Skip to content

Commit 9b8e5a0

Browse files
committed
add client code
Resolves: Related: Signed-off-by: Daniel Andrei Minca <mandrei17@gmail.com>
1 parent 7c16deb commit 9b8e5a0

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

netcat.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,47 @@ def main():
9090
if listen:
9191
server_loop()
9292

93+
def client_sender(buffer):
94+
95+
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
96+
97+
try:
98+
# connect to target host
99+
client.connect((target, port))
100+
101+
if len(buffer):
102+
client.send(buffer)
103+
104+
while True:
105+
106+
# wait for data back
107+
recv_len = 1
108+
response = ""
109+
110+
while recv_len:
111+
112+
data = client.recv(4096)
113+
recv_len = len(data)
114+
response += data
115+
116+
if recv_len < 4096:
117+
break
118+
119+
print response,
120+
121+
# wait for more input
122+
buffer = raw_input("")
123+
buffer += "\n"
124+
125+
# send it off
126+
client.send(buffer)
127+
128+
except:
129+
130+
print "[*] Exception! Exiting."
131+
132+
# tear down connection
133+
client.close()
134+
93135
main()
94136

0 commit comments

Comments
 (0)