Sitemap
Yen Wang

Yen Wang

Curious mind. Interested in both creative and exploitative sides. More about me | https://www.yenwang.dev/

Python for Cybersecurity 13 — Proxy IV

1 min readSep 12, 2023

--

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.

Press enter or click to view image in full size

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 buffer

2.

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 += data

Read response data into the buffer until there’s no more data or time’s up.

Reference

Source Code

Github Python For Cybersecurity | Monles

--

--