This series of tutorials is aimed to share the notes taken while I was learning python for cybersecurity with the books - Black Hat Python.
這系列教學文章為學習筆記+延伸資源,旨在分享學習書籍 Black Hat Python時所思所學,也希望能幫助想了解Python和資安的大大們入門。
This tutorail has also been written in English in Medium.
Let's get started! 開始吧!
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
buffer = b""
建立一個空的字串緩衝,這會積累(accumulate)將從socket得到的回應
connection.settimeout(20)
設一個20秒的timeout,如果你代理交通到其他國家或經過丟失資料的網路(which might be aggressive if you're proxying traffic to other countries or over lossy networks),這可能會有攻擊性,所以增加時間是必要的。
try:
while True:
data = connection.recv(4096)
if not data:
break
buffer += data
閱讀進入緩衝區(buffer)的回應資料,直到再也沒有任何資料或時間到了。
Reference參考資料
推薦影片
絕讚! Youtube 教學影片 | Elevate Cyber
原始碼
Github - Python For Cybersecurity | Monles