custom command check
This commit is contained in:
1 parent
e3d1dbbbf1
commit
4ccec278bf
3 files changed
+7
-39
No files matched your search
+5
-4
@@ -1,4 +1,4 @@
|
||||
# client.py
|
||||
#!/usr/bin/env python3
|
||||
import socket
|
||||
|
||||
PORT = 5055
|
||||
@@ -15,14 +15,14 @@ ALL_IPS = [
|
||||
"172.22.156.6"
|
||||
]
|
||||
|
||||
def grep_all_ips(ips):
|
||||
def grep_all_ips(ips, cmd):
|
||||
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())
|
||||
client_socket.sendall(cmd.encode())
|
||||
data = client_socket.recv(65536)
|
||||
print("Received:", data.decode())
|
||||
except Exception as e:
|
||||
@@ -30,4 +30,5 @@ def grep_all_ips(ips):
|
||||
finally:
|
||||
client_socket.close()
|
||||
|
||||
grep_all_ips(ALL_IPS)
|
||||
cmd = input("Enter the command to execute on all servers: ")
|
||||
grep_all_ips(ALL_IPS, cmd)
|
||||
Reference in new issue
Block a user