Using the implementation of a hacking tool, we show how to parallelize input and output with Python so that I/O operations deliver results quickly.
reading time:
13 Min.
In Pocket save on computer
No matter how fast CPUs and I/O interfaces can be, if the software doesn’t play along, expensive resources are wasted. Asynchronous I/O operations can help. This means that a computer no longer has to stand by and wait until it finally receives the answer to a request from a web service, for example. In the meantime, he can do other things, such as sending more requests.
One tool that would benefit from asynchronous processing is the C-written web content scanner Dirb (Dir Buster), popular with hackers. It’s unleashed on a web server to find out which URLs it’s responding to. To do this, Dirb is given dictionaries from which it assembles URLs and requests them one after the other.
The crux of the matter lies in the word “one after the other”, because Dirb only sends the next request when the answer to the previous one has arrived. In the round-trip time from the request to the response (RTT), the program twiddles its thumbs – and with it the hacker. In Python, it would look something like this: