forked from j5oh/synackAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getHydra.py
executable file
·46 lines (43 loc) · 1.83 KB
/
getHydra.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
#!/usr/bin/env python3
from synack import synack
import os
import sys
def hydraOutput(codename):
jsonResponse = s1.getHydra(codename)
hydraOut = list()
for i in range(len(jsonResponse)):
keys = list(jsonResponse[i]['ports'].keys())
for j in range(len(keys)):
portKeys = list(jsonResponse[i]['ports'][keys[j]])
for k in range(len(portKeys)):
if len(jsonResponse[i]['ports'][keys[j]][portKeys[k]]) > 0:
if "synack" in jsonResponse[i]['ports'][keys[j]][portKeys[k]]:
if "cpe" in jsonResponse[i]['ports'][keys[j]][portKeys[k]]['synack']:
if "parsed" in jsonResponse[i]['ports'][keys[j]][portKeys[k]]['synack']['cpe']:
if jsonResponse[i]['ports'][keys[j]][portKeys[k]]['synack']['cpe']['parsed'] != "":
hydraOut.append(jsonResponse[i]['ip']+","+keys[j]+","+portKeys[k]+","+jsonResponse[i]['ports'][keys[j]][portKeys[k]]['synack']['cpe']['parsed'])
else:
hydraOut.append(jsonResponse[i]['ip']+","+keys[j]+","+portKeys[k]+",''")
return hydraOut
s1 = synack()
s1.gecko = False
s1.getSessionToken()
s1.getAllTargets()
args = len(sys.argv)
if args == 2:
codename = str(sys.argv[1].lower())
output = hydraOutput(codename)
with open("hydra.out", 'a') as out:
out.write('\n'.join(output))
if args > 2:
sys.exit()
if args == 1:
codenames = s1.getCodenames("host")
for codename in codenames:
print(codename)
targetPath = "./"+codename.upper()+"/"
if os.path.isdir(targetPath) == False:
os.mkdir(targetPath)
output = hydraOutput(codename)
with open(targetPath+"hydra.txt", 'a') as out:
out.write('\n'.join(output))