Acquire Android image using flash drive OTG


Question

In Linux, the dd command is used to pull the image from the smartphone to computer. And of course, the smartphone need to be rooted before the dd command launched.




  1. Is there any specific command or script to be put on the flash drive, to acquire image of Android smartphone and store the acquired image to the flash drive On-The-Go?


  2. How to make it the operation automatically run after the flash drive is inserted? For example: Once I insert the flash drive into Android smartphone, the dd command run automatically and the acquired image stored to flash drive.




Edit : For Forensic purpose, i would like to minimize footprint process such as installing any apps before the flash drive inserted.


Answer


Is there any specific command or script to be put on the flash drive, to acquire image of Android smartphone and store the acquired image to the flash drive On-The-Go?




Nope. No special command or script is needed other than cat or dd, the binaries thankfully Android comes with.



Often, the auto mount point of a flash drive is /mnt/usbotg (may differ for your device), so the command would be



dd if=/dev/block/BLOCK_DEVICE of=/mnt/usbotg/FILENAME.img


Replace BLOCK_DEVICE with the block file's name (the partition you want to copy). It may start with mmcblk.



If required, see How to list all major partitions with their labels?




How to make it the operation automatically run after the flash drive is inserted? For example: Once i insert the flash drive into Android Smartphone, the dd command run automatically and the acquired image stored to flash drive. (sic)




Unless you're planning to inject a BadUSB into the Android device, you would need an app. I found Tasker and Automagic suitable for the job. Both are paid apps with free trial version available on their site.



Tasker



Here is a simple complete profile:




  • Profile: State → Hardware USB Connected → Mass Storage

  • Task: (Actions):




    • Code → Run Shell:




      • Command: dd if=/dev/block/BLOCK_DEVICE of=/mnt/usbotg/FILENAME.img

      • check Use Root





    This should be enough but I prefer to add some glitters here and there. I would wait for 10 seconds after flash drive is mounted before executing the command. I would also give visual indication to myself that Tasker is running the countdown.



    All of this can be done by following this simple procedure:




    • Set a variable to maximum length of countdown (Variables → Variable Set)

    • Wait for 1 second (Task → Wait)

    • Subtract 1 from the remaining of variable (Variables → Variable Subtract)

    • Cancel any Tasker notification (Alert → Notify Cancel)

    • Give visual indication of countdown (Alert → Notify → include variable in Title or Text)

    • Repeat the said steps (exclude variable set) for countdown (Task → Goto → Action Number: 2)

    • Run the command (Code → Run Shell)




This would work. However, the moment you plug your flash drive into your device, Tasker would seek confirmation whether to continue with this flash drive or not. It can remember the device for future correspondence.



Automagic



Automagic would introduce you with a mandatory know-how, so details are not important here. The basic flow would need:




  • Trigger: Storage Media Event; Event: Mounted

  • Action: Execute Root Command → fill the details



Activate the flow and Automagic's service, and test the flow.



There is one major caveat here. There is no differentiation between the type of storage connected, hence, your flow may trigger if you inject SD card too.



Note: Rather than keeping the command inside the apps, you can keep it under a script and place it in your flash drive. Configure your automation app to confirm whether the script exists in the mounted flash drive and if yes, execute it. For confirmation, Tasker already has Read File action. Else, ls "YOUR_SCRIPT" should help.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes