forked from queceo/Pentesting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmdi.py
77 lines (62 loc) · 1.68 KB
/
cmdi.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
#!/usr/bin/env python
import cmd
import scanner
class CMD(cmd.Cmd):
"""Simple command processor example."""
def __init__(self):
cmd.Cmd.__init__(self)
self.prompt = "> "
self.intro = "Welcome to console!" ## defaults to None
#scanner Object
self.SC = scanner.scanner()
#scanner actions
def do_scanner(self, arguments):
args = arguments.split()
if len(args) >= 1:
# add ip with port to database scanlist
# usage: scanner add [ip] [port]
if args[0] == "add":
try:
ipaddress = args[1]
port = args[2]
self.SC.add_scan_ip(ipaddress,port)
except:
print "Usage: scanner add [ip] [port]"
# delete ip with port from database scanlist
# usage: scanner delete [id]
elif args[0] == "delete":
try:
iid = args[1]
self.SC.delete_scan_ip(iid)
except:
print "Usage: scanner delete [id]"
# starts the scan
# usage: scanner start
elif args[0] == "start":
self.SC.ping()
else:
print "Usage: scanner add [ip] [port]"
#show [smt] commands
def do_show(self, arguments):
"""show [smt] to look up """
args = arguments.split()
if len(args) >= 1:
#show scanlist
if (args[0] == "scanlist"):
print "DATABASE scanlist:"
scanIpList = self.SC.get_scan_ip()
for row in scanIpList:
print "ID: ",row[0]," | ip-address: ", row[1], " | port: ",row[2], " | Date: ", row[3]
#show Help
elif (args[0] == "?"):
print "Possible actions:"
print "scanlist: show all ips/ports to scan"
#show nothing
else:
print "Nothing to show for %s" % args[0]
#no arguments
else:
print "Nothing to show"
def do_EOF(self, line):
"""EOF Exit cmd"""
return True