Last active
September 16, 2019 10:00
-
-
Save Anirbansingha1/7268eca7cca62eb36dda1d7c0bdf0687 to your computer and use it in GitHub Desktop.
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
| import requests,sys | |
| myfile=sys.argv[1] | |
| headers = {} | |
| param={} | |
| cookie={} | |
| c=0 | |
| row_body='' | |
| parampost={} | |
| with open(myfile) as h: | |
| for line in h: | |
| if line.startswith('GET'): | |
| c+=1 | |
| request_type='GET' | |
| print 'Request Type "GET"' | |
| if '?' in line: | |
| extra_url=line.replace('GET','').strip().split('?')[0] | |
| params=line.replace('GET','').strip().split('?')[1].split('&') | |
| for li in params: | |
| if '=' in li: | |
| li=li.split('=') | |
| param[li[0]]=li[1] | |
| else: | |
| extra_url=line.split(' ')[1] | |
| elif line.startswith('POST'): | |
| print 'Request Type "POST"' | |
| c+=1 | |
| request_type='POST' | |
| if '?' in line: | |
| extra_url=line.replace('POST','').strip().split('?')[0] | |
| params=line.replace('GET','').strip().split('?')[1].split('&') | |
| for li in params: | |
| if '=' in li: | |
| li=li.split('=') | |
| param[li[0]]=li[1] | |
| else: | |
| extra_url=line.split(' ')[1] | |
| elif line.startswith('Host'): | |
| host='https://'+line.strip().split(' ')[1] | |
| host=host+extra_url | |
| elif line.startswith('Cookie'): | |
| line=line.split(';') | |
| for li in line: | |
| if '=' in li: | |
| li=li.split('=') | |
| cookie[li[0].strip()]=li[1].strip() | |
| elif c==0: | |
| print 'Request Type "'+line.split(' ')[0].strip()+'" Not Supported!' | |
| exit() | |
| elif line.startswith('['): | |
| if '[' in line: | |
| row_body=line | |
| elif '=' in line and '&' in line: | |
| line=line.split('&') | |
| for k in line: | |
| k=k.split('=') | |
| parampost[k[0].strip()]=k[1].strip() | |
| else: | |
| if ':' in line: | |
| line=line.split(':') | |
| headers[line[0]]=line[1].strip() | |
| if host:print ('url: '+host) | |
| if headers: print ('Headers: '+str(headers)) | |
| if row_body:print ('Raw Body: '+str(row_body)) | |
| if param:print ('Param: '+str(param)) | |
| if cookie:print ('Cookie:- '+str(cookie)) | |
| if parampost: print('ParamPost: '+str(parampost)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment