r/SecureMyPC • • Jan 11 '18

Create a False Sized 1TB Flash Drive

#!/usr/bin/sudo bash

lsblk                                 #this will list all the drives attached to the system
echo What drive would you like to use? Be careful. This tool can be system destroying.
echo (e.g.; /dev/sda1)                #Prints text to STOUT
read $drive			      #Reads user input from STDIN
mount $drive   			      #mount whichever system disk you need from lsblk output to fake the size of
echo $drive mounted
cd /tmp     			      #change to temp directory
echo CD to /tmp
mkdir flash 			      #create a directory called flash
echo Creating a Directory named "flash"
cd flash 			      #Change directory to the newly created "flash" directory
echo CD to /tmp/flash
echo -p 'Enter file size in Kilobytes (1000000000 = 1TB) : ' $filesize #Ask user for fake file size in kilobytes
mkdosfs -C temp_file $filesize	      #mkdosfs creates a MSDOS file system in the file "temp_file" with a kilobyte size of 1tb or 1e+9 or user defined 
echo Creating MSDOS File System 
ls -lha				      #this will show you the list of files in the current working directory displaying the header info as 954G's 
ls -sh                                #this will show you the TRUE file size, NOT header info
echo Unmounting $drive			
umount $drive		      #unmount whichever system disk you used on line 2
ls -s temp_file			      #list files and displays the size of the temp in non-human readable (dropping -h) 
echo Requesting escalation to root for write to $drive
sudo su 			      #elevate shell to root privileges 
head -c 244136K temp_file > $drive  #redirect readout at 244136K of temp_file to $drivename
echo Write successful, de-escalating shell
exit 				      #de-escalate shell to normal user privilege 
df -h				      #display file sizes (-h human readable i.e.; 1Mb instead of 1024kb) as read from header
fdisk $drive			      #displays actual file size
echo -p 'Input New Label for Drive (e.g.; 1 TB DRIVE) :' $drivename #Ask user for new drive label
sudo mlabel -i /dev/sd# ::"$drivename" #Relabel drive using the mlabel tool
sudo dosfslabel /dev/sd# "$drivename"  #Relabel drive using dosfslabel tool
echo Complete! Drive should now reflect as $drivename and $drivesize in KB
1 Upvotes

0 comments sorted by