├── EFI └── Boot │ ├── BOOTX64.efi │ ├── grubx64.efi │ ├── grub.cfg.original │ └── grub.cfg ├── README.md ├── mkwinusb ├── mkkaliusb └── format-usb /EFI/Boot/BOOTX64.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wh1t3Rh1n0/usb-tools/HEAD/EFI/Boot/BOOTX64.efi -------------------------------------------------------------------------------- /EFI/Boot/grubx64.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wh1t3Rh1n0/usb-tools/HEAD/EFI/Boot/grubx64.efi -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | usb-tools 2 | ========= 3 | Tools for Quickly Formatting and Partitioning USB Flash Drives 4 | 5 | The rest of this file was automatically generated with the following command: 6 | 7 | (for f in * ; do ./$f --help ; done) >> README.md 8 | 9 | 10 | format-usb 11 | ---------- 12 | Quickly create an msdos partition table and a single, formatted partition 13 | on a given USB flash drive so that it is compatible with Microsoft Windows. 14 | 15 | Usage: 16 | 17 | format-usb [device] [optional partition label] [optional fs type] 18 | 19 | You must provide a label if specifying the filesystem type. 20 | 21 | Accepted filesystem flags: 22 | 23 | --ntfs 24 | --exfat 25 | --none 26 | 27 | 28 | mkkaliusb 29 | --------- 30 | Create a Kali or Ubuntu Linux USB flash drive with the following 31 | characteristics: 32 | 33 | * A single FAT32 filesystem - The entire flash drive is still readable and 34 | writable from Windows and other operating systems. 35 | 36 | * Bootable on legacy PCs via BIOS and modern PCs and Macs via EFI. 37 | 38 | * All boot files have the hidden, system, and read-only flags set so they 39 | are not visible by default on Windows operating systems. 40 | 41 | Usage: 42 | 43 | mkkaliusb [ISO] [device] 44 | 45 | 46 | mkwinusb 47 | -------- 48 | Create a bootable USB Windows 7, 8, or 10 install media from an ISO. 49 | 50 | Usage: 51 | 52 | mkwinusb [ISO] [device] 53 | 54 | -------------------------------------------------------------------------------- /EFI/Boot/grub.cfg.original: -------------------------------------------------------------------------------- 1 | # Config file for GRUB2 - The GNU GRand Unified Bootloader 2 | # /boot/grub/grub.cfg 3 | 4 | # DEVICE NAME CONVERSIONS 5 | # 6 | # Linux Grub 7 | # ------------------------- 8 | # /dev/fd0 (fd0) 9 | # /dev/sda (hd0) 10 | # /dev/sdb2 (hd1,2) 11 | # /dev/sda3 (hd0,3) 12 | # 13 | # root=UUID=dc08e5b0-e704-4573-b3f2-cfe41b73e62b persistent 14 | 15 | set menu_color_normal=yellow/blue 16 | set menu_color_highlight=blue/yellow 17 | 18 | function load_video { 19 | insmod efi_gop 20 | insmod efi_uga 21 | insmod video_bochs 22 | insmod video_cirrus 23 | insmod all_video 24 | } 25 | 26 | load_video 27 | set gfxpayload=keep 28 | 29 | # Timeout for menu 30 | set timeout=5 31 | 32 | # Set default boot entry as Entry 0 33 | set default=0 34 | set color_normal=yellow/blue 35 | 36 | menuentry "Kali - Boot Non Persistent Mode" { 37 | set root=(hd0,1) 38 | linuxefi /live/vmlinuz boot=live noconfig=sudo username=root hostname=kali 39 | initrdefi /live/initrd.img 40 | } 41 | 42 | menuentry "Kali - Boot Persistent" { 43 | set root=(hd0,1) 44 | linuxefi /live/vmlinuz boot=live noconfig=sudo username=root hostname=kali persistence 45 | initrdefi /live/initrd.img 46 | } 47 | 48 | menuentry "Kali Failsafe" { 49 | set root=(hd0,1) 50 | linuxefi /live/vmlinuz boot=live config memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal 51 | initrdefi /live/initrd.img 52 | } 53 | 54 | menuentry "Kali Forensics - No Drive or Swap Mount" { 55 | set root=(hd0,1) 56 | linuxefi /live/vmlinuz boot=live noconfig=sudo username=root hostname=kali noswap noautomount 57 | initrdefi /live/initrd.img 58 | } 59 | 60 | menuentry "Kali Graphical Install" { 61 | set root=(hd0,1) 62 | linuxefi /install/gtk/vmlinuz video=vesa:ywrap,mtrr vga=788 63 | initrdefi /install/gtk/initrd.gz 64 | } 65 | 66 | menuentry "Kali Text Install" { 67 | set root=(hd0,1) 68 | linuxefi /install/vmlinuz video=vesa:ywrap,mtrr vga=788 69 | initrdefi /install/initrd.gz 70 | } -------------------------------------------------------------------------------- /mkwinusb: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## 3 | ## mkwinusb 4 | ## -------- 5 | ## Create a bootable USB Windows 7, 8, or 10 install media from an ISO. 6 | ## 7 | ## Usage: 8 | ## 9 | ## mkwinusb [ISO] [device] 10 | ## 11 | if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] ; then 12 | grep -E '^##[^#]?' "$0" | sed -E 's/## ?//g' 13 | if [ "$1" == "" ] ; then 14 | echo 15 | echo "Available devices:" 16 | fdisk -l | grep -E '/dev/sd[a-z][^0-9]' 17 | echo 18 | fi 19 | exit 20 | fi 21 | 22 | ISO=$1 23 | DEVICE=$2 24 | LABEL=$3 25 | 26 | if [ "$LABEL" == "" ]; then 27 | LABEL=Windows 28 | fi 29 | 30 | # Check whether format-usb is in the current directory or available in the 31 | # path. 32 | if ! ( [ -e "./format-usb" ] || which format-usb ) ; then 33 | echo "Cannot find format-usb in the current directory or the default path." 34 | exit 35 | fi 36 | FORMATUSB=$(which format-usb || echo ./format-usb) 37 | 38 | 39 | # Check that ms-sys is installed 40 | if [ "$(which ms-sys)" == "" ] ; then 41 | cat < 20 | ## 21 | 22 | if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] ; then 23 | grep -E '^##[^#]?' "$0" | sed -E 's/## ?//g' 24 | if [ "$1" == "" ] ; then 25 | echo 26 | echo "Available devices:" 27 | fdisk -l | grep -E '/dev/sd[a-z][^0-9]' 28 | echo 29 | fi 30 | exit 31 | fi 32 | 33 | ISO=$1 34 | DEVICE=$2 35 | LABEL=$3 36 | 37 | if [ "$LABEL" == "" ]; then 38 | LABEL=Kali 39 | fi 40 | 41 | # Check whether format-usb is in the current directory or available in the 42 | # path. 43 | if ! ( [ -e "./format-usb" ] || which format-usb ) ; then 44 | echo "Cannot find format-usb in the current directory or the default path." 45 | exit 46 | fi 47 | FORMATUSB=$(which format-usb || echo ./format-usb) 48 | 49 | if ! ( which grub-install || which fatattr ) ; then 50 | cat < "$TMPDIR/usb/autorun.inf" 101 | [autorun] 102 | ;open=explorer.exe 103 | ;icon=icon.ico,0 104 | label=$LABEL 105 | 106 | [Content] 107 | MusicFiles=True 108 | PictureFiles=True 109 | VideoFiles=True 110 | EOF 111 | 112 | # Hide all files on the flash drive from Windows 113 | fatattr +r +h +s $TMPDIR/usb/* 114 | 115 | # Unmount the ISO and USB 116 | umount $TMPDIR/iso 117 | umount $TMPDIR/usb 118 | 119 | echo 'DONE! Eject flash drive with "eject '$DEVICE'".' 120 | #eject $DEVICE && echo "$DEVICE Ejected"'!' && echo "Please remove the flash drive now." 121 | -------------------------------------------------------------------------------- /format-usb: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## 3 | ## format-usb 4 | ## ---------- 5 | ## Quickly create an msdos partition table and a single, formatted partition 6 | ## on a given USB flash drive so that it is compatible with Microsoft Windows. 7 | ## 8 | ## Usage: 9 | ## 10 | ## format-usb [device] [optional partition label] [optional fs type] 11 | ## 12 | ## You must provide a label if specifying the filesystem type. 13 | ## 14 | ## Accepted filesystem flags: 15 | ## 16 | ## --ntfs 17 | ## --exfat 18 | ## --none 19 | ## 20 | ## Additional options: 21 | ## 22 | ## --zero : Completely overwrite the device with zero's before 23 | ## formatting 24 | ## 25 | 26 | if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] ; then 27 | grep -E '^##[^#]?' "$0" | sed -E 's/## ?//g' 28 | if [ "$1" == "" ] ; then 29 | echo 30 | echo "Available devices:" 31 | fdisk -l | grep -E '/dev/sd[a-z][^0-9]' 32 | echo 33 | fi 34 | exit 35 | fi 36 | 37 | DEVICE=$1 38 | LABEL=$2 39 | 40 | echo "DEVICE=$DEVICE" 41 | echo "LABEL=$LABEL" 42 | 43 | if [ "$(echo \"$*\" | grep '\--ntfs')" != "" ] ; then 44 | FS=--ntfs 45 | elif [ "$(echo \"$*\" | grep '\--exfat')" != "" ] ; then 46 | FS=--exfat 47 | if [ "$(which mkfs.exfat)" == "" ] ; then 48 | echo "Could not find mkfs.exfat" 49 | echo "Make sure these packages are installed: exfat-utils exfat-fuse" 50 | exit 51 | fi 52 | elif [ "$(echo \"$*\" | grep '\--none')" != "" ] ; then 53 | FS=--none 54 | else 55 | FS=--fat 56 | fi 57 | 58 | #read -p 1 59 | 60 | # Unmount current partitions 61 | for d in $(mount | grep "$1" | cut -d ' ' -f 1); do 62 | echo $d 63 | umount -f $d || exit 64 | done 65 | 66 | # Zero the device if desired 67 | if [ "$(echo \"$*\" | grep '\--zero')" != "" ] ; then 68 | echo "Overwriting $DEVICE with zeros... (This may take a while)" 69 | dd if=/dev/zero of=$DEVICE bs=512k 70 | echo 'OK!' 71 | fi 72 | 73 | # Overwrite the first 10 MB of the device 74 | dd if=/dev/zero of=$DEVICE bs=1M count=10 75 | echo Please wait... 76 | 77 | # Overwrite the last 10 MB of the device 78 | DEVSIZE=$( fdisk -l | grep "$DEVICE" | grep Disk | grep -iEo '[0-9]+ bytes' | cut -d ' ' -f 1 ) 79 | SEEKTO=$(expr $DEVSIZE - 10485760) 80 | #dd if=/dev/zero of=$DEVICE seek=$SEEKTO status=progress oflag=seek_bytes bs=512k 81 | dd if=/dev/zero of=$DEVICE seek=$SEEKTO oflag=seek_bytes bs=512k 82 | echo Please wait... 83 | 84 | partprobe >/dev/null 2>/dev/null 85 | 86 | 87 | #read -p a 88 | 89 | # Wipe out any existing GPT 90 | #cat </dev/null 2>/dev/null 99 | 100 | #read -p b 101 | 102 | # Create the new partition table 103 | echo parted $DEVICE mktable msdos yes 104 | #parted $DEVICE mktable msdos yes 105 | cat </dev/null 2>/dev/null 113 | 114 | if [ "$FS" == "--none" ]; then 115 | eject $DEVICE && echo "$DEVICE Ejected"'!' && echo "Please remove the flash drive now." 116 | exit 117 | fi 118 | 119 | #read -p 2 120 | 121 | echo $FS 122 | # Create a single primary partition 123 | if [ "$FS" == "--ntfs" ] || [ "$FS" == "--exfat" ] ; then 124 | # NTFS/EXFAT 125 | FSTYPE=7 126 | else 127 | # FAT32 128 | FSTYPE=0b 129 | fi 130 | cat </dev/null 2>/dev/null 144 | 145 | #read -p 3 146 | 147 | # Unmount current partitions again (in case some idiotic thing automounts them) 148 | for d in $(mount | grep "$1" | cut -d ' ' -f 1); do 149 | echo $d 150 | umount -f $d 151 | done 152 | 153 | 154 | # Format the partition and apply provided label 155 | if [ "$FS" == "--ntfs" ] ; then 156 | # NTFS 157 | if [ "$LABEL" != "" ] ; then 158 | mkfs.ntfs -L "$LABEL" -Q $DEVICE"1" 159 | else 160 | mkfs.ntfs -Q $DEVICE"1" 161 | fi 162 | elif [ "$FS" == "--exfat" ] ; then 163 | # exfat 164 | if [ "$LABEL" != "" ] ; then 165 | mkfs.exfat -n "$LABEL" $DEVICE"1" 166 | else 167 | mkfs.exfat $DEVICE"1" 168 | fi 169 | else 170 | # VFAT 171 | if [ "$LABEL" != "" ] ; then 172 | mkfs.vfat -n "$LABEL" $DEVICE"1" 173 | else 174 | mkfs.vfat $DEVICE"1" 175 | fi 176 | fi 177 | echo Please wait... 178 | sync 179 | partprobe >/dev/null 2>/dev/null 180 | 181 | # Check filesystem for errors 182 | fsck $DEVICE'1' 183 | echo Please wait... 184 | 185 | echo 'Done! :D' 186 | 187 | #eject $DEVICE && echo "$DEVICE Ejected"'!' && echo "Please remove the flash drive now." 188 | --------------------------------------------------------------------------------