-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexploit_http.py
More file actions
executable file
·44 lines (36 loc) · 1.6 KB
/
exploit_http.py
File metadata and controls
executable file
·44 lines (36 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
import requests as req
import json
# Good ressources https://book.hacktricks.xyz/generic-methodologies-and-resources/python/web-requests
# https://docs.python-requests.org/en/latest/user/quickstart/#make-a-request
## The following variables can be given to the request methods.
url = '' # 'http://example.com:80/'
params = {} # {'p1':'value1', 'p2':'value2'}
# headers = {} # {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)', 'Content-Type': 'application/json'}
# cookies = {} # {'PHPSESSID': '1234567890abcdef', 'FakeCookie123': '456'}
# proxies = {} # {'http':'http://127.0.0.1:8080','https':'http://127.0.0.1:8080'}
# files = {'file': ('filename.txt', open('filename.txt', 'rb'))}
s = req.Session()
## GET
# res = s.get(url)
# res = requests.get('https://httpbin.org/stream/20', stream=True) # GET stream
# for line in r.iter_lines():
# # filter out keep-alive new lines
# if line:
# decoded_line = line.decode('utf-8')
# print(json.loads(decoded_line))
## POST
# res = s.post(url, data='plain text', headers={'Content-Type': 'text/plain'}) # plain/text
# res = s.post(url, data=params) # form-encoded data application/x-www-form-urlencoded
# res = s.post(url, json=params) # json application/json
# res = s.post(url, files=files) # file multipart/form-data
## RESPONSE contents
# code = res.status_code
# ret_headers = res.headers
# body_byte = res.content
# body_text = res.text
# ret_cookies = res.cookies
# is_redirect = res.is_redirect
# is_permanent_redirect = res.is_permanent_redirect
# float_seconds = res.elapsed.total_seconds()
# json = res.json()