python编写一个xss漏洞扫描器扫描网页url是否存在xss漏洞代码
代码语言:python
所属分类:web系统
代码描述:python编写一个xss漏洞扫描器扫描网页url是否存在xss漏洞代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
#!/usr/local/python3/bin/python3 # -*- coding: utf-8 -* import requests from pprint import pprint from bs4 import BeautifulSoup as bs from urllib.parse import urljoin def get_all_forms(url): """获取url网页中的所有form表单""" soup = bs(requests.get(url).content, "html.parser") return soup.find_all("form") def get_form_details(form): """ 获取form表单的详细信息,如post method action等 """ details = {} # get the form action (target url) action = form.attrs.get("action").lower() # get the form method (POST, GET, etc.) method = form.attrs.get("method", "get").lower() # get all the input details such as type and name inputs = [] for input_tag in form.find_all("input"): input_type = input_tag.attrs.get("type", "text") input_name = input_tag.attrs.get("name") inputs.append({"type": input_type, "name": input_name}) # put everything to the resulting dictionary details["action"] = action details["method"] = method details["inputs"] = inputs return details def submit_form(form_details, url, value): """ 模拟提交表单 Params: form_details (list): a dictionary that contain form information url (str): the original URL that contain that form value (str): this will be replaced to all text and search inputs Returns the HTTP Response after form submission """ # construct the full URL (if the url provided in action is relative) target_url = urljoin(url, form_details["action"]) # get the inputs inputs = form_details["inputs".........完整代码请登录后点击上方下载按钮下载查看
网友评论0