-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Miguel Sanchez
committed
Feb 26, 2023
1 parent
9c47d72
commit 2304a8a
Showing
8 changed files
with
210 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,43 @@ | ||
from colorama import Fore | ||
import threading | ||
import socket | ||
from modules import urltoip | ||
import ipaddress | ||
import socket | ||
import threading | ||
|
||
ports = [80, 8080, 443] | ||
open_ports = [] | ||
closed_ports = [] | ||
start_port = 1 | ||
end_port = 65000 | ||
|
||
def portscanner(domain: str): | ||
ip = urltoip.get_ip(domain) | ||
open_ports = [] | ||
# specify the range of ports to scan | ||
|
||
# define a function to scan a single port and print the service banner | ||
def scan_port(port): | ||
try: | ||
for port in ports: | ||
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
data = sck.connect_ex((ip, port)) | ||
if data == 0: | ||
open_ports.append(f"{port}") | ||
sck.close() | ||
else: | ||
pass | ||
print(f"{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} PORTS: {Fore.GREEN}{', '.join(map(str,open_ports))}") | ||
except socket.error: | ||
print (Fore.RED + "Could not connect to host") | ||
pass | ||
except KeyboardInterrupt: | ||
print ("You pressed CTRL+C") | ||
except ipaddress.AddressValueError: | ||
print ("IP address not allowed") | ||
except TypeError: | ||
# create a TCP socket and attempt to connect to the specified port | ||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
sock.settimeout(1) | ||
result = sock.connect_ex((ip_address, port)) | ||
|
||
# if the connection is successful, attempt to receive the service banner | ||
if result == 0: | ||
open_ports.append(f"{port}") | ||
print(f"{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} PORTS: {Fore.GREEN}{', '.join(map(str,open_ports))}") | ||
|
||
# close the socket | ||
sock.close() | ||
except: | ||
pass | ||
|
||
if __name__=="__main__": | ||
t1 = threading.Thread(target=portscanner, args=(ports,)) | ||
t1.start() | ||
# create a list of threads to scan each port in the range | ||
def main(domain: str): | ||
global ip_address | ||
ip_address = urltoip.get_ip(domain) | ||
threads = [] | ||
for port in range(start_port, end_port + 1): | ||
thread = threading.Thread(target=scan_port, args=(port,)) | ||
threads.append(thread) | ||
thread.start() | ||
|
||
# wait for all threads to complete | ||
for thread in threads: | ||
thread.join() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import requests | ||
import re | ||
from bs4 import BeautifulSoup | ||
|
||
def apache_version(): | ||
url = 'https://httpd.apache.org/download.cgi' | ||
|
||
response = requests.get(url) | ||
soup = BeautifulSoup(response.text, 'html.parser') | ||
version = soup.find("h1", attrs={'id':'apache24'}).get_text() | ||
version_number = re.search(r'([\d.]+)', version).group(1) | ||
return version_number | ||
|
||
def nginx_version(): | ||
url = 'https://nginx.org/en/download.html' | ||
|
||
response = requests.get(url) | ||
soup = BeautifulSoup(response.text, 'html.parser') | ||
version = soup.find('a', attrs={'href':'/download/nginx-1.22.1.tar.gz'}).get_text() | ||
version_number = re.search(r'([\d.]+)', version).group(1) | ||
return version_number |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from colorama import Fore | ||
import requests | ||
import re | ||
import threading | ||
import sys | ||
|
||
# specify the URL to test | ||
url = sys.argv[1] | ||
|
||
# create a list of domains to test for SSRF | ||
domains = ["localhost", "127.0.0.1", "0.0.0.0", "localhost.localdomain", "localhost6.localdomain6", "0:0:0:0:0:0:0:1"] | ||
|
||
# define a function to check a single parameter for SSRF | ||
def check_parameter(parameter): | ||
for domain in domains: | ||
try: | ||
# send a GET request with the current domain in the parameter | ||
response = requests.get(url.replace(parameter, domain)) | ||
|
||
# check the response for signs of successful SSRF exploitation | ||
if re.search(r"connection refused|network is unreachable", response.text, re.IGNORECASE): | ||
print(f'{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} SSRF Found in: {Fore.MAGENTA}{parameter}') | ||
break | ||
except: | ||
# handle any exceptions that occur during the request | ||
pass | ||
|
||
# send a GET request to the URL and extract all parameters | ||
response = requests.get(url) | ||
parameters = re.findall(r"\?(\w+)=", response.text) | ||
|
||
# create a list of threads to check each parameter for SSRF | ||
if __name__ == "__main__": | ||
threads = [] | ||
for parameter in parameters: | ||
thread = threading.Thread(target=check_parameter, args=(parameter,)) | ||
threads.append(thread) | ||
thread.start() | ||
|
||
# wait for all threads to complete | ||
for thread in threads: | ||
thread.join() | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from bs4 import BeautifulSoup | ||
from colorama import Fore | ||
import requests | ||
import urllib.parse | ||
import re | ||
|
||
payloads = [ | ||
"<script>alert('XSS')</script>", | ||
"<img src=x onerror=alert('XSS')>", | ||
"<svg onload=alert('XSS')>", | ||
"javascript:alert('XSS')", | ||
"data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4=" | ||
] | ||
|
||
def xss_scan(domain: str) -> str: | ||
# send a GET request to the URL | ||
response = requests.get(domain) | ||
|
||
# parse the HTML content using BeautifulSoup | ||
soup = BeautifulSoup(response.content, "html.parser") | ||
|
||
# find all input fields in the form tag with user input options | ||
input_fields = soup.find_all("input", {"type": ["text", "password", "email", "number", "search", "user"]}) | ||
|
||
# iterate through the input fields and send an XSS payload to each field | ||
parsed_payloads = [] | ||
for field in input_fields: | ||
# create a sample XSS payloads | ||
|
||
# set the value of the current input field to the XSS payload | ||
for payload in payloads: | ||
encoded_payload = urllib.parse.quote_plus(payload) | ||
field["value"] = payload | ||
|
||
# submit the form data using a POST request | ||
form_data = {} | ||
for form_field in soup.find_all("input"): | ||
form_data[form_field.get("name")] = form_field.get("value") | ||
response = requests.post(domain, data=form_data) | ||
|
||
# check the response for signs of successful XSS exploitation | ||
if payload in response.text: | ||
print(f'{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} XSS FOUND: {Fore.MAGENTA}{field.get("name")}') | ||
|
||
#if the XSS exploitation was not successful, URL encode the payload and try again | ||
field["value"] = encoded_payload | ||
form_data[field.get("name")] = encoded_payload | ||
response = requests.post(domain, data=form_data) | ||
|
||
if encoded_payload in response.text: | ||
print(f'{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} XSS FOUND: {Fore.MAGENTA}{field.get("name")}') | ||
|
||
scripts = soup.find_all("script") | ||
# Iterate over all script tags | ||
for script in scripts: | ||
if re.search(r"(location|document|window)\.(hash|search|referrer|pathname|name|title|cookie|getElementById|getElementsByClassName|getElementsByTagName|write|writeln|innerHTML|outerHTML|setAttribute|getAttribute)\(", str(script)): | ||
print(f'{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} Potential DOM XSS: {Fore.MAGENTA}{str(script)}') |