Skip to content

Commit f9a0447

Browse files
committed
initial version
0 parents  commit f9a0447

18 files changed

+256
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config/*.txt
2+
iso/*.iso
3+
iso/*.img

.nobackup

Whitespace-only changes.

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020-2022 Tomasz Klim
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Overview
2+
3+
This repository provides some scripts useful for deploying a large number of Drive Badger / Mobile Badger devices, having a similar configuration.
4+
5+
It may be useful, when preparing an attack on bigger company:
6+
7+
https://drivebadger.com/planning-the-big-attack.html
8+
9+
10+
Note that these scripts don't arm the devices. It needs to be done manually, after first boot. It allows you to customize each device separately,
11+
eg. load encryption keys assigned to particular device and its operator.
12+
13+
https://drivebadger.com/installing.html#arming-the-device
14+
15+
https://drivebadger.com/configuring-encryption-keys.html

config/drivebadger-devices.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ata-PNY_ELITE_PSSD_D9F12345678901234567
2+
ata-PNY_ELITE_PSSD_DC4ABCDEF1234567890A
3+
ata-SanDisk_SD9SN8W2T00_19359H123456
4+
usb-WD_My_Passport_264F_32303333312D345678901234-0:0

config/local-drives.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ata-Samsung_SSD_870_EVO_1TB_S61234567890ABC

config/master-luks-password.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
put-your-main-password-here-it-will-be-used-for-all-devices-in-key-slot-0

drivebadger/configure-new-device.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
PASSFILE=/opt/deployment-scripts/config/master-luks-password.txt
4+
DEVLIST=/opt/deployment-scripts/config/drivebadger-devices.txt
5+
LOCAL=/opt/deployment-scripts/config/local-drives.txt
6+
7+
DISK=$1 # eg. ata-SanDisk_SD9SN8W2T00_19359H123456
8+
ARCH=$2 # eg. amd64
9+
IMAGE=/opt/deployment-scripts/iso/kali-linux-2021.4a-live-$ARCH.iso
10+
11+
if [ "$2" = "" ]; then
12+
echo "USAGE: $0 <disk> <architecture> [--plain]"
13+
exit 1
14+
elif [ ! -f $IMAGE ]; then
15+
echo "ERROR: $IMAGE not found (you need to download image for chosen architecture: $2)"
16+
exit 1
17+
elif [ ! -e /dev/disk/by-id/$DISK ]; then
18+
echo "ERROR: $DISK not found"
19+
exit 1
20+
elif grep -qxF $DISK $DEVLIST; then
21+
echo "ERROR: disk $DISK already configured"
22+
exit 1
23+
elif grep -qxF $DISK $LOCAL; then
24+
echo "ERROR: disk $DISK is a local drive"
25+
exit 1
26+
fi
27+
28+
DEVICE=`readlink -f /dev/disk/by-id/$DISK |cut -d'/' -f3`
29+
30+
if grep -q "$DEVICE " /proc/mounts; then
31+
echo "ERROR: disk $DISK is mounted (as device $DEVICE)"
32+
exit 1
33+
fi
34+
35+
echo "copying image $IMAGE"
36+
echo "to device /dev/$DEVICE"
37+
dd if=$IMAGE of=/dev/$DEVICE status=progress
38+
39+
echo "adding new partition"
40+
parted /dev/$DEVICE --script -- mkpart primary 10GB 100%
41+
mkdir -p /mnt/drivebadger_setup
42+
43+
if [ "$3" = "--plain" ]; then
44+
mkfs.ext4 -m 0 -L persistence /dev/${DEVICE}3
45+
mount /dev/${DEVICE}3 /mnt/drivebadger_setup
46+
else
47+
echo "configuring LUKS encryption"
48+
cat $PASSFILE |cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 luksFormat /dev/${DEVICE}3
49+
cat $PASSFILE |cryptsetup luksOpen /dev/${DEVICE}3 drivebadger_setup
50+
mkfs.ext4 -m 0 -L persistence /dev/mapper/drivebadger_setup
51+
mount /dev/mapper/drivebadger_setup /mnt/drivebadger_setup
52+
fi
53+
54+
echo "setting up persistent filesystem contents"
55+
/opt/deployment-scripts/drivebadger/install.sh /mnt/drivebadger_setup
56+
umount /mnt/drivebadger_setup
57+
58+
if [ "$3" != "--plain" ]; then
59+
cryptsetup luksClose drivebadger_setup
60+
fi
61+
62+
echo "adding $DISK to device list $DEVLIST"
63+
echo $DISK >>$DEVLIST

drivebadger/get-label.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
DISK=$1 # ata-SanDisk_SD9SN8W2T00_19359H123456
4+
5+
echo $DISK |cut -d'-' -f2- |cut -d'_' -f1 |tr '[:upper:]' '[:lower:]'

drivebadger/install.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
BASE=$1
4+
5+
if [ "$BASE" = "" ] || [ ! -d $BASE ]; then
6+
echo "usage: $0 <directory>"
7+
exit 0
8+
fi
9+
10+
echo "/ union" >$BASE/persistence.conf
11+
touch $BASE/.nobackup
12+
mkdir -p $BASE/.files/.data $BASE/rw/opt
13+
14+
git clone https://github.com/pisecurity/mc-black $BASE/rw/opt/mc-black
15+
git clone https://github.com/drivebadger/drivebadger $BASE/rw/opt/drivebadger
16+
git clone https://github.com/drivebadger/hook-wcxftp $BASE/rw/opt/drivebadger/hooks/hook-wcxftp
17+
git clone https://github.com/drivebadger/hook-fstab $BASE/rw/opt/drivebadger/hooks/hook-fstab
18+
git clone https://github.com/drivebadger/exclude-windows $BASE/rw/opt/drivebadger/config/exclude-windows
19+
git clone https://github.com/drivebadger/exclude-macos $BASE/rw/opt/drivebadger/config/exclude-macos
20+
git clone https://github.com/drivebadger/exclude-linux $BASE/rw/opt/drivebadger/config/exclude-linux
21+
git clone https://github.com/drivebadger/exclude-antivirus $BASE/rw/opt/drivebadger/config/exclude-antivirus
22+
git clone https://github.com/drivebadger/exclude-software $BASE/rw/opt/drivebadger/config/exclude-software
23+
git clone https://github.com/drivebadger/exclude-devel $BASE/rw/opt/drivebadger/config/exclude-devel
24+
git clone https://github.com/drivebadger/exclude-user $BASE/rw/opt/drivebadger/config/exclude-user
25+
git clone https://github.com/drivebadger/exclude-erp $BASE/rw/opt/drivebadger/config/exclude-erp
26+
git clone https://github.com/drivebadger/compat $BASE/rw/opt/drivebadger/external/compat
27+
git clone https://github.com/drivebadger/ext-veracrypt $BASE/rw/opt/drivebadger/external/ext-veracrypt
28+
29+
30+
# Here you should add your own repositories:
31+
# - lists of drive encryption keys; example: https://github.com/drivebadger/keys-bitlocker-demo
32+
# - any custom hooks, injectors and other functional extensions (if you have any)
33+
#
34+
# See https://drivebadger.com/installing.html for more details.
35+
36+
37+
# This command should be executed after first start of Kali Linux Live:
38+
#
39+
# cd /opt/drivebadger/setup/2020.3 && ./install.sh

drivebadger/list-connected-devices.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
DEVLIST=/opt/deployment-scripts/config/drivebadger-devices.txt
4+
5+
for D in `cat $DEVLIST`; do
6+
if [ -e /dev/disk/by-id/$D ]; then
7+
echo $D
8+
fi
9+
done
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
DEVLIST=/opt/deployment-scripts/config/drivebadger-devices.txt
4+
5+
for D in `cat $DEVLIST`; do
6+
if [ ! -e /dev/disk/by-id/$D ]; then
7+
echo $D
8+
fi
9+
done
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
ls /dev/disk/by-id/ata-* /dev/disk/by-id/usb-* 2>/dev/null \
4+
|grep -v -- -part \
5+
|grep -v VBOX \
6+
|grep -v QEMU \
7+
|grep -v VMware \
8+
|grep -v CF_CARD \
9+
|cut -d'/' -f 5 \
10+
|grep -vixFf /opt/deployment-scripts/config/drivebadger-devices.txt \
11+
|grep -vixFf /opt/deployment-scripts/config/local-drives.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
for D in `/opt/deployment-scripts/drivebadger/list-connected-devices.sh`; do
4+
echo "### attempting to mount $D"
5+
/opt/deployment-scripts/drivebadger/mount.sh $D 3
6+
done

drivebadger/mount.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
PASSFILE=/opt/deployment-scripts/config/master-luks-password.txt
4+
5+
DISK=$1 # ata-SanDisk_SD9SN8W2T00_19359H123456
6+
PART=$2 # 3
7+
8+
LABEL=`/opt/deployment-scripts/drivebadger/get-label.sh $DISK`
9+
PARTITION=`readlink -f /dev/disk/by-id/$DISK-part$PART |cut -d'/' -f3`
10+
11+
mountpoint=/mnt/${LABEL}_${PARTITION}
12+
mkdir -p $mountpoint
13+
14+
if grep -q " $mountpoint " /proc/mounts; then
15+
echo "$mountpoint already mounted"
16+
exit 0
17+
fi
18+
19+
20+
if [ "`blkid /dev/$PARTITION |grep crypto_LUKS`" = "" ]; then
21+
mount /dev/$PARTITION $mountpoint
22+
else
23+
cat $PASSFILE |cryptsetup -q luksOpen /dev/$PARTITION luks_$PARTITION
24+
if [ -e /dev/mapper/luks_$PARTITION ]; then
25+
mount /dev/mapper/luks_$PARTITION $mountpoint
26+
echo "mounted in $mountpoint"
27+
else
28+
exit 1
29+
fi
30+
fi

drivebadger/umount.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
DISK=$1 # ata-SanDisk_SD9SN8W2T00_19359H123456
4+
PART=$2 # 3
5+
6+
LABEL=`/opt/deployment-scripts/drivebadger/get-label.sh $DISK`
7+
PARTITION=`readlink -f /dev/disk/by-id/$DISK-part$PART |cut -d'/' -f3`
8+
9+
mountpoint=/mnt/${LABEL}_${PARTITION}
10+
11+
if ! grep -q " $mountpoint " /proc/mounts; then
12+
echo "$mountpoint not mounted"
13+
exit 0
14+
fi
15+
16+
umount $mountpoint
17+
18+
if [ -e /dev/mapper/luks_$PARTITION ]; then
19+
cryptsetup luksClose luks_$PARTITION
20+
fi

iso/kali.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
wget https://cdimage.kali.org/kali-2021.4a/kali-linux-2021.4a-live-amd64.iso
4+
wget https://cdimage.kali.org/kali-2021.4a/kali-linux-2021.4a-live-i386.iso
5+
wget https://cdimage.kali.org/kali-2021.4a/kali-linux-2021.4a-live-arm64.iso

iso/raspbian.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# well tested version
4+
FILE=2021-05-07-raspios-buster-armhf-lite.zip
5+
wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-05-28/$FILE
6+
unzip -b $FILE
7+
rm -f $FILE
8+
9+
# latest available version
10+
FILE=2021-10-30-raspios-bullseye-armhf-lite.zip
11+
wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-11-08/$FILE
12+
unzip -b $FILE
13+
rm -f $FILE

0 commit comments

Comments
 (0)