Skip to content

Commit

Permalink
Add tcp-client.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwhale committed Jul 6, 2023
1 parent c919144 commit 928938b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions blackhat-python3/chapter2 - Network Basics/tcp-client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import socket

target_host = "www.google.com"
target_port = 80

# create a socket object
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# connect the client
client.connect((target_host, target_port))

# send some data
request = "GET / HTTP/1.1\r\nHost: {}\r\n\r\n".format(target_host)
client.send(request.encode())

# receive some data
response = client.recv(4096)

print(response.decode())

0 comments on commit 928938b

Please sign in to comment.