I'm following a book ( Black hat python by Justin Seitz )
I tried exact same code as the book , and attempted to write a code which will establish a TCP connection (see commented bit of the code) relying on socket lib .
but it keeps giving me , an error which says :- Bytes like object is required on line 10 .
not sure what's the problem is with the 2nd bit (uncommented part of the code ) maybe something IP related
I'm aware that the book is using python 2.7 , but I'm using Python 3.9.12 Is the python version causing the problem ?
If so , what is the 3.9.12 equivalent syntax of these codes ?
tnx in advance
import socket
#target_host = "www.google.com"
#target_port = 80
#client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#client.connect((target_host,target_port))
#client.send("GET / HTTP/1.1\r\nHost: google.com\r\n\r\n")
#response = client.recv(4096)
#print(response)
target_host = 127.0.0.1
target_port = 80
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.sendto("AAABBBCCC", (target_host,target_port))
data, addr = client.recvfrom(4096)
print(data)