Skip to content

Instantly share code, notes, and snippets.

@n1nj4sec
Created October 8, 2019 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n1nj4sec/d40fb14ca7a861443bb9578502d51361 to your computer and use it in GitHub Desktop.
Save n1nj4sec/d40fb14ca7a861443bb9578502d51361 to your computer and use it in GitHub Desktop.
A little forensic script to extract a pupy payload's config.
#!/usr/bin/env python
# -*- coding: UTF8 -*-
import sys
import struct
import pylzma
if __name__=="__main__":
data=b""
found=False
with open(sys.argv[1], 'rb') as fd:
data=fd.read()
for i in range(int(0), len(data)):
try:
size_compressed, size_uncompressed = struct.unpack(">II", data[i:i+8])
if size_compressed > 65536:
continue
data=pylzma.decompress(data[i+8:i+8+size_compressed])
if len(data)==size_uncompressed:
print("decompressed config valid at offset %s"%i)
print(data)
found=True
except Exception as e:
continue
if not found:
print("config not found :'(. The template has probably been modified")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment