8000 Add new functions · CKAndroidProject/adbsploit@9066472 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9066472

Browse files
committed
Add new functions
1 parent 0929a7c commit 9066472

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

.idea/sonarlint/issuestore/d/d/dd3818f11976b0d6d6f65eb2768d8a128a4ffb51

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adbsploit/adbsploit.py

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
>>> python adbsploit.py -help
66
"""
77
import os
8+
import shutil
89
import sys
910
import time
1011
import adbutils
@@ -14,7 +15,7 @@
1415
from rich.table import Table
1516
from colorama import Fore
1617

17-
global_device = "device"
18+
1819

1920

2021
class Utils:
@@ -26,15 +27,17 @@ def banner():
2627

2728

2829
class Cli(object):
30+
gdevice = 'serial'
2931

3032
def devices(self):
3133
Utils.banner()
3234
table = Table()
3335
table.add_column("Device detected", style="cyan")
3436
table.add_column("Model", style="magenta")
3537
table.add_column("Name", style="magenta")
38+
table.add_column("Device", style="magenta")
3639
for d in adbutils.adb.device_list():
37-
table.add_row(d.serial, d.prop.model, d.prop.name)
40+
table.add_row(d.serial, d.prop.model, d.prop.name, d.prop.device)
3841
console = Console()
3942
console.print(table)
4043

@@ -47,6 +50,7 @@ def select(self, device):
4750
Utils.banner()
4851
output = adbutils.adb.device(serial=device)
4952
print("Selected device: " + Fore.GREEN + output.serial)
53+
Cli.gdevice = output.serial
5054

5155
def list_forward(self, device='all'):
5256
Utils.banner()
@@ -286,7 +290,7 @@ def dump_hierarchy(self, device):
286290
def keyevent(self, device, key):
287291
Utils.banner()
288292
d = adbutils.adb.device(device)
289-
k = d.keyevent(key)
293+
d.keyevent(key)
290294
print(Fore.GREEN+"They key event is processed correctly...")
291295

292296
def show_keyevents(self):
@@ -405,17 +409,10 @@ def remove_password(self, device):
405409
d4 = d.shell("su 0 'rm /data/system/locksettings.db-shm'")
406410
print(d4)
407411

408-
#TODO
409-
def rotate(self, device):
410-
Utils.banner()
411-
d = adbutils.adb.device(device)
412-
d.rotation()
413-
414-
#TODO
415-
def swipe(self, device):
412+
def swipe(self, device, sx, sy, ex, ey, duration='0.5'):
416413
Utils.banner()
417414
d = adbutils.adb.device(device)
418-
d.swipe()
415+
d.swipe(sx, sy, ex, ey, duration)
419416

420417
def screen(self, device, status):
421418
Utils.banner()
@@ -427,7 +424,7 @@ def screen(self, device, status):
427424
else:
428425
print(Fore.RED+"That option doesn't exists...")
429426

430-
def unlock_screen(self, device, code):
427+
def unlock_screen(self, device, code=''):
431428
Utils.banner()
432429
d = adbutils.adb.device(device)
433430
if d.is_screen_on() == False:
@@ -439,23 +436,48 @@ def unlock_screen(self, device, code):
439436
else:
440437
print(Fore.GREEN+"The screen is already unlocked...")
441438

442-
def show_mac(self):
439+
def lock_screen(self, device):
443440
Utils.banner()
441+
d = adbutils.adb.device(device)
442+
d.keyevent(26)
443+
print(Fore.GREEN + "The screen is now locked...")
444+
445+
def show_macaddress(self, device):
446+
Utils.banner()
447+
d = adbutils.adb.device(device)
448+
print(Fore.GREEN+d.shell("cat /sys/class/net/wlan0/address"))
444449

445450
def screenrecord(self):
446451
Utils.banner()
447452

453+
#TODO
448454
def stream_screen(self):
449455
Utils.banner()
450456

451-
def screenshot(self):
457+
def screenshot(self, device, name='screenshot'):
452458
Utils.banner()
459+
os.system("adb -s "+device+" exec-out screencap -p >"+name+".png")
460+
print(Fore.GREEN+"An image is created with the name "+name+".png ...")
453461

454-
def get_notifications(self,device):
462+
def dump_meminfo(self, device, app='all'):
455463
Utils.banner()
456464
d = adbutils.adb.device(device)
457-
print(d.shell("dumpsys notification | grep ticker | cut -d= -f2"))
465+
if app == 'all':
466+
d.shell("dumpsys meminfo")
467+
else:
468+
d.shell("dumpsys meminfo "+app)
458469

470+
def process_list(self, device):
471+
Utils.banner()
472+
d = adbutils.adb.device(device)
473+
print(d.shell("ps -ef"))
474+
475+
def tcpip(self, port):
476+
Utils.banner()
477+
if port == '':
478+
print(Fore.RED+"You must specify a port to listen on your device...")
479+
else:
480+
os.system("adb tcpip "+port)
459481

460482
def version(self):
461483
"""Show the version of the tool"""
@@ -468,6 +490,6 @@ def version(self):
468490
console = Console()
469491
console.print(table)
470492

471-
472493
if __name__ == '__main__':
473494
fire.Fire(Cli)
495+

0 commit comments

Comments
 (0)
0