This is asyhttp, a simple module to perform asynchronous HTTP requests using asyncio and aiohttp.
It provides a trivial way to perform a set of async HTTP requests.
- Proxy support
- Custom headers
- Allow redirects
- Use TLS
asyhttp loop() accepts some args
urls
a set of dictionaries, each dict represent an HTTP request.proxy
(str) proxt URL, str (optional).process_out
a user defined function that can be used to process the response of each HTTP request. It will be called by the async function that perform each HTTP request, as soon as the response arrive (optional).redirects
(bool) – If set to True, follow redirects. False by default (optional).verify_tls
(bool) True for check TLS cert validation, False by default (optional).
from asyhttp import loop
requests = [ {'url':'http://exam.ple/page.html', 'method':'GET'},
{'url':'http://exam.ple/page.html', 'method':'POST', 'body' : 'blabla'}
]
loop(urls=requests)
asyhttp loop can be useful to write quick bruteforces against vulnerable systems or as a core for tools like dirfy.
An early version of this code comes from https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html
By default, asyhttp loop print on stdout HTTP status code and reason for each response received. You can override its default behavior writing custom code to process the response your HTTP requests. Your code has to be written in a function and passed to loop as a kwarg called process_out. That function will be called by the async function that perform each of your HTTP requests, as soon as the response arrive.
In your custom code you can process: - url: url of the HTTP request - return_code - reason - resp_body - user_data
pip install asyhttp
from asyhttp import loop
requests = [{'url':'http://exam.ple/page.html', 'method':'GET'}]
loop(urls=requests)
from asyhttp import loop
def process_output(url,return_code,reason,resp_body,user_data):
if return_code == 200:
sys.stdout.write("url")
requests = [{'url':'http://exam.ple/page.html', 'method':'GET'}]
loop(urls=requests,process_out=process_output)
urls
process_out
proxy
verify_tls
redirects
- GET
- POST
- HEAD
{'method':'GET', 'url':'http://exam.ple/page.html'}
{'method':'POST', 'url':'http://exam.ple/page.html','body':'blablabl=balbal'}
{'url':'http://exam.ple/page.html', 'method':'GET', 'headers' : 'X-Custom-Header:YEAH'}
loop(urls=url_dict_list,proxy="http://127.0.0.1:8080")
To add HTTP headers to a request, pass them as a dict.
{'url':'http://exam.ple/page.html', 'method':'GET', 'headers' : {'User-agent':'YEAH'}}
False by default
loop(urls=requests,process_out=process_response,redirects=True)
False by default
loop(urls=requests,process_out=process_response,verify_tls=True)