Created
July 14, 2019 22:07
-
-
Save ZeroX-DG/ae77a2a6a27748a46d7efd1b45e7155f to your computer and use it in GitHub Desktop.
Detect login forms
This file contains 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 | |
from lxml import html | |
input_rules = { | |
"type=password": 10, | |
"name=username": 10, | |
"name=password": 10, | |
"id=username": 10, | |
"id=password": 10, | |
"type=email": 5, | |
"type=text": 3, | |
"type=checkbox": 2, | |
"type=radio": 1 | |
} | |
def score_form(form): | |
score = 0 | |
for key in input_rules.keys(): | |
[attr, value] = key.split("=") | |
for input_control in form.inputs: | |
if attr in input_control.attrib: | |
if input_control.attrib[attr] == value: | |
score += input_rules[key] | |
return score | |
def start(url): | |
r = requests.get(url) | |
doc = html.document_fromstring(r.text, base_url=url) | |
forms = doc.xpath('//form') | |
possible_forms = [] | |
for form in forms: | |
score = score_form(form) | |
if score > 0: | |
possible_forms.append(form) | |
for form in possible_forms: | |
print(form.attrib) | |
start("http://www.chuabaidinhninhbinh.vn:2082/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment