def generate_corpus(options): td = curl_test_data.TestData("../data") with open(options.output, "wb") as f: enc = TLVEncoder(f) # Write the URL to the file. enc.write_string(enc.TYPE_URL, options.url) # Write the first response to the file. if options.rsp1: enc.write_bytes(enc.TYPE_RSP1, options.rsp1.encode("utf-8")) elif options.rsp1file: with open(options.rsp1file, "rb") as g: enc.write_bytes(enc.TYPE_RSP1, g.read()) elif options.rsp1test: wstring = td.get_test_data(options.rsp1test) enc.write_bytes(enc.TYPE_RSP1, wstring.encode("utf-8")) # Write other options to file. enc.maybe_write_string(enc.TYPE_USERNAME, options.username) enc.maybe_write_string(enc.TYPE_PASSWORD, options.password) enc.maybe_write_string(enc.TYPE_POSTFIELDS, options.postfields) return ScriptRC.SUCCESS
def __init__(self, address, config_parser=None, test_data_directory=None): imp_smbserver.SMBSERVER.__init__(self, address, config_parser=config_parser) # Set up a test data object so we can get test data later. self.ctd = curl_test_data.TestData(test_data_directory) # Override smbComNtCreateAndX so we can pretend to have files which # don't exist. self.hookSmbCommand(imp_smb.SMB.SMB_COM_NT_CREATE_ANDX, self.create_and_x)
def generate_corpus(options): td = curl_test_data.TestData("../data") with open(options.output, "wb") as f: enc = TLVEncoder(f) # Write the URL to the file. enc.write_string(enc.TYPE_URL, options.url) # Write the first response to the file. if options.rsp1: enc.write_bytes(enc.TYPE_RSP1, options.rsp1.encode("utf-8")) elif options.rsp1file: with open(options.rsp1file, "rb") as g: enc.write_bytes(enc.TYPE_RSP1, g.read()) elif options.rsp1test: wstring = td.get_test_data(options.rsp1test) enc.write_bytes(enc.TYPE_RSP1, wstring.encode("utf-8")) # Write other options to file. enc.maybe_write_string(enc.TYPE_USERNAME, options.username) enc.maybe_write_string(enc.TYPE_PASSWORD, options.password) enc.maybe_write_string(enc.TYPE_POSTFIELDS, options.postfields) enc.maybe_write_string(enc.TYPE_COOKIE, options.cookie) enc.maybe_write_string(enc.TYPE_RANGE, options.range) enc.maybe_write_string(enc.TYPE_CUSTOMREQUEST, options.customrequest) enc.maybe_write_string(enc.TYPE_MAIL_FROM, options.mailfrom) # Write the first upload to the file. if options.upload1: enc.write_bytes(enc.TYPE_UPLOAD1, options.upload1.encode("utf-8")) elif options.upload1file: with open(options.upload1file, "rb") as g: enc.write_bytes(enc.TYPE_UPLOAD1, g.read()) # Write an array of headers to the file. if options.header: for header in options.header: enc.write_string(enc.TYPE_HEADER, header) # Write an array of headers to the file. if options.mailrecipient: for mailrecipient in options.mailrecipient: enc.write_string(enc.TYPE_MAIL_RECIPIENT, mailrecipient) return ScriptRC.SUCCESS
def generate_corpus(options): sys.path.append(options.curl_test_dir) import curl_test_data td = curl_test_data.TestData(os.path.join(options.curl_test_dir, "data")) with open(options.output, "wb") as f: enc = corpus.TLVEncoder(f, td) # Write the URL to the file. enc.write_string(enc.TYPE_URL, options.url) # Write any responses to the file. enc.maybe_write_response(enc.TYPE_RSP0, options.rsp0, options.rsp0file, options.rsp0test) enc.maybe_write_response(enc.TYPE_RSP1, options.rsp1, options.rsp1file, options.rsp1test) enc.maybe_write_response(enc.TYPE_RSP2, options.rsp2, options.rsp2file, options.rsp2test) enc.maybe_write_response(enc.TYPE_RSP3, options.rsp3, options.rsp3file, options.rsp3test) enc.maybe_write_response(enc.TYPE_RSP4, options.rsp4, options.rsp4file, options.rsp4test) enc.maybe_write_response(enc.TYPE_RSP5, options.rsp5, options.rsp5file, options.rsp5test) enc.maybe_write_response(enc.TYPE_RSP6, options.rsp6, options.rsp6file, options.rsp6test) enc.maybe_write_response(enc.TYPE_RSP7, options.rsp7, options.rsp7file, options.rsp7test) enc.maybe_write_response(enc.TYPE_RSP8, options.rsp8, options.rsp8file, options.rsp8test) enc.maybe_write_response(enc.TYPE_RSP9, options.rsp9, options.rsp9file, options.rsp9test) enc.maybe_write_response(enc.TYPE_RSP10, options.rsp10, options.rsp10file, options.rsp10test) # Write any second socket responses to the file. enc.maybe_write_response(enc.TYPE_SECRSP0, options.secrsp0, options.secrsp0file, options.secrsp0test) enc.maybe_write_response(enc.TYPE_SECRSP1, options.secrsp1, options.secrsp1file, options.secrsp1test) # Write other options to file. enc.maybe_write_string(enc.TYPE_USERNAME, options.username) enc.maybe_write_string(enc.TYPE_PASSWORD, options.password) enc.maybe_write_string(enc.TYPE_POSTFIELDS, options.postfields) enc.maybe_write_string(enc.TYPE_COOKIE, options.cookie) enc.maybe_write_string(enc.TYPE_RANGE, options.range) enc.maybe_write_string(enc.TYPE_CUSTOMREQUEST, options.customrequest) enc.maybe_write_string(enc.TYPE_MAIL_FROM, options.mailfrom) enc.maybe_write_string(enc.TYPE_ACCEPT_ENCODING, options.acceptencoding) enc.maybe_write_string(enc.TYPE_RTSP_SESSION_ID, options.rtspsessionid) enc.maybe_write_string(enc.TYPE_RTSP_STREAM_URI, options.rtspstreamuri) enc.maybe_write_string(enc.TYPE_RTSP_TRANSPORT, options.rtsptransport) enc.maybe_write_string(enc.TYPE_MAIL_AUTH, options.mailauth) enc.maybe_write_u32(enc.TYPE_HTTPAUTH, options.httpauth) enc.maybe_write_u32(enc.TYPE_OPTHEADER, options.optheader) enc.maybe_write_u32(enc.TYPE_NOBODY, options.nobody) enc.maybe_write_u32(enc.TYPE_FOLLOWLOCATION, options.followlocation) enc.maybe_write_u32(enc.TYPE_WILDCARDMATCH, options.wildcardmatch) enc.maybe_write_u32(enc.TYPE_RTSP_REQUEST, options.rtsprequest) enc.maybe_write_u32(enc.TYPE_RTSP_CLIENT_CSEQ, options.rtspclientcseq) # Write the first upload to the file. if options.upload1: enc.write_bytes(enc.TYPE_UPLOAD1, options.upload1.encode("utf-8")) elif options.upload1file: with open(options.upload1file, "rb") as g: enc.write_bytes(enc.TYPE_UPLOAD1, g.read()) # Write an array of headers to the file. if options.header: for header in options.header: enc.write_string(enc.TYPE_HEADER, header) # Write an array of headers to the file. if options.mailrecipient: for mailrecipient in options.mailrecipient: enc.write_string(enc.TYPE_MAIL_RECIPIENT, mailrecipient) # Write an array of mimeparts to the file. if options.mimepart: for mimepart in options.mimepart: enc.write_mimepart(mimepart) return ScriptRC.SUCCESS