Advertisement
Guest User

Untitled

a guest
Jan 9th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import binascii
  2. import struct
  3. from binascii import hexlify, unhexlify
  4.  
  5. # XOR data
  6. def xor_byte(byte):
  7. s1 = byte
  8. s2 = "ff"
  9. return hexlify(''.join(chr(ord(c1) ^ ord(c2)) for c1, c2 in zip(unhexlify(s1[-len(s2):]), unhexlify(s2))))
  10.  
  11. def xor_data(hex_data):
  12. result = []
  13. for b in range( len(hex_data)/2 ):
  14. xored_byte = xor_byte( hex_data[2*b:2*(b+1)] )
  15. result.append(xored_byte)
  16. return "".join(result)
  17.  
  18. # Read data
  19. with open('onion3.txt') as in_file:
  20. hex_data = in_file.read()
  21.  
  22. # Unhexlify the data.
  23. #bin_data = unhexlify( xor_data(hex_data.replace('\r\n','')) )
  24. bin_data = unhexlify( hex_data.replace('\r\n','') )
  25.  
  26. # Write out the JPEG.
  27. with open('onion3.jpg', 'wb') as out_file:
  28. out_file.write(bin_data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement