ADB Commands

जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert)!

दूसरे तरीके HackTricks का समर्थन करने के लिए:

Adb सामान्यत: में स्थित होता है:

#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 कमांड चलाना है, उसे निर्दिष्ट करना होगा

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

पोर्ट टनलिंग

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

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 [विकल्प] <पथ>

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 [विकल्प] <पैकेज>

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>

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 का पथ प्रिंट करें।

adb shell pm path com.android.phone

adb shell pm clear <PACKAGE>

एक पैकेज के साथ जुड़ी सभी डेटा को हटा देता है।

adb shell pm clear com.test.abc

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

adb pull <remote> [local]

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

adb pull /sdcard/demo.mp4 ./

adb push <local> <remote>

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

adb push test.apk /sdcard

स्क्रीनकैप्चर/स्क्रीनरिकॉर्ड

adb shell screencap <फ़ाइलनाम>

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

adb shell screencap /sdcard/screen.png

adb shell screenrecord [options] <filename>

उन उपकरणों की डिस्प्ले रिकॉर्ड करें जो Android 4.4 (API स्तर 19) और उससे ऊपर चल रहे हैं।

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

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

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

शैल

adb shell

उपकरण के अंदर एक शैल प्राप्त करें

adb shell

adb shell <CMD>

उपकरण के अंदर एक कमांड को चलाएं

adb shell ls

pm

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

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

प्रक्रियाएँ

यदि आप अपने एप्लिकेशन की प्रक्रिया का पीआईडी प्राप्त करना चाहते हैं तो आप निम्नलिखित को क्रियान्वित कर सकते हैं:

adb shell ps

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

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

adb shell pidof com.your.application

और यह एप्लिकेशन का पीआईडी प्रिंट करेगा

सिस्टम

adb root

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

adb sideload <update.zip>

लॉग

लॉगकैट

केवल एक एप्लिकेशन के संदेशों को फ़िल्टर करने के लिए, एप्लिकेशन का पीआईडी प्राप्त करें और लॉगकैट के आउटपुट को फ़िल्टर करने के लिए grep (लिनक्स/मैकओएस) या findstr (विंडोज) का उपयोग करें:

adb logcat | grep 4526
adb logcat | findstr 4526

adb logcat [विकल्प] [फ़िल्टर-स्पेसिफिकेशन]

adb logcat

टिप्पणी: मॉनिटरिंग रोकने के लिए Ctrl-C दबाएं

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>

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 [विकल्प]

adb shell dumpsys

adb shell dumpsys meminfo

adb shell dumpsys battery

ADB Commands

Android Debug Bridge (ADB) is a versatile command-line tool that lets you communicate with a device. Here are some useful ADB commands for Android app pentesting:

  1. Check connected devices:

    adb devices
  2. Install an APK:

    adb install app.apk
  3. Uninstall an app:

    adb uninstall package_name
  4. Grant permissions:

    adb shell pm grant package_name permission
  5. Revoke permissions:

    adb shell pm revoke package_name permission
  6. Start an activity:

    adb shell am start -n package_name/activity_name
  7. Pull a file from the device:

    adb pull /path/to/file
  8. Push a file to the device:

    adb push file /path/on/device
  9. Capture a bug report:

    adb bugreport bugreport.zip
  10. Access the device shell:

    adb shell

Make sure to have a mobile device with Developer Options enabled running Android 5.0 or higher.

adb shell dumpsys batterystats collects battery data from your device

Notes: बैटरी इतिहासकार उस डेटा को एक HTML दृश्यीकरण में रूपांतरित करता है। चरण 1 adb shell dumpsys batterystats > batterystats.txt चरण 2 python historian.py batterystats.txt > batterystats.html

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

# बैकअप

एडीबी से एंड्रॉइड डिवाइस का बैकअप।
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

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

( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 myapp_backup.ab ) |  tar xfvz -
जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert)!

दूसरे तरीके HackTricks का समर्थन करने के लिए:

Last updated