Changeset 18 for test/blackhat-demo/jregistrate-collect
- Timestamp:
- 08/01/15 19:04:49 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/blackhat-demo/jregistrate-collect
r15 r18 34 34 parser = argparse.ArgumentParser( 35 35 description="") 36 parser.add_argument('-c', dest='cases', type=str, default='{"valid":"0012-5969","invalid":"0012-9999"}', 37 help='JSON representation of echo timing cases.') 38 parser.add_argument('--no-tcpts', action='store_true', help='Disbale TCP timestamp profiling') 36 parser.add_argument('--no-tcpts', action='store_true', help='Disable TCP timestamp profiling') 39 37 parser.add_argument('--no-control', action='store_true', help='Do not collect separate control data. Instead, synthesize it from test and train data.') 40 38 parser.add_argument('session_name', default=None, … … 55 53 protocol = 'http' 56 54 57 cases = json.loads(options.cases)55 cases = {"valid":"0012-8846","invalid":"0012-9999"} 58 56 59 57 … … 69 67 70 68 71 def sendRequest( data=None):69 def sendRequest(case_data): 72 70 method = 'POST' 73 71 path = '/jregistrate/register' 74 72 url = "%s://%s:%d%s" % (protocol,hostname,port,path) 75 73 headers = {"Content-Type":"application/x-www-form-urlencoded"} 76 body = (b'member_id='+ data.encode('utf-8')+b'&last_four=1111&zip_code=97219&username=bob&password=&conf_pwd=')74 body = (b'member_id='+case_data.encode('utf-8')+b'&last_four=1111&zip_code=97219&username=bob&password=&conf_pwd=') 77 75 req = requests.Request(method, url, headers=headers, data=body).prepare() 78 76 … … 82 80 session = requests.Session() 83 81 response = session.send(req, verify=False) 84 #print(repr(response.raw._original_response.local_address))85 82 reported = extractReportedRuntime(response.headers, response.text) 86 83 retry = False … … 89 86 time.sleep(1.0) 90 87 sys.stderr.write("ERROR: retrying...\n") 91 #print(data.encode('utf-8'), reported)92 88 93 89 return {'userspace_rtt':response.elapsed.microseconds*1000, … … 170 166 sample_order[i] = (sample_order[i][0],sample_order[0][1]) 171 167 random.shuffle(sample_order) 172 #print('after', sample_order)173 168 174 169 results = [] … … 179 174 sample_order[i][1])) 180 175 181 #print(results)182 176 db.addProbes(results) 183 177 db.conn.commit() … … 185 179 186 180 if (time.time() > next_report): 187 #s = time.time()188 181 reportProgress(db, sample_types, start) 189 #print("reportProgress time:", time.time()-s)190 182 next_report += report_interval 191 183 … … 194 186 stopSniffer(sniffer) 195 187 196 start = time.time()197 188 associatePackets(sniffer_fp, db) 198 189 sniffer_fp.close() 199 end = time.time()200 print("associate time:", end-start)201 190 202 191 if options.no_control:
Note: See TracChangeset
for help on using the changeset viewer.