---Description -- -- @args xxx yyyyy -- -- @author Ron Bowes -- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html ----------------------------------------------------------------------- module(... or "pe", package.seeall) require 'bit' require 'bin' require 'stdnse' require 'nsedebug' function parse_from_string(data) local pos, _ local result = {} -- Start by reading the first two bytes and ensuring it's a proper executable (they should be 'MZ') pos, result['MZ'] = bin.unpack("A2", data) if(result['MZ'] == nil or result['MZ'] ~= "MZ") then return false, "File does not appear to be a proper executable (doesn't start with 'MZ')" end -- The 2-byte offset to the actual PE header is located at 0x3C pos, result['pe_offset'] = bin.unpack("