-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlookingInterface.py
executable file
·111 lines (93 loc) · 2.77 KB
/
lookingInterface.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import paramiko
import cmd
import sys
import time
import os
"""
After 7 years I will make better this code
now in use for devnet basic training and
python understanding
"""
def conexion(ip):
hostname = raw_input("Enter the hostname\n")
que = raw_input("Please Enter Interface that you are looking for \n")
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, username='test', password='test', allow_agent=False, look_for_keys=False)
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
chan = ssh.invoke_shell()
print clock(chan, hostname)
print lookInt(chan, hostname, que)
print description(chan, hostname, que)
log = raw_input("Do you want to print the logs.... y/n \n").lower()
if log == 'y':
print logs(chan, hostname, que)
print u"\x1b[0m"
print main()
else:
print u"\x1b[0m"
print main()
def clock(chan, hostname):
hostname = hostname + '#'
chan.send('show clock')
chan.send('\n')
time.sleep(1)
clock = chan.recv(9999)
if clock != hostname:
return clock.strip(hostname)
def lookInt(chan, hostname, interface):
hostname = hostname + "#"
chan.send('sh int ' + interface)
chan.send('\n')
chan.send(u"\u0020")
time.sleep(1)
clock = chan.recv(9999)
if clock != hostname:
return clock.strip(hostname)
def description(chan, hostname, interface):
hostname = hostname + "#"
chan.send('sh int ' + interface + ' description')
chan.send('\n')
time.sleep(1)
clock = chan.recv(9999)
if clock != hostname:
return clock.strip(hostname)
def logs(chan, hostname, interface):
hostname = hostname + "#"
chan.send('sh log | include ' + interface)
chan.send('\n')
time.sleep(1)
clock = chan.recv(9999)
if clock != hostname:
return clock.strip(hostname)
print ("############################################")
print ("# osisecurite.com #")
print ("# by chapo182 #")
print ("# #")
print ("############################################\n")
def main():
protocolo = raw_input("Choose Protocol ssh/telnet\n").lower()
if protocolo == "ssh" and len(protocolo) == 3:
ip = raw_input("Please Enter the IP Address \n")
test = os.system('ping ' '-c 5 -W 1 '+ str(ip) + ' > /dev/null')
if not test:
print u"\033[92m [+] Device Reachable"
conexion(ip)
else:
print u"\033[91m [-] Device Unreachable"
print "[*] Re enter the information"
print u"\x1b[0m"
main()
elif protocolo == "telnet" and len(protocolo) == 6:
ip = raw_input("Please Enter the IP Address \n")
test = os.system('ping ' '-c 5 -W 1 '+ str(ip) + ' > /dev/null')
if not test:
print u"\033[92m [+] Device Reachable........"
conexion(ip)
else:
print "[-] Device Unreachable"
main()
else:
main()
if __name__ == "__main__":
main()