Beispiel #1
0
def createPictures():
        print "Reading file"
        raw = dparse.readFile("onion5.hex")

        print "Parsing"
        dHex = dparse.txtToHex(raw)
        dInt = dparse.hexToInt(dHex)
        dBin = dparse.intToBin(dInt)
        
        print "Searching"
        start = dstats.searchForBytes(dHex, ['FF', 'D8', 'FF'])
        end   = dstats.searchForBytes(dHex, ['FF', 'D9']) + 2

        print "Separating: " + str(start) + ", " + str(end)
        iBin = dBin[start : end]
        
        iInt = dparse.binToInt(iBin)
        iAsc = dparse.intToAsc(iInt)

        print "Writing"
        outFile = open("../pics/2out0.jpg", 'w')
        outFile.write(iAsc)
        outFile.close()
       
        remains = dBin[end:]

        remains = dmanip.flipOrder(remains)
        rAsc = dparse.intToAsc(dparse.binToInt(remains))
        with open("../pics/2out1.jpg", 'w') as f:
                f.write(rAsc)
Beispiel #2
0
def flipBits(b):
        ret = []

        i = dparse.binToInt(b)
        
        for byte in i:
                ret.append(xor([byte], [255])[0])
        
        return dparse.intToBin(ret)
Beispiel #3
0
def extMagNum(h):
        print "Creating flipped data"
        i = dparse.hexToInt(h)
        b = dparse.intToBin(i)
        bFlip = dmanip.flipBits(b)
        bRev = dmanip.flipBinOrder(b)
        bRevFlip = dmanip.flipBits(bRev)
        
        hFlip = dparse.intToHex(dparse.binToInt(bFlip))
        hRev = dparse.intToHex(dparse.binToInt(bRev))
        hRevFlip = dparse.intToHex(dparse.binToInt(bRevFlip))
        
        print "> Searching normal"
        magNumSearch(h)

        print "> Searching flipped bits"
        magNumSearch(hFlip)

        print "> Searching reversed order"
        magNumSearch(hRev)

        print "> Searching flipped bits and reversed order"
        magNumSearch(hRevFlip)
Beispiel #4
0
def createPictures():
        print "Reading file"
        raw = dparse.readFile("onion2.hex")

        print "Parsing"
        dHex = dparse.txtToHex(raw)
        dInt = dparse.hexToInt(dHex)
        dBin = dparse.intToBin(dInt)

        print "Flipping"
        dBinFlipped = dmanip.flipBits(dBin)

        for i in range(3):
                if i == 2:
                        dBinFlipped = dmanip.flipOrder(dBinFlipped)
                

                print "Searching"
                start = dstats.searchForBytes(dBinFlipped, dparse.intToBin(dparse.hexToInt(['FF', 'D8'])))
                end   = dstats.searchForBytes(dBinFlipped, dparse.intToBin(dparse.hexToInt(['FF', 'D9']))) + 2

                print "Separating: " + str(start) + ", " + str(end)
                iBin = dBinFlipped[start : end]
                
                print dBinFlipped[:5]
                print dBinFlipped[-5:]
                print "---"
                print iBin[:5]
                print iBin[-5:]
                print "---"
                
                dBinFlipped = dBinFlipped[end:] # Cut off beginning of file for next iteration
                iInt = dparse.binToInt(iBin)
                iAsc = dparse.intToAsc(iInt)

                print "Writing"
                outFile = open("../pics/out" + str(i) + ".jpg", 'w')
                outFile.write(iAsc)
                outFile.close()

        print "Done"
Beispiel #5
0
#!/usr/bin/python

import dparse
import dmanip
import dstats

txt = ""

with open("../data/new.txt", "r") as f:
    next(f)
    next(f)

    for line in f:
        if line[:3] == "---":
            break
        txt += line
        print len(line)

bRaw = ""

for c in txt:
    if c == "\t":
        bRaw += "1"
    elif c == " ":
        bRaw += "0"


print dparse.intToAsc(dparse.binToInt(dparse.txtToBin(bRaw)))