Created
October 8, 2019 08:43
-
-
Save n1nj4sec/d40fb14ca7a861443bb9578502d51361 to your computer and use it in GitHub Desktop.
A little forensic script to extract a pupy payload's config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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