From 804ae2e0a37e186206e76d722caf15455bb414df Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 5 Sep 2016 16:22:58 +0200 Subject: [PATCH] hide stuff in text --- hax/somedecode.py | 39 ++++++++++++++++++++++++++++++++++++++ hax/someencode.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100755 hax/somedecode.py create mode 100755 hax/someencode.py diff --git a/hax/somedecode.py b/hax/somedecode.py new file mode 100755 index 0000000..2f9dcaa --- /dev/null +++ b/hax/somedecode.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +import sys +import os +import signal +import csv +import binascii + + +def somedecode(infilename, outfilename): + with open(infilename, 'r') as infile: + infilestr=infile.read() + + bitstrstr = "" + + for c in infilestr: + if c in "abcdefghinjklmnopqrstuvwxyz": + bitstrstr += "0" + elif c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": + bitstrstr += "1" + else: + pass + + bitstrstr = bitstrstr[:-(len(bitstrstr)%8)] + + print(bitstrstr) + + retstr = binascii.unhexlify('%x' % int(bitstrstr, 2)) + open(outfilename, 'w').write(retstr.decode()) + + +if __name__ == "__main__": + def signal_handler(signal, frame): + print('SIG received. exitting!') + sys.exit(0) + signal.signal(signal.SIGINT, signal_handler) + + somedecode("out.txt", "dec.txt") + diff --git a/hax/someencode.py b/hax/someencode.py new file mode 100755 index 0000000..95c02bd --- /dev/null +++ b/hax/someencode.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +import sys +import os +import signal +import csv +import binascii + + +def someencode(infilename, strfilename, outfilename): + with open(infilename, 'r') as infile: + infilestr=infile.read() + with open(strfilename, 'r') as strfile: + strfilestr=strfile.read().strip() + + bitstrstr = "".join(["{0:08b}".format(ord(i)) for i in strfilestr ]) + +# print (infilestr) + print (bitstrstr) + + retstr = "" + bit = 0 + + for c in infilestr: + if bit >= len(bitstrstr): + retstr = retstr + c + elif c not in "abcdefghinjklmnopqrstuvwxyz": + retstr = retstr + c + elif bitstrstr[bit] == "1": + retstr = retstr + chr(ord(c)-32) + bit += 1 + else: + retstr = retstr + c + bit += 1 + + if bit < len(bitstrstr): + print("SOME PAYLOAD NOT ENCODED!") + open(outfilename, 'w').write(retstr) + + +if __name__ == "__main__": + def signal_handler(signal, frame): + print('SIG received. exitting!') + sys.exit(0) + signal.signal(signal.SIGINT, signal_handler) + + someencode("in.txt", "str.txt", "out.txt") + -- 2.43.0