Created
September 30, 2014 14:48
-
-
Save Rurik/f6a05d9fb50ed5085223 to your computer and use it in GitHub Desktop.
Determine the .NET version used to compile a .NET executable.
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
def get_NET_version(data): | |
""" | |
Code to extract .NET compiled version. | |
typedef struct t_MetaData_Header { | |
DWORD Signature; // BSJB | |
WORD MajorVersion; | |
WORD MinorVersion; | |
DWORD Unknown1; | |
DWORD VersionSize; | |
PBYTE VersionString; | |
WORD Flags; | |
WORD NumStreams; | |
PBYTE Streams; | |
} METADATA_HEADER, *PMETADATA_HEADER; | |
""" | |
offset = data.find('BSJB') | |
if offset > 0: | |
hdr = data[offset:offset+32] | |
magic = hdr[0:4] | |
major = struct.unpack('i', hdr[4:8])[0] | |
minor = struct.unpack('i', hdr[8:12])[0] | |
size = struct.unpack('i', hdr[12:16])[0] | |
return hdr[16:16+size].strip('\x00') | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment