Skip to content

Instantly share code, notes, and snippets.

@shollingsworth
Created September 6, 2019 18:47
Show Gist options
  • Save shollingsworth/5531daf63cffe8db98b6dba092b68143 to your computer and use it in GitHub Desktop.
Save shollingsworth/5531daf63cffe8db98b6dba092b68143 to your computer and use it in GitHub Desktop.
MagicRescue Demo for RootAccess Sept 2019
#!/bin/bash
size_mb="50"
dest_file=$(mktemp)
mount_dir=$(mktemp -d)
dd if=/dev/urandom of=${dest_file} bs=1M count=${size_mb}
echo "destfile ${dest_file} crated"
lodev=$(losetup --show -f ${dest_file})
echo "loopback ${lodev} created"
mkfs.ext4 ${lodev}
echo "${lodev} formatted"
mkdir -pv ${mount_dir}
mount -v ${lodev} ${mount_dir}
echo "mounted ${lodev} to ${mount_dir}"
df -h ${mount_dir}
echo "Press enter to destroy! (ctl-c) to exit"
read
umount -v ${mount_dir}
rmdir -v ${mount_dir}
losetup -v -d "${lodev}"
rm -fv ${dest_file}
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
disk="${1?"arg0:disk"}"
out="${2?"arg1:output directory"}"
if ! which magicrescue &>/dev/null; then
echo "install magicrescue"
exit 1
fi
all_recipes=($(find /usr/share/magicrescue -type f | xargs -I{} basename {} | sed 's/^/-r /'))
# mkdir -pv ${out}
echo magicrescue ${all_recipes[*]} -d ${out} ${disk}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment