2

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.

  • Thanks @TamoghnaChowdhury. I already check that information but there's no automation after i put the flash drive into smartphone. – Myka Z Dec 10 '15 at 12:59
  • @TamoghnaChowdhury lol. Dont worry. Your words always helping me. Thanks again. Maybe you will give me an idea for the automation after this? ;) – Myka Z Dec 10 '15 at 13:03
  • Whoa. For doing that without any apps, you would have to use kernel interrupts or modify core system mount scripts to run said command on USB insertion, and that would go way out of scope on this site. You could try Unix and Linux Stack Exchange of SuperUser – Tamoghna Chowdhury Dec 10 '15 at 13:07
  • Whoa. I didnt expect this idea would go deeply on kernel modification. Thanks for suggestion. – Myka Z Dec 10 '15 at 13:30
4

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.

  • 1
    Thanks a lot, Firelord! I would say the answer for the first question is really makes me smile. I already try the dd command from my phone and it works! Just need a little bit modification on command for my phone : dd if=/dev/block/mmcblk0 of=/storage/usbdisk/file_name.img . Is there any other solution or custom script to be write for automation instead of installing these apps? Because of Forensic purpose, i would like to minimize footprint process of acquired image. About the BadUSB, is it possible to do the automation just like the BadUSB? Thanks in advance! :) – Myka Z Dec 10 '15 at 12:56
  • That I'm afraid is not possible without exploiting the underlying OS. Information Security may help you in that case. – Firelord Dec 10 '15 at 13:02
  • From your answer on adding some glitters here and there, how i can set all those variables? Because i dont see any button to set those variables on my Tasker. – Myka Z Dec 30 '15 at 17:00
  • The Variables tab is not shown if Menu / Prefs / UI / Beginner Mode is enabled. Disable that mode and try. If still doesn't work, then post a screenshot. – Firelord Dec 30 '15 at 17:10
  • Done. postimg.org/image/563zi743z Now, how to put those variables on Tasker? – Myka Z Dec 31 '15 at 2:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.