码迷,mamicode.com
首页 > 编程语言 > 详细

Python Ethical Hacking - VULNERABILITY SCANNER(1)

时间:2019-10-20 13:20:24      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:util   target   usr   click   ror   asi   http   mic   new   

HTTP REQUESTS

BASIC INFORMATION FLOW

  • The user clicks on a link.
  • HTML website generates a request(client-side)
  • The request is sent to the server.
  • The server performs the requests(server-side)
  • Sends response back.

GET vs POST

Two main methods used to send data to the web application:

1. Through the URL(Usually using GET).

    a. http://webisite.com/news.php?id=1

    b. http://website.com/?id=1

2. Through input elements(Usually using POST).

    a. Search boxes.

    b. Login boxes.

    c. ..etc.

 

Target website:http://10.0.0.45/mutillidae/index.php?page=dns-lookup.php

技术图片

 

 

#!/usr/bin/env python

import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin


def request(url):
    try:
        return requests.get(url)
    except requests.exceptions.ConnectionError:
        pass


target_url = "http://10.0.0.45/mutillidae/index.php?page=dns-lookup.php"
response = request(target_url)

parsed_html = BeautifulSoup(response.content.decode())
forms_list = parsed_html.findAll("form")

for form in forms_list:
    action = form.get("action")
    post_url = 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.decode())

Run the Python Code successfully.

技术图片

 

Python Ethical Hacking - VULNERABILITY SCANNER(1)

标签:util   target   usr   click   ror   asi   http   mic   new   

原文地址:https://www.cnblogs.com/keepmoving1113/p/11707233.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!