# cat blog >> /dev/brain 2> /proc/mind
cat blog >> /dev/brain 2> /proc/mind
# cat xor_alternative.py import sys # data contains hex chars (a-f + 0-9) and random chars # Chars are not repeated data = '2ubfLkR0vsJ#)=SQtXNcO6AYPT1U+ja7W*h9I-y4GeHzn5&BK;_@$U3dm8^%' def obfuscate(s, step): out = '' ldata = len(data) ls = len(s) for i in s: h = hex(ord(i))[2:] for j in h: p = data.index(j) p2 = (p + step) % ldata out += data[p2] return out def deobfuscate(s, step): out = '' ldata = len(data) ls = len(s) for i in range(0, ls, 2): h = '' for j in range(2): p = data.index(s[i + j]) p2 = (p - step) % ldata h += data[p2] out += chr(int(h, 16)) return out action = sys.argv[1] s = sys.argv[2] step = int(sys.argv[3]) print 'String =', s print 'Step =', step if action == 'o': print 'Action = Obfuscate' print 'Result =', obfuscate(s, step) elif action == 'd': print 'Action = Deobfuscate' print 'Result =', deobfuscate(s, step) # python xor_alternative.py o SECRET 1234 String = SECRET Step = 1234 Action = Obfuscate Result = c+=c=+ch=cc= # python xor_alternative.py d c+=c=+ch=cc= 1234 String = c+=c=+ch=cc= Step = 1234 Action = Deobfuscate Result = SECRET
cat xor_alternative.py
python xor_alternative.py o SECRET 1234
python xor_alternative.py d c+=c=+ch=cc= 1234
Post a Comment
No comments:
Post a Comment