|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +perdev=`/opt/drivebadger/internal/kali/get-first-persistent-partition.sh` |
| 4 | + |
| 5 | +if [ "$perdev" != "" ]; then |
| 6 | + target_partition=`basename $perdev` |
| 7 | + target_drive=`/opt/drivebadger/internal/generic/get-partition-drive.sh $target_partition` |
| 8 | + |
| 9 | + target_raw_device=`/opt/drivebadger/internal/generic/get-raw-device.sh $perdev` # sdb3 or dm-0 |
| 10 | + logger "persistent partition $perdev on device $target_raw_device" |
| 11 | + |
| 12 | + id=`/opt/drivebadger/internal/generic/get-computer-id.sh` |
| 13 | + target_root_directory=`/opt/drivebadger/internal/kali/get-target-directory.sh $target_partition` |
| 14 | + target_directory=$target_root_directory/$id |
| 15 | + keys_directory=`/opt/drivebadger/internal/kali/get-keys-directory.sh $target_partition` |
| 16 | + |
| 17 | + mkdir -p $target_directory $keys_directory |
| 18 | + /opt/drivebadger/internal/generic/dump-debug-files.sh $target_directory |
| 19 | + |
| 20 | + for uuid in `ls /dev/disk/by-uuid`; do |
| 21 | + tmp=`readlink /dev/disk/by-uuid/$uuid` |
| 22 | + current_partition=`basename $tmp` # dm-0 is handled properly below, but dm-1 etc. not - fix before reusing this code in different context |
| 23 | + current_drive=`/opt/drivebadger/internal/generic/get-partition-drive.sh $current_partition` |
| 24 | + |
| 25 | + if [ "$current_partition" = "$target_raw_device" ] || [ "$current_partition" = "$target_partition" ]; then |
| 26 | + logger "skipping UUID=$uuid (partition $current_partition matches target $target_partition)" |
| 27 | + elif [ "$current_drive" = "$target_drive" ]; then |
| 28 | + logger "skipping UUID=$uuid (partition $current_partition lays on the same target drive $target_drive as target partition $target_partition)" |
| 29 | + else |
| 30 | + fs=`/opt/drivebadger/internal/generic/get-partition-fs-type.sh $current_partition $target_directory` |
| 31 | + drive_serial=`/opt/drivebadger/internal/generic/get-drive-serial.sh $current_drive $target_directory` |
| 32 | + |
| 33 | + if [ "$fs" = "swap" ]; then |
| 34 | + logger "skipping UUID=$uuid (swap partition $current_partition)" |
| 35 | + elif [ "$fs" = "apfs" ]; then |
| 36 | + nohup /opt/drivebadger/internal/generic/mount/apfs.sh $target_root_directory $target_directory $keys_directory "$drive_serial" $current_partition $uuid 2>/dev/null |
| 37 | + elif [ "$fs" = "crypto_LUKS" ]; then |
| 38 | + nohup /opt/drivebadger/internal/generic/mount/luks.sh $target_root_directory $target_directory $keys_directory "$drive_serial" $current_partition $uuid 2>/dev/null |
| 39 | + else |
| 40 | + nohup /opt/drivebadger/internal/generic/mount/plain.sh $target_root_directory $target_directory $keys_directory "$drive_serial" $current_partition $uuid $fs 2>/dev/null |
| 41 | + fi |
| 42 | + fi |
| 43 | + done |
| 44 | + |
| 45 | + # now process encrypted drives |
| 46 | + |
| 47 | + for current_partition in `/opt/drivebadger/internal/generic/get-udev-unrecognized-devices.sh`; do |
| 48 | + current_drive=`/opt/drivebadger/internal/generic/get-partition-drive.sh $current_partition` |
| 49 | + drive_serial=`/opt/drivebadger/internal/generic/get-drive-serial.sh $current_drive $target_directory` |
| 50 | + fs=`/opt/drivebadger/internal/generic/get-partition-fs-type.sh $current_partition $target_directory` |
| 51 | + |
| 52 | + if [ "$fs" = "VMFS_volume_member" ]; then |
| 53 | + nohup /opt/drivebadger/internal/generic/mount/vmfs.sh $target_root_directory $target_directory $keys_directory "$drive_serial" $current_partition 2>/dev/null |
| 54 | + else |
| 55 | + nohup /opt/drivebadger/internal/generic/mount/unrecognized.sh $target_root_directory $target_directory $keys_directory "$drive_serial" $current_partition 2>/dev/null |
| 56 | + fi |
| 57 | + |
| 58 | + done |
| 59 | + |
| 60 | + logger "finished processing drives and partitions" |
| 61 | +fi |
0 commit comments