Ejemplo n.º 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)
Ejemplo n.º 2
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"