-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_forms.py
More file actions
executable file
·40 lines (28 loc) · 977 Bytes
/
extract_forms.py
File metadata and controls
executable file
·40 lines (28 loc) · 977 Bytes
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
#!/usr/bin/env python3
import requests
import urllib.parse as urlparse
from bs4 import BeautifulSoup
def request(url):
try:
return requests.get(url)
except requests.exceptions.ConnectionError:
pass
target_url = "http://10.0.2.5/mutillidae/index.php?page=dns-lookup.php"
response = request(target_url)
parsed_html = BeautifulSoup(response.content, features="lxml")
forms_list = parsed_html.findAll("form")
for form in forms_list:
action = form.get("action")
post_url = urlparse.urljoin(target_url, action)
method = form.get("method")
inputs_list = form.findAll("input")
post_data = {}
for input in inputs_list:
input_name = input.get("name")
input_type = input.get("type")
input_value = input.get("value")
if input_type == 'text':
input_value = 'test'
post_data[input_name] = input_value
result = requests.post(post_url, data=post_data)
print(result.content)