mirror of
https://github.com/autistic-symposium/web3-starter-py.git
synced 2025-05-17 14:10:21 -04:00
💾
This commit is contained in:
parent
7cb7a479f6
commit
69bb4175f1
124 changed files with 20 additions and 15 deletions
26
boilerplates/security/python_sockets/netcat_example.py
Normal file
26
boilerplates/security/python_sockets/netcat_example.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import socket
|
||||
|
||||
PORT = 12345
|
||||
HOSTNAME = '54.209.5.48'
|
||||
|
||||
|
||||
def netcat(text_to_send):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect((HOSTNAME, PORT))
|
||||
s.sendall(text_to_send)
|
||||
s.shutdown(socket.SHUT_WR)
|
||||
rec_data = []
|
||||
|
||||
while 1:
|
||||
data = s.recv(1024)
|
||||
if not data:
|
||||
break
|
||||
rec_data.append(data)
|
||||
s.close()
|
||||
return rec_data
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
text_to_send = ''
|
||||
text_recved = netcat( text_to_send)
|
||||
print(text_recved[1])
|
Loading…
Add table
Add a link
Reference in a new issue