33 lines
796 B
Python
33 lines
796 B
Python
# client.py
|
|
import socket
|
|
|
|
PORT = 5055
|
|
ALL_IPS = [
|
|
"172.22.156.3",
|
|
"172.22.158.2",
|
|
"172.22.94.2",
|
|
"172.22.156.4",
|
|
"172.22.158.3",
|
|
"172.22.94.3",
|
|
"172.22.156.5",
|
|
"172.22.158.4",
|
|
"172.22.94.4",
|
|
"172.22.156.6"
|
|
]
|
|
|
|
def grep_all_ips(ips):
|
|
for ip in ips:
|
|
try:
|
|
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
client_socket.connect((ip, PORT))
|
|
print(f"Connected to server at {ip}:{PORT}")
|
|
|
|
client_socket.sendall("ls -la".encode())
|
|
data = client_socket.recv(65536)
|
|
print("Received:", data.decode())
|
|
except Exception as e:
|
|
print(f"Failed to connect to {ip}:{PORT} - {e}")
|
|
finally:
|
|
client_socket.close()
|
|
|
|
grep_all_ips(ALL_IPS) |