-
Notifications
You must be signed in to change notification settings - Fork 5
/
honeybee.py
executable file
·111 lines (95 loc) · 3.46 KB
/
honeybee.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
111
#!/usr/bin/python2
from multiprocessing import Process, Queue
import nmap
import sys
import subprocess
import kippo
def execute_out(cmd):
Command = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
(out, err) = Command.communicate()
if err:
logger('Error Executing ' + cmd + ' \n' + err)
return out
def scanHost(host='127.0.0.1',ports='22,80',arguments='-sV'):
def singleScan(p,ans, ags):
try:
# print p
nm = nmap.PortScanner()
a = nm.scan(host,p,arguments=ags)
ans.put(a)
#print a
except nmap.PortScannerError as err:
print("Error to connect with " + host + " for port scanning")
print(err)
ans.put('None')
scanRes = Queue()
result = []
for i in ports.split(','):
p = Process(target=singleScan, args=(i,scanRes,arguments,))
p.start()
p.join()
result.append(scanRes.get())
'''
print "----------------------------------------"
print "HOST "+host+ " All Neccassary Information"
print "----------------------------------------"
'''
for i in range(len(result)):
tempres = result[i]
#print tempres
print("-----------------> PORT "+ ports.split(',')[i])
#print "###############Port "+ports.split(',')[i] +" Open/Closed###########"
tstate = str(tempres['scan'][host]['tcp'][int(ports.split(',')[i])]['state'])
#print "TCP Port is "+tstate
if tstate == 'open':
#print "###############Services Running##############"
service = str(tempres['scan'][host]['tcp'][int(ports.split(',')[i])]['product'])
print("SERVICE-INFO by TCP:- "+ service)
if ports.split(',')[i] == '22':
try:
kippo.scan(host)
except:
#print(sys.exc_info()[0])
print()
print("Kippo total honeyscore is " + str(kippo.hs['honeyscore']))
elif ports.split(',')[i] == '21':
h = 0
if 'honeypot' in service:
h = h + 5
print('honeyscore 5 : nmap service scan fingerprinted this honeypot ')
def opscanHost(host='127.0.0.1',arguments='-O'):
try:
nmop = nmap.PortScanner()
return nmop.scan(host,ports=None,arguments=arguments)
except nmap.PortScannerError as err:
print("Error to connect with " + host + " for port scanning")
print(err)
# scanHost(ports='443')
if len(sys.argv) == 1:
ores = opscanHost()
# print(ores)
opname = ores['scan']['127.0.0.1']['osmatch'][0]['name']
# print opname
scanHost()
if len(sys.argv) == 2:
ores = opscanHost(sys.argv[1])
# print ores
opname = ores['scan'][sys.argv[1]]['osmatch'][0]['name']
print(opname)
scanHost(sys.argv[1])
if len(sys.argv) == 3:
ores = opscanHost(sys.argv[1])
opname = ores['scan'][sys.argv[1]]['osmatch'][0]['name']
print(opname)
if sys.argv[2].find('-') != -1:
start = int(sys.argv[2].split('-')[0])
last = int(sys.argv[2].split('-')[1])
l = [str(i) for i in range(start,last+1)]
scanHost(sys.argv[1],','.join(l))
else:
scanHost(sys.argv[1],sys.argv[2])
if len(sys.argv) == 4:
ores = opscanHost(sys.argv[1])
opname = ores['scan'][sys.argv[1]]['osmatch'][0]['name']
#print opname
scanHost(sys.argv[1],sys.argv[2],sys.argv[3])