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)
def xorOutguess(): data = [] for i in range(3): cur = "" f = open("../outguesses/out" + str(i) + ".jpg.out", 'r') next(f); next(f) for line in f: if line[:3] == "---": break else: cur += line data.append(dparse.hexToInt(dparse.txtToHex(cur))) xored = dmanip.xor(data[0], dmanip.xor(data[1], data[2])) print dparse.intToAsc(xored)
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"
#!/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)))
#!/usr/bin/python import dparse import dstats import dmanip print "starting" txt = "" with open("../data/twitter.hex", "r") as f: for line in f: if line[:3] == "Off": continue txt += line[9:] print "parsing" tInt = dparse.hexToInt(dparse.txtToHex(txt)) sInt = dparse.ascToInt(dparse.txtToAsc(dparse.readFile("761.MP3"))) dstats.magNumSearch(sInt) print len(tInt) print len(sInt) outFile = open("../pics/twitter.jpg", "w") outFile.write(dparse.intToAsc(dmanip.xor(tInt, sInt))) outFile.close()
#!/usr/bin/python import dparse import dstats import dmanip raw1 = "" with open("../outguesses/2out0.jpg.out", 'r') as f: for i in range(9): next(f) for line in f: if line[:3] == "---": break raw1 += line #raw2 = dparse.readFile("../outguesses/2out1.jpg.out") h1Hex = dparse.txtToHex(raw1) h1Int = dparse.hexToInt(h1Hex) h1Asc = dparse.intToAsc(h1Int) with open("../pics/newrunes.jpg", 'w') as f: f.write(h1Asc)
if len(i) == 58152: relData.append(i) print len(relData) relData = [dparse.txtToAsc(i) for i in relData] xored = relData[0] for i in range(1, len(relData)): xored = dmanip.xor(xored, relData[i]) dstats.extMagNum(dparse.intToHex(xored)) with open("../data/xorrunes.asc", 'w') as f: f.write(dparse.intToAsc(xored)) # Search for suffs and prefs # count = 2 # prevPref = 0 # prevSuff = 0 # while(True): # prefs = [', '.join([str(j) for j in i[:count]]) for i in data] # suffs = [', '.join([str(j) for j in i[-count:]]) for i in data] # # curPref = len(dstats.getFreq(prefs)) # curSuff = len(dstats.getFreq(suffs)) # # if curPref != prevPref: # print "Pref change from " + str(prevPref) + " to " + str(curPref) + " at " + str(count) #