Created
November 28, 2018 18:50
-
-
Save leoloobeek/bc278637f6e4215dcddf1812a513ce9f to your computer and use it in GitHub Desktop.
Sample Extract Payload DotNetToJScript
This file contains 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 python2 | |
#Orginal Location https://gist.github.com/williballenthin/52debe05295266186cd2673ebf169967 | |
''' | |
Carve PE files from binary data. | |
Write them into the current directy named after their hash. | |
Example:: | |
$ python carvepe.py unallocated.bin | |
INFO:__main__:found pe at 0x0, length: 0xd8000 | |
INFO:__main__:writing pe file to 273ed32b617fd79ed1b88ebd4521a441.bin | |
$ ls | |
595f44fec1e92a71d3e9e77456ba80d1.bin | |
71f920fa275127a7b60fa4d4d41432a3.bin | |
43c191bf6d6c3f263a8cd0efd4a058ab.bin | |
author: Willi Ballenthin | |
''' | |
import sys | |
import mmap | |
import hashlib | |
import logging | |
import contextlib | |
from collections import namedtuple | |
import pefile | |
import argparse | |
logger = logging.getLogger(__name__) | |
Match = namedtuple('Match', ['offset', 'size']) | |
def carve(data): | |
""" | |
find things that look like PE files from arbitrary binary data. | |
Args: | |
data (str): arbitrary byte string | |
Yields: | |
Match: one Match instance per identified PE file. | |
""" | |
offset = 0 | |
while True: | |
offset = data.find('MZ', offset) | |
if offset == -1: | |
break | |
logger.debug('found MZ: 0x%x', offset) | |
# grab a bunch of data that should include the entire binary. | |
# assume less than 10mb. | |
max_offset = min(len(data), offset + 10 * 1024 * 1024) | |
payload = data[offset:max_offset] | |
try: | |
pe = pefile.PE(data=payload) | |
except pefile.PEFormatError: | |
logger.debug('not actually a PE, sorry.') | |
else: | |
logger.debug('yup, this looks ok.') | |
# try to compute the size of the PE file. | |
# we'll enumerate each section, and find the end of the last section. | |
# this should work for most binaries, unless there is an overlay. | |
# the PE file format does not have a true "file length" field, unfortunately. | |
max_addr = 0 | |
for section in sorted(pe.sections, key=lambda s: s.PointerToRawData): | |
section_max_addr = section.PointerToRawData + section.SizeOfRawData | |
if section_max_addr > max_addr: | |
max_addr = section_max_addr | |
if pe.OPTIONAL_HEADER.CheckSum == pe.generate_checksum(): | |
logger.debug('checksum verified') | |
yield Match(offset, max_addr) | |
offset += 1 | |
def main(argv=None): | |
if argv is None: | |
argv = sys.argv[1:] | |
parser = argparse.ArgumentParser(description="Carve PE files from binary data.") | |
parser.add_argument("input", type=str, | |
help="Path to input file") | |
parser.add_argument("-v", "--verbose", action="store_true", | |
help="Enable debug logging") | |
parser.add_argument("-q", "--quiet", action="store_true", | |
help="Disable all output but errors") | |
args = parser.parse_args() | |
if args.verbose: | |
logging.basicConfig(level=logging.DEBUG) | |
elif args.quiet: | |
logging.basicConfig(level=logging.ERROR) | |
else: | |
logging.basicConfig(level=logging.INFO) | |
with open(args.input, 'rb') as f: | |
# we're using a memory map here. | |
# it lets us read from a large file as if it were entirely in memory. | |
# (but its not, actually) | |
with contextlib.closing(mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)) as m: | |
for match in carve(m): | |
pe = m[match.offset:match.offset+match.size] | |
logger.info('found pe at 0x%x, length: 0x%x', match.offset, match.size) | |
m = hashlib.md5() | |
m.update(pe) | |
logger.debug('md5sum: %s', m.hexdigest()) | |
outpath = m.hexdigest() + '.bin' | |
logger.info('writing pe file to %s', outpath) | |
with open(outpath, 'wb') as g: | |
g.write(pe) | |
if __name__ == "__main__": | |
sys.exit(main()) |
This file contains 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
//Base64 Raw Decoder | |
function Base64Decode(str) { | |
if (!(/^[a-z0-9+/]+={0,2}$/i.test(str)) || str.length%4 != 0) throw Error('Not base64 string'); | |
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
var o1, o2, o3, h1, h2, h3, h4, bits, d=[]; | |
for (var c=0; c<str.length; c+=4) { // unpack four hexets into three octets | |
h1 = b64.indexOf(str.charAt(c)); | |
h2 = b64.indexOf(str.charAt(c+1)); | |
h3 = b64.indexOf(str.charAt(c+2)); | |
h4 = b64.indexOf(str.charAt(c+3)); | |
bits = h1<<18 | h2<<12 | h3<<6 | h4; | |
o1 = bits>>>16 & 0xff; | |
o2 = bits>>>8 & 0xff; | |
o3 = bits & 0xff; | |
d[c/4] = String.fromCharCode(o1, o2, o3); | |
// check for padding | |
if (h4 == 0x40) d[c/4] = String.fromCharCode(o1, o2); | |
if (h3 == 0x40) d[c/4] = String.fromCharCode(o1); | |
} | |
str = d.join(''); // use Array.join() for better performance than repeated string appends | |
return str; | |
} | |
//End Base64 Decoder | |
function setversion() { | |
} | |
function debug(s) {} | |
function base64ToStream(b) { | |
var enc = new ActiveXObject("System.Text.ASCIIEncoding"); | |
var length = enc.GetByteCount_2(b); | |
var ba = enc.GetBytes_4(b); | |
var transform = new ActiveXObject("System.Security.Cryptography.FromBase64Transform"); | |
ba = transform.TransformFinalBlock(ba, 0, length); | |
var ms = new ActiveXObject("System.IO.MemoryStream"); | |
ms.Write(ba, 0, (length / 4) * 3); | |
ms.Position = 0; | |
return ms; | |
} | |
var serialized_obj = "AAEAAAD/////AQAAAAAAAAAEAQAAACJTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVy"+ | |
"AwAAAAhEZWxlZ2F0ZQd0YXJnZXQwB21ldGhvZDADAwMwU3lzdGVtLkRlbGVnYXRlU2VyaWFsaXph"+ | |
"dGlvbkhvbGRlcitEZWxlZ2F0ZUVudHJ5IlN5c3RlbS5EZWxlZ2F0ZVNlcmlhbGl6YXRpb25Ib2xk"+ | |
"ZXIvU3lzdGVtLlJlZmxlY3Rpb24uTWVtYmVySW5mb1NlcmlhbGl6YXRpb25Ib2xkZXIJAgAAAAkD"+ | |
"AAAACQQAAAAEAgAAADBTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyK0RlbGVnYXRl"+ | |
"RW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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ | |
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ | |
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ | |
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ | |
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+ | |
"AAAAAAAAAAAAAAAAAAAAAAENAAAABAAAAAkXAAAACQYAAAAJFgAAAAYaAAAAJ1N5c3RlbS5SZWZs"+ | |
"ZWN0aW9uLkFzc2VtYmx5IExvYWQoQnl0ZVtdKQgAAAAKCwAA"; | |
var entry_class = 'TestClass'; | |
try { | |
setversion(); | |
var stm = base64ToStream(serialized_obj); | |
var fmt = new ActiveXObject('System.Runtime.Serialization.Formatters.Binary.BinaryFormatter'); | |
var al = new ActiveXObject('System.Collections.ArrayList'); | |
var d = fmt.Deserialize_2(stm); | |
al.Add(undefined); | |
var o = d.DynamicInvoke(al.ToArray()).CreateInstance(entry_class); | |
//Extract Serialized Object to file.bin | |
var base64decoded = Base64Decode(serialized_obj); | |
var TextStream = WScript.CreateObject('ADODB.Stream'); | |
TextStream.Type = 2; | |
TextStream.charSet = 'iso-8859-1'; | |
TextStream.Open(); | |
TextStream.WriteText(base64decoded); | |
var BinaryStream = WScript.CreateObject('ADODB.Stream'); | |
BinaryStream.Type = 1; | |
BinaryStream.Open(); | |
TextStream.Position = 0; | |
TextStream.CopyTo(BinaryStream); | |
BinaryStream.SaveToFile("file.bin", 2); | |
BinaryStream.Close(); | |
//End Extract | |
//Go Rip that MZ Header. | |
//File.Bin is the serialized object that contains the assembly | |
} catch (e) { | |
debug(e.message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment