<s> '''<STR_LIT>''' <EOL> import os <EOL> import peutils <EOL> import pefile <EOL> import pkg_resources <EOL> import pprint <EOL> def get_peid_db ( ) : <EOL> '''<STR_LIT>''' <EOL> my_dir = os . path . dirname ( os . path . realpath ( __file__ ) ) <EOL> db_path = os . path . join ( my_dir , '<STR_LIT>' ) <EOL> if not os . path . exists ( db_path ) : <EOL> raise RuntimeError ( '<STR_LIT>' % db_path ) <EOL> signatures = peutils . SignatureDatabase ( data = open ( db_path , '<STR_LIT:rb>' ) . read ( ) ) <EOL> return signatures <EOL> PEID_SIGS = get_peid_db ( ) <EOL> class PEIDWorker ( object ) : <EOL> '''<STR_LIT>''' <EOL> dependencies = [ '<STR_LIT>' ] <EOL> def __init__ ( self ) : <EOL> self . peid_sigs = PEID_SIGS <EOL> def execute ( self , input_data ) : <EOL> '''<STR_LIT>''' <EOL> raw_bytes = input_data [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> try : <EOL> pefile_handle = pefile . PE ( data = raw_bytes , fast_load = False ) <EOL> except ( AttributeError , pefile . PEFormatError ) , error : <EOL> return { '<STR_LIT:error>' : str ( error ) , '<STR_LIT>' : [ ] } <EOL> peid_match = self . peid_features ( pefile_handle ) <EOL> return { '<STR_LIT>' : peid_match } <EOL> def peid_features ( self , pefile_handle ) : <EOL> '''<STR_LIT>''' <EOL> peid_match = self . peid_sigs . match ( pefile_handle ) <EOL> return peid_match if peid_match else [ ] <EOL> def test ( ) : <EOL> '''<STR_LIT>''' <EOL> import zerorpc <EOL> workbench = zerorpc . Client ( timeout = <NUM_LIT> , heartbeat = <NUM_LIT> ) <EOL> workbench . connect ( "<STR_LIT>" ) <EOL> import os <EOL> data_path = os . path . join ( os . path . dirname ( os . path . realpath ( __file__ ) ) , <EOL> '<STR_LIT>' ) <EOL> md5 = workbench . store_sample ( open ( data_path , '<STR_LIT:rb>' ) . read ( ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> input_data = workbench . get_sample ( md5 ) <EOL> worker = PEIDWorker ( ) <EOL> output = worker . execute ( input_data ) <EOL> print '<STR_LIT>' <EOL> pprint . pprint ( output ) <EOL> output = workbench . work_request ( '<STR_LIT>' , md5 ) <EOL> print '<STR_LIT>' <EOL> pprint . pprint ( output ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test ( ) </s>
