CRIME python diskdump

From: Shaun Savage (savages@private)
Date: Mon Nov 18 2002 - 23:46:58 PST

  • Next message: Jeff Bryner: "RE: CRIME Great presentation!!"

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1
    
    
    Here is a GPL disk dump program.  It compresses disk data in 32k blocks.
    it has 2 tracks, a data track and header track.  Each CD has has 4
    hashes,  SHA and MD5 for both uncompressed and compressed.  It spans
    multi CDs. The data is pulled of the disk by 'dd' because there is no
    iso format.
    
    I do to need to add  hash of hash and a better user interface. This is
    just a first try of a program I had to write for a friend.
    
    I just added the hash and compression.
    
    Shaun Savage
    
    
    
    - --
    savages@private
    GPG = B527 8F72 BAFA D490 6B30  6885 9FA2 34E8 EA73 F975
    Public key at  http://www.savages.net/gpg/savages
    
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.0 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
    
    iD8DBQE92exvn6I06Opz+XURAjYIAJwPYC2oz+gq+92nMD/TTyMtZZZ5GACfXaUG
    KiPNwp7To8VMk4TcVcMiqpo=
    =f//y
    -----END PGP SIGNATURE-----
    
    
    #!/usr/bin/python
    
    #* diskdump - forensic disk backup
    #* By Shaun Savage <savages@private>
    #* Copyright 2002 Shaun Savage
    #*
    #* This program is free software; you can redistribute it and/or
    #* modify it under the terms of the GNU General Public License
    #* as published by the Free Software Foundation; either version 2
    #* of the License, or (at your option) any later version.
    #*
    #* This program is distributed in the hope that it will be useful,
    #* but WITHOUT ANY WARRANTY; without even the implied warranty of
    #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #* GNU General Public License for more details.
    #*
    #* You should have received a copy of the GNU General Public License
    #* along with this program; if not, write to the Free Software
    #* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    
    import zlib
    import sha
    import md5
    import os
    
    disk = "hda"
    count = 0
    
    def rddsk(idx,start):
        shash = sha.new()
        schash = sha.new()
        mhash = md5.new()
        mchash = md5.new()
        ic = []
    
        dsk = "/dev/"+disk
    
        fin = open(dsk)
        fin.seek(start*32768,0)
        fout = open("dsk.out","w+")
        idx = 0
        tl = 0
        i=0
    
        while tl < 681574400:
            d = fin.read(32768)
            dc = zlib.compress(d,9)
            shash.update(d)
            schash.update(dc)
            mhash.update(d)
            mchash.update(dc)
            dl = len(dc)
            i += 1
            if (i + start) > count :
                break
            tl += dl
            ic.append(tl)
            fout.write(dc)
    
        fin.close()
        fout.close()
    
        f = open("hdr.out","w+")
        f.write(str(idx)+"\n")
        f.write(str(start)+"\n")
        f.write(str(tl)+"\n")
        f.write(str(i*32768)+"\n")
        f.write(shash.hexdigest()+"\n")
        f.write(mhash.hexdigest()+"\n")
        f.write(schash.hexdigest()+"\n")
        f.write(mchash.hexdigest()+"\n")
    
        f.close()
        return start+i
    
    
    def docd(idx,start): 
        rtn = rddsk(idx,start)
    
        raw_input("Put In disk "+str(idx))
        os.system("cdrecord dev=0,0,0 -multi speed=12 -data dsk.out")
        os.system("cdrecord dev=0,0,0 -eject speed=12 -data -shorttrack hdr.out ")
    
        return rtn
    
    index=0
    blk=0
    f = open("/proc/ide/"+disk+"/capacity")
    sz = f.read(255)
    f.close()
    
    count = int(sz)/32
    
    while blk < count:
        blk = docd(index,blk)
        index += 1
    



    This archive was generated by hypermail 2b30 : Tue Nov 19 2002 - 00:42:38 PST