Adb आमतौर पर स्थित होता है:

bash
#Windows
C:\Users\<username>\AppData\Local\Android\sdk\platform-tools\adb.exe

#MacOS
/Users/<username>/Library/Android/sdk/platform-tools/adb

प्राप्त जानकारी: http://adbshell.com/

कनेक्शन

adb devices

यह जुड़े हुए उपकरणों की सूची बनाएगा; यदि "अनधिकृत" दिखाई देता है, तो इसका मतलब है कि आपको अपने मोबाइल को अनब्लॉक करना होगा और कनेक्शन को स्वीकृत करना होगा।

यह उपकरण को सूचित करता है कि इसे पोर्ट 5555 में adb सर्वर शुरू करना है:

adb tcpip 5555

उस IP और उस पोर्ट से कनेक्ट करें:

adb connect <IP>:<PORT>

यदि आपको वर्चुअल एंड्रॉइड सॉफ़्टवेयर (जैसे Genymotion) में निम्नलिखित त्रुटि मिलती है:

adb server version (41) doesn't match this client (36); killing...

यह इसलिए है क्योंकि आप एक अलग संस्करण के ADB सर्वर से कनेक्ट करने की कोशिश कर रहे हैं। बस उस adb बाइनरी को खोजने की कोशिश करें जिसका सॉफ़्टवेयर उपयोग कर रहा है (जाएँ C:\Program Files\Genymobile\Genymotion और adb.exe के लिए खोजें)

कई उपकरण

जब भी आप अपने मशीन से जुड़े कई उपकरण पाते हैं, तो आपको यह निर्धारित करना होगा कि आप adb कमांड किस पर चलाना चाहते हैं।

bash
adb devices
List of devices attached
10.10.10.247:42135	offline
127.0.0.1:5555	device
bash
adb -s 127.0.0.1:5555 shell
x86_64:/ # whoami
root

पोर्ट टनलिंग

यदि adb पोर्ट केवल लोकलहोस्ट से सुलभ है एंड्रॉइड डिवाइस में लेकिन आपके पास SSH के माध्यम से पहुंच है, तो आप पोर्ट 5555 को फॉरवर्ड कर सकते हैं और adb के माध्यम से कनेक्ट कर सकते हैं:

bash
ssh -i ssh_key username@10.10.10.10 -L 5555:127.0.0.1:5555 -p 2222
adb connect 127.0.0.1:5555

पैकेट प्रबंधक

स्थापित करें/अनइंस्टॉल करें

adb install [option] <path>

bash
adb install test.apk

adb install -l test.apk # forward lock application

adb install -r test.apk # replace existing application

adb install -t test.apk # allow test packages

adb install -s test.apk # install application on sdcard

adb install -d test.apk # allow version code downgrade

adb install -p test.apk # partial application install

adb uninstall [options] <PACKAGE>

bash
adb uninstall com.test.app

adb uninstall -k com.test.app Keep the data and cache directories around after package removal.

पैकेज

सभी पैकेज प्रिंट करता है, वैकल्पिक रूप से केवल उन पैकेजों को जिनका पैकेज नाम <FILTER> में पाठ शामिल है।

adb shell pm list packages [options] <FILTER-STR>

bash
adb shell pm list packages <FILTER-STR>

adb shell pm list packages -f <FILTER-STR> #See their associated file.

adb shell pm list packages -d <FILTER-STR> #Filter to only show disabled packages.

adb shell pm list packages -e <FILTER-STR> #Filter to only show enabled packages.

adb shell pm list packages -s <FILTER-STR> #Filter to only show system packages.

adb shell pm list packages -3 <FILTER-STR> #Filter to only show third party packages.

adb shell pm list packages -i <FILTER-STR> #See the installer for the packages.

adb shell pm list packages -u <FILTER-STR> #Also include uninstalled packages.

adb shell pm list packages --user <USER_ID> <FILTER-STR> #The user space to query.

adb shell pm path <PACKAGE>

दिए गए APK का पथ प्रिंट करें।

bash
adb shell pm path com.android.phone

adb shell pm clear <PACKAGE>

किसी पैकेज से संबंधित सभी डेटा को हटा दें।

bash
adb shell pm clear com.test.abc

फ़ाइल प्रबंधक

adb pull <remote> [local]

एक निर्दिष्ट फ़ाइल को एक एमुलेटर/डिवाइस से आपके कंप्यूटर पर डाउनलोड करें।

bash
adb pull /sdcard/demo.mp4 ./

adb push <local> <remote>

अपने कंप्यूटर से एक निर्दिष्ट फ़ाइल को एक एमुलेटर/डिवाइस पर अपलोड करें।

bash
adb push test.apk /sdcard

Screencapture/Screenrecord

adb shell screencap <filename>

डिवाइस डिस्प्ले का स्क्रीनशॉट लेना।

bash
adb shell screencap /sdcard/screen.png

adb shell screenrecord [options] <filename>

