Python for Cybersecurity 13 — Proxy IV
Sharpen Python skills in the field of cybersecurity.
Get Yen Wang’s stories in your inbox
Join Medium for free to get updates from this writer.
This series of tutorials is mainly to share the notes taken while I was learning python for cybersecurity with the books — Black Hat Python.
There are some links in the section of References below.
Catalogue
- Proxy IV
Proxy IV
1.
def receive_from(connection):
buffer = b""
connection.settimeout(20)
try:
while True:
data = connection.recv(4096)
if not data:
break
buffer += data
except Exception as e:
print('error ', e)
pass
return buffer2.
buffer = b""Create an empty string buffer , that will accumulate responses from the socket.
3.
connection.settimeout(20)Set a twenty-second time-out, which might be aggressive if you’re proxying traffic to other countries or over lossy networks, so increase the time-out as necessary.
4.
try:
while True:
data = connection.recv(4096)
if not data:
break
buffer += dataRead response data into the buffer until there’s no more data or time’s up.
Reference
- Black Hat Python, 2nd Edition: Python Programming for Hackers and Pentesters | Amazon e-book
- Awesome Youtube Tutorial | Elevate Cyber
- Awesome Github source codes | Selfmade
Source Code
Github Python For Cybersecurity | Monles









