sysopfb

royal trojan overlay decoder

Mar 23rd, 2018
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import struct
  2. import pefile
  3. import sys
  4.  
  5. addv = 305419896
  6. xorv = 0x55aa9966
  7.  
  8. def manip(val):
  9. return ((val + addv) ^ xorv) & 0xffffffff
  10.  
  11. def decoder_overlay(key,data):
  12. (a,b,c,d) = struct.unpack_from('<IIII', key)
  13. val1 = b ^ c
  14. val2 = (a ^ d) + manip(val1)
  15. for i in range(7):
  16. nextval = val1 + manip(val2)
  17. val1 = val2
  18. temp = val2 & 0xffffffff
  19. val2 = nextval
  20. val1 = temp
  21. val2 = nextval
  22. out = ""
  23. for j in range(len(data)):
  24. nextval = val1 + manip(val2)
  25. out += chr((nextval ^ val2 ^ ord(data[j]))&0xff)
  26. val1 = val2 & 0xffffffff
  27. val2 = nextval
  28. return out
  29.  
  30.  
  31. if __name__ == "__main__":
  32. pe = pefile.PE(sys.argv[1])
  33. blob = pe.get_overlay()
  34. key = blob[:16]
  35. t = decoder_overlay(key,blob[16:])
  36. open(sys.argv[1]+'_decoded_overlay','wb').write(t)
Advertisement
Add Comment
Please, Sign In to add comment