Android 4.4 (API स्तर 19) और उच्चतर चलाने वाले उपकरणों की डिस्प्ले रिकॉर्डिंग।

bash
adb shell screenrecord /sdcard/demo.mp4
adb shell screenrecord --size <WIDTHxHEIGHT>
adb shell screenrecord --bit-rate <RATE>
adb shell screenrecord --time-limit <TIME> #Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).
adb shell screenrecord --rotate # Rotates 90 degrees
adb shell screenrecord --verbose

(रिकॉर्डिंग रोकने के लिए Ctrl-C दबाएँ)

**आप फ़ाइलें (छवियाँ और वीडियो) adb pull का उपयोग करके डाउनलोड कर सकते हैं

शेल

adb शेल

डिवाइस के अंदर एक शेल प्राप्त करें

bash
adb shell

adb shell <CMD>

डिवाइस के अंदर एक कमांड निष्पादित करें

bash
adb shell ls

pm

निम्नलिखित कमांड एक शेल के अंदर निष्पादित होते हैं

bash
pm list packages #List installed packages
pm path <package name> #Get the path to the apk file of tha package
am start [<options>] #Start an activity. Whiout options you can see the help menu
am startservice [<options>] #Start a service. Whiout options you can see the help menu
am broadcast [<options>] #Send a broadcast. Whiout options you can see the help menu
input [text|keyevent] #Send keystrokes to device

Processes

यदि आप अपने एप्लिकेशन की प्रक्रिया का PID प्राप्त करना चाहते हैं, तो आप निष्पादित कर सकते हैं:

bash
adb shell ps

और अपने एप्लिकेशन के लिए खोजें

या आप कर सकते हैं

bash
adb shell pidof com.your.application

और यह एप्लिकेशन का PID प्रिंट करेगा

सिस्टम

bash
adb root

रूट अनुमतियों के साथ adbd डेमन को पुनः प्रारंभ करता है। फिर, आपको ADB सर्वर से फिर से कनेक्ट करना होगा और आप रूट होंगे (यदि उपलब्ध हो)।

bash
adb sideload <update.zip>

फ्लैशिंग/पुनर्स्थापना Android update.zip पैकेज।

लॉग

लॉगकैट

केवल एक एप्लिकेशन के संदेशों को फ़िल्टर करने के लिए, एप्लिकेशन का PID प्राप्त करें और लॉगकैट के आउटपुट को फ़िल्टर करने के लिए grep (linux/macos) या findstr (windows) का उपयोग करें:

bash
adb logcat | grep 4526
adb logcat | findstr 4526

adb logcat [option] [filter-specs]

bash
adb logcat

नोट्स: मॉनिटर को रोकने के लिए Ctrl-C दबाएँ

bash
adb logcat *:V # lowest priority, filter to only show Verbose level

adb logcat *:D # filter to only show Debug level

adb logcat *:I # filter to only show Info level

adb logcat *:W # filter to only show Warning level

adb logcat *:E # filter to only show Error level

adb logcat *:F # filter to only show Fatal level

adb logcat *:S # Silent, highest priority, on which nothing is ever printed

adb logcat -b <Buffer>

bash
adb logcat -b # radio View the buffer that contains radio/telephony related messages.

adb logcat -b # event View the buffer containing events-related messages.

adb logcat -b # main default

adb logcat -c # Clears the entire log and exits.

adb logcat -d # Dumps the log to the screen and exits.

adb logcat -f test.logs # Writes log message output to test.logs .

adb logcat -g # Prints the size of the specified log buffer and exits.

adb logcat -n <count> # Sets the maximum number of rotated logs to <count>.

dumpsys

सिस्टम डेटा को डंप करें

adb shell dumpsys [options]

bash
adb shell dumpsys

adb shell dumpsys meminfo

adb shell dumpsys battery

नोट्स: एक मोबाइल डिवाइस जिसमें डेवलपर विकल्प सक्षम हैं, Android 5.0 या उच्चतर पर चल रहा है।

bash
adb shell dumpsys batterystats collects battery data from your device

नोट्स: Battery Historian उस डेटा को HTML दृश्य में परिवर्तित करता है। STEP 1 adb shell dumpsys batterystats > batterystats.txt STEP 2 python historian.py batterystats.txt > batterystats.html

bash
adb shell dumpsys batterystats --reset erases old collection data

adb shell dumpsys activity

बैकअप

adb से एक एंड्रॉइड डिवाइस का बैकअप लें।

bash
adb backup [-apk] [-shared] [-system] [-all] -f file.backup
# -apk -- Include APK from Third partie's applications
# -shared -- Include removable storage
# -system -- Include system Applciations
# -all -- Include all the applications

adb shell pm list packages -f -3      #List packages
adb backup -f myapp_backup.ab -apk com.myapp # backup on one device
adb restore myapp_backup.ab                  # restore to the same or any other device

यदि आप बैकअप की सामग्री की जांच करना चाहते हैं:

bash
( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 myapp_backup.ab ) |  tar xfvz -

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)

HackTricks का समर्थन करें