Last active
July 16, 2021 09:35
-
-
Save Und3rf10w/68bc1a458347a87e42465ed97597107e to your computer and use it in GitHub Desktop.
Asyncio tarpits taken from https://nullprogram.com/blog/2019/03/22/
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 random | |
async def handler(_reader, writer): | |
writer.write(b'HTTP/1.1 200 OK\r\n') | |
try: | |
while True: | |
await asyncio.sleep(5) | |
header = random.randint(0, 2**32) | |
value = random.randint(0, 2**32) | |
writer.write(b'X-%x: %x\r\n' % (header, value)) | |
await writer.drain() | |
except ConnectionResetError: | |
pass | |
async def main(): | |
server = await asyncio.start_server(handler, '0.0.0.0', 80) | |
async with server: | |
await server.serve_forever() | |
asyncio.run(main()) |
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 random | |
async def handler(_reader, writer): | |
try: | |
while True: | |
await asyncio.sleep(10) | |
writer.write(b'%x\r\n' % random.randint(0, 2**32)) | |
await writer.drain() | |
except ConnectionResetError: | |
pass | |
async def main(): | |
server = await asyncio.start_server(handler, '0.0.0.0', 22) | |
async with server: | |
await server.serve_forever() | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment