Web Attackers Documentation
API
APIdiscover
Class to discover API endpoints
Source code in pyhtools\attackers\web\api\discover.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
__init__(base_url, match_codes, rate_limit=20, delay=0.05, output_file_path=None, headers=None)
APIdiscover constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url |
str
|
weburl of API |
required |
match_codes |
list
|
list of integer containing HTTP response status codes, which detects that endpoint exists |
required |
rate_limit |
int
|
number of concurrent requests at the same time |
20
|
delay |
float
|
delay between consecutive requests |
0.05
|
output_file_path |
str
|
file path to store results in json format |
None
|
headers |
dict
|
overrides default headers while sending HTTP requests |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in pyhtools\attackers\web\api\discover.py
check_endpoint(endpoint)
async
checks if endpoint is valid or not using HTTP Get request returns dict containing endpoint information
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint(str) |
api endpoint |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
contains HTTP request and response data |
Source code in pyhtools\attackers\web\api\discover.py
enumerate(endpoints)
async
start API enumeration and return captured responses as list
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoints |
list
|
contains list of endpoints as str |
required |
Returns:
Name | Type | Description |
---|---|---|
results |
list
|
list of results containing dict of |
endpoint information |
Source code in pyhtools\attackers\web\api\discover.py
get_endpoints_from_file(wordlist_path)
async
reads endpoints from wordlist file and returns as a list
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wordlist_path |
str
|
path of wordlist file |
required |
Returns:
Name | Type | Description |
---|---|---|
list | list of str containing endpoints |
Source code in pyhtools\attackers\web\api\discover.py
save_result_to_file(results, file_path)
async
stores json result to file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
path to output file |
required |
results |
list
|
list of HTTP response (dict) |
required |
Returns:
Name | Type | Description |
---|---|---|
bool | returns True if file was saved else False in case |
|
of any exception |
Source code in pyhtools\attackers\web\api\discover.py
start_enum_from_file(wordlist_file)
async
start endpoint enumeration using wordlist
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wordlist_file(str) |
path of wordlist file |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\web\api\discover.py
start_enum_id(ending_id, param_name, starting_id=0)
async
starts enumeration based on id in GET request
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ending_id |
int
|
object id after which enumeration should stop |
required |
param_name |
str
|
GET param |
required |
starting_id |
int
|
object id from which enumeration should start |
0
|
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\web\api\discover.py
Vuln Scanner
Scanner
Scans for vulnerabilities in the website
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
get_forms(url)
extracts all the forms on the url webpage using beautiful soup 4
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
URL of webpage |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of forms (bs4.element.ResultSet) |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
get_links(url)
extracts links from the whole webpage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
URL of the webpage |
required |
Returns:
Name | Type | Description |
---|---|---|
links |
list
|
list of URLs present in the webpage |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
get_page_content(url)
extracts html code of the webpage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
URL of the webpage |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Html content as string |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
get_target_links(url)
extracts useful links and prints them which are only related to the target webpage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
links |
list
|
list of links from the target webpage |
required |
Returns:
Name | Type | Description |
---|---|---|
list | useful links as str related to target webpage |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
is_xss_vulnerable_in_form(form, url)
tests whether the passed form is xss vulnerable or not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
form |
dict
|
webpage form from bs4.element.ResultSet |
required |
url |
str
|
base url of webpage |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
returns True if vulnerable else False |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
is_xss_vulnerable_in_link(url, payload=None)
tests whether the passed url is xss vulnerable or not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
base url of webpage |
required |
payload |
str
|
XSS payload to be injected in URL during test |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool | returns True if vulnerable else False |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
remove_escape_seq(content)
removes \r \t \n from the html parsed content if present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content |
str
|
html page content as string |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
escaped html content without \r \t \n chars |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
run()
Starts the scanner
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
submit_form(form, value, url)
submits form with passed value to url passed
Parameters:
Name | Type | Description | Default |
---|---|---|---|
form |
dict
|
webpage form from bs4.element.ResultSet |
required |
value |
str
|
Form input value to be used while filling form |
required |
url |
str
|
base url of webpage |
required |
Returns:
Name | Type | Description |
---|---|---|
str | html contents of the reponse |
Source code in pyhtools\attackers\web\vuln_scanner\scanner.py
Module: sqli.py Author: dmdhrumilmistry Project: github.com/dmdhrumilmistry/pyhtools License: MIT
enumerate_tests(url)
tests application for various SQL injection methods
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
url of the target |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\web\vuln_scanner\sqli.py
is_url_valid(url)
checks if url is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
url of the target |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
returns True if url is valid else False |
Source code in pyhtools\attackers\web\vuln_scanner\sqli.py
is_vulnerable(url)
tests whether app is vulnerable to the url
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
url of the target |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
returns True if vulnerable else returns False |
Source code in pyhtools\attackers\web\vuln_scanner\sqli.py
get_args()
get arguments from the user and return as dict containing target_url, ignore_links, login_link, and login_details
Returns:
Name | Type | Description |
---|---|---|
dict | user arguments |
Source code in pyhtools\attackers\web\vuln_scanner\__main__.py
Enumerate
Discoverer
Discoverer can be used to enumerate directories and subdomains of target website.
Source code in pyhtools\attackers\web\enumerate.py
check_dirs(domain, wordlist_path, status_codes=[200, 403, 500])
async
enumerate website directories
Parameters:
Name | Type | Description | Default |
---|---|---|---|
domain |
str
|
domain of the target |
required |
wordlist_path |
str
|
path of wordlist file |
required |
status_codes |
list
|
list of integer containing HTTP response |
[200, 403, 500]
|
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\web\enumerate.py
check_subdomains(domain, wordlist_path, status_codes=[200, 403, 500])
async
enumerate website subdomains
Parameters:
Name | Type | Description | Default |
---|---|---|---|
domain |
str
|
domain of the target |
required |
wordlist_path |
str
|
path of wordlist file |
required |
status_codes |
list
|
list of integer containing HTTP response |
[200, 403, 500]
|
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\web\enumerate.py
Get Forms
fuzz_forms(target_url)
get forms from html page, send post request and return html response
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_url |
str
|
webpage URL containing forms |
required |
Returns:
Name | Type | Description |
---|---|---|
str | returns html content of page after sending fuzzed form request |
Source code in pyhtools\attackers\web\get_forms.py
get_page_content(url)
extracts html code of the webpage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
webpage URL |
required |
Returns:
Name | Type | Description |
---|---|---|
str | HTML content of the webpage |
Source code in pyhtools\attackers\web\get_forms.py
remove_escape_seq(content)
removes
from the html parsed content if present.
Args: content (str): html content of webpage
Returns: str: returns escaped html code
Source code in pyhtools\attackers\web\get_forms.py
Login Guesser
bruteforce_login(target_url, wordlist_file, post_values)
Bruteforces login requests on a website
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_url |
str
|
URL of login page |
required |
wordlist_file |
str
|
path of wordlist file |
required |
post_values |
dict
|
dict containing key value pairs of POST data |
required |
Returns:
Type | Description |
---|---|
None |
Source code in pyhtools\attackers\web\login_guesser.py
Spider
Spider
class Spider used to extract links from website's webpage
Source code in pyhtools\attackers\web\spider.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
__init__(rate_limit=100, delay=0.0001, headers=None)
Spider constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rate_limit |
int
|
number of concurrent requests at the same time |
100
|
delay |
float
|
delay between consecutive requests |
0.0001
|
headers |
dict
|
overrides default headers while sending HTTP requests |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in pyhtools\attackers\web\spider.py
get_links(url)
async
extracts links from the whole webpage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
URL of the webpage |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
set
|
list of links present in the webpage |
Source code in pyhtools\attackers\web\spider.py
get_target_links(url, print_link=True)
async
extracts useful links and prints them which are only related to the target webpage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
links |
list
|
list of all links from the target webpage |
required |
Returns:
Name | Type | Description |
---|---|---|
list | returns useful links list related to target webpage |
Source code in pyhtools\attackers\web\spider.py
start(target_url, print_links=True)
async
starts spider
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_url |
str
|
URL of the target website |
required |
print_links |
bool
|
if True prints links found on console |
True
|
Returns:
Name | Type | Description |
---|---|---|
list | list of links found by spider |
Source code in pyhtools\attackers\web\spider.py
Utils
AsyncRLRequests
Bases: AsyncRequests
Send Asynchronous rate limited HTTP requests.
Source code in pyhtools\attackers\web\utils.py
__init__(rate_limit=20, delay=0.05, headers=None)
AsyncRLRequests constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rate_limit |
int
|
number of concurrent requests at the same time |
20
|
delay |
float
|
delay between consecutive requests |
0.05
|
headers |
dict
|
overrides default headers while sending HTTP requests |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in pyhtools\attackers\web\utils.py
request(url, method='GET', session=None, *args, **kwargs)
async
Send HTTP requests asynchronously with rate limit and delay between the requests
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
URL of the webpage/endpoint |
required |
method |
str
|
HTTP methods (default: GET) supports GET, POST, |
'GET'
|
session |
aiohttp.ClientSession
|
aiohttp Client Session for sending requests |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
ClientResponse
|
returns request and response data as dict |
Source code in pyhtools\attackers\web\utils.py
AsyncRequests
AsyncRequests class helps to send HTTP requests.
Source code in pyhtools\attackers\web\utils.py
__init__(headers=None)
AsyncRequests class constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
headers |
dict
|
overrides default headers while sending HTTP requests |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
request(url, method='GET', session=None, *args, **kwargs)
async
Send HTTP requests asynchronously
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
URL of the webpage/endpoint |
required |
method |
str
|
HTTP methods (default: GET) supports GET, POST, |
'GET'
|
session |
aiohttp.ClientSession
|
aiohttp Client Session for sending requests |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
ClientResponse
|
returns request and response data as dict |