Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Friday, September 19, 2014

Flipping the “Production” bit on a Nexus 7

As a security researcher, I’m constantly battling the lack of access on my retail Nexus 7. I spent about 12 hours today messing with this, rooting the device and modifying boot images. Each time, my device would get stuck in a “soft-brick/bootloop’.

It was frustrating.

I followed every step-by-step I could find, continuously modding the setting in build.prop but to no avail. Funny enough – the trick I was using to root and recover my device is what ended up offering a solution!

Root Your Device, For Real

There are a number of roots out there, but none as good as “Nexus Root Toolkit’ by WugFresh. I was a little hesitant, but believe me – if you follow EVERY STEP (esp deleting and installing drivers) it works fantastic.

Run through the wizard. Follow the YouTube videos. A child can do this.

image

But Not Really

However, after you’ve rooted your device, you’re still in “Production” mode and you still can’t get root in shell. To accomplish that, you need to flip the production bit. But, as mentioned, I could never figure out how to flip the bit and then restore the boot image. Whenever I flashed the image back onto the device, it would go into a continuous reboot. At some point, however, I was poking around the Nexus Root Tooklit UI and saw the “Advanced Utilities” option to temporarily boot on an opened image.

I used it a couple times to see what was going on with my device – it would boot on the “modified boot image,” even when it wouldn’t boot on my slightly modified image. And when I adb shell’ed into the device, I had that wonderful root option!

image 

It was only around hour 11.5 that I realized I could have flashed that image (their modified boot image) onto the boot partition, and my device would no longer be in production mode.

So it’s simple…

  • Launch NRT
  • Click “Advanced”
  • Under “Boot Flash Image,” switch the option from “Boot (Temporary)” to “Flash (Permanent)”
    image
  • Select the modified boot image in the \data\modified boot image directory in the NRT install folder
  • Let it flash

Your device is now no longer in production mode – you can mount it as root:

image

Further Research

I’m sure I could simply flip that bit somehow, but I just haven’t figured out how. After a full 12 hours (on top of an 8-hour work day), I decided to just move on. Anyone with better ideas – leave a comment!

Monday, August 25, 2014

Android Application Logs

Learned a great new trick today - using logcat to display Android log meesages to the console window remotely.

Background

Android OS has a log feature (android.util.Logging) which has various levels of verbosity. Developers can send messages to this log. The log isn't written anywhere on the device, it's stored in memory (it is also RIFE with interesting data - such as frequent NMEA GPS location strings).

View the Log over ADB

On a rooted Android, simply enter:

adb logcat >log.txt

and memory-based logs will flow to the log.txt file in your current working directory.