Sunday, April 21, 2013

Root, Backup Apps+Data and Install Cyanogenmod 7 Gingerbread on G2/Vision Phone

Root, Backup Apps+Data and Install Cyanogenmod 7 Gingerbread on G2/Vision Phone

This post explains about rooting a Tmobile G2/HTC Vision and then installing Cyanogenmod 7 (Gingerbread) while retaining the apps and data that were in use with stock ROM. Entire process from rooting till installation of Cyanogenmod should not take more than half an hour.

Root Your G2

  1. Install Terminal Emulator and a file manager (such as Astro File Manager) from the Market.
  2. Extract the contents of the zip file (Download from XDA site / here) to the SD card (this will create a directory called root_files on the card). When done, make sure you unmount your SD card from your computer if you had mounted it as a storage device to transfer the files.
  3. Enable Unknown Sources (under Settings->Applications) and USB Debugging (under Settings->Applications->Development).
  4. Using your file manager, navigate to the root_files directory on your SD card and select “com.modaco.visionaryplus.r14.apk” to install the Visionary app.
  5. Start the Visionary app and click on “Temproot now.” Leave all other settings unchecked.
  6. Start the Terminal app and type the following commands (the $ and # symbols represent the command prompt and should not be typed):
$ su
# cp /sdcard/root_files/perm_root /data/local/perm_root
# chmod 777 /data/local/*
# /data/local/perm_root
Select Temproot now in Visionary
Select Temproot now in Visionary
Temp Root in progress via Visionary Plus
Temp Root in progress via Visionary Plus
Perm Root commands
Perm Root commands
Perm Root execution in progress
Perm Root execution in progress
You will see multiple messages scroll by as the programs run. Once you are returned to the prompt in terminal, you will have permanent root (S-OFF), as well as subsidy unlock and SuperCID.

Steps to Backup Installed Apps + Data to SD card (using Titanium Backup)

  1. Install Titanium Backup from Market (free version would do the job, though it will take only one version of backup).
  2. Make sure the latest / good version of BusyBox is installed (hit the “Problems” button lower right in Titanium home screen)
  3. Un-check “Auto-sync TB settings” under Preferences
  4. Only Run “Backup all user apps” under ‘Batch’.
  5. Titanium takes a backup of app and user data to SDCard.
Batch backup
Batch backup

Steps to Backup Stock ROM to SD card (Using Clockworkmod Recovery)

  1. Install ROM Manager from Market (free version)
  2. Open ROM Manager and select ‘Flash ClockworkMod Recovery’. Confirm the phone model and wait until flash operation is complete.
  3. Now ‘Select Reboot to Recovery Option’.
  4. In Recovery console, scroll to ‘backup/restore’ (Trackpad button to scroll and select, Power button to go back) and then select ‘backup’ to initiate stock ROM backup process. (It will take 5-10 mins).
  5. Once the backup is complete you will be redirected back to recovery console.
  6. (Optional: copy Titanium backup folder & Clockworkmod backup folder form the SDCard root folder to your PC, just in case)
Flashing Clockworkmod Recovery
Flashing Clockworkmod Recovery
Rom Manager Requesting for SuperUser access
Rom Manager Requesting for SuperUser access
Recovery Console
Recovery Console
Backup in Progress
Backup in Progress
Backup Complete
Backup Complete

Install Custom ROM – Cyanogenmod 7 based on Gingerbread

  1. Download the latest Cyanogenmod ROM zip file for G2 from here.
  2. Download Google Apps bundle from here. Its recommended to keep the zip on the root of SDCard.
  3. Copy the zip file to Sdcard root directory. Unmount Sdcard from computer.
  4. On your phone recovery console select wipe data/factory reset, wipe cache partition and Advanced > ‘Wipe Dalvik cache’. (Ensure that this step is complete before proceeding ahead).
  5. Now select the option ‘install zip from sdcard’ and choose cyanogenmod 7 zip that was copied earlier.
Wipe Cache, data ans Select Cyanogen zip from sdcard
Wipe Cache, data ans Select Cyanogen zip from sdcard
Cyanogen Boot Screen
Cyanogen Boot Screen
G2 with Honeycomb Theme
G2 with Honeycomb Theme

Install Google Apps

  1. In recovery console select ‘install zip from sdcard’ and choose the google apps zip file. Reboot the device.
Note: Now Cyanogenmod bootloader will be displayed. It might take one or two minutes to boot to the new OS. My phone started looping through the boot screen and the home screen. If that happens reboot your device once or twice.

Restore Backed-up Apps + Data via Titanium Backup

  1. Install Titanium Backup from Market.
  2. After opening Titanium, selectively restore apps from the “Restore all apps with data” (these will only be user apps per 3. above) by selecting this batch operation and un-checking the apps I do not want to restore via Titanium prior to running the batch operation (by default all apps will be selected). You can also select here to restore just the app, app + data, or just data.
Restore Apps and Data
Restore Apps and Data
Content extracted from
CyanogenMod 7 Info
App Name CyanogenMod 7
License free
Type code
App URL Download
More Info link

Batch File Decompiles Android apk to Java Source With a Single Command

Batch File Decompiles Android apk to Java Source With a Single Command

This batch file decompiles an apk to its corresponding java sources. People who are looking forward to do a code review on an android app who’s source code is not readily available can utilize this bat. This batch runs various free tools available on the internet in a sequence to obtain the java source files.
This is not made to encourage piracy/plagiarism in any case.

How To

1. Extract batch file and lib folder to C:\apk2java\ (or any folder that doesnt have space in its path)
2. Backup the target app’s apk from phone to PC via ASTRO Browser (check this post for details)
3. Keep the target apk in the root folder where batch file is present
Copy target apk to exec folder
4. Run ‘apk2java.bat target.apk’ in cmd
c:\apk2java>apk2java.bat target.apk
Execute Command
Process Complete
5. Result : java and resource files available in ‘src’
src folder containing decompiled files
Note: This batch just automates the sequence in which various tools are initiated and does not handle any error events. You will have to go through the cmd verbose to figure out the problem.
Note 2: ‘lib’ folder contains apk-tool files (apk-tool.jar, aapt.exe), jad.exe, 7zip (7za.exe), dex2jar files (all other jars).  If required, update each of those tools by replacing it with latest copy from links mentioned below.

Requirements

  • Windows (but can be ported to *NIX)
  • JRE 1.6 (Java Runtime Environment)

Tools in lib

  • Dex2jar – Converts Android dex format to jar (link)
  • JAD – Java Decompiler CLI (link)
  • 7Zip – Unarchival  (link)
  • apk-tool – Extracts resources from apk (link)
  • aapt – Android Asset Packaging Tool (link)
  • aapt commands (link)
@echo off
echo *********************************************
echo **          Convert 'apk' to 'jar'         **
echo *********************************************
set CLASSPATH=
FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0lib\setclasspath.bat" %%i
java -Xms512m -Xmx1024m -cp "%CLASSPATH%" com.googlecode.dex2jar.v3.Main %*

cd /d %~dp0

echo *********************************************
echo **    Remove if any 'src' folder exists    **
echo *********************************************
rmdir /s /q src

echo *********************************************
echo **    Create 'src' and 'class' folders     **
echo *********************************************
mkdir src
cd src
mkdir other
cd..
mkdir class

echo *********************************************
echo **     Expand, delete the 'jar' file       **
echo *********************************************
%~dp0lib\7za.exe x *.jar -o%~dp0class -aou
del *.jar 

echo *********************************************
echo **        Decompiling class files          **
echo *********************************************
xcopy /Q /E /Y class src
for /R src %%a in (*.class) do %~dp0lib\jad.exe -d %%~dpa -o -s .java "%%a"

echo *********************************************
echo ** Delete .class files and 'class' folder  **
echo *********************************************

cd src
del /S /Q *.class
cd..
rmdir /s /q class

echo *********************************************
echo **      Extract, fix resource files        **
echo *********************************************
java -jar "%~dp0lib\apktool.jar" decode -s -f *.apk %~dp0src\other\

echo ]                                               
echo *********************************************
echo **  Process complete - Check 'src' folder  **
echo *********************************************
echo ]
apk2java Info
App Name apk2java
License free
Type code
App URL Download
More Info link

Quickly Switch Between OpenDNS And Direct Connection With NetSetMan

03 Feb 2009

Quickly Switch Between OpenDNS And Direct Connection With NetSetMan

OpenDNS is a service which provides parental control solution by filtering the sites based on the URL entered by the user. OpenDNS can be easily setup by replacing the DNS nameserver provided by the ISP to the OpenDNS specific one. By changing the settings as in when required we can switch from direct connection/OpenDNS and vice versa. But this might be a tedious task to go and change the LAN settings when one might want to do it frequently. Let us find a work around for this.
OpenDNS provides a complete solution for blocking certain sites which falls under various identified categories. Once we register at OpenDNS website we get access to our Dashboard.
opendnsdashboard
All we have to do is to to enable parental control is
  1. Change the our DNS nameservers to OpenDNS NS (Nameservers are 208.67.222.222 and 208.67.220.220.)
  2. Customize the level of filtering in the setting found in OpenDNS website.
opendnssettings
OpenDNS can be configured either at Router or individual PC while using at the Home network. Most of the users who utilize this service for parental control use it in their PC rather than the router (Note: Enabling OpenDNS in router provides better security than in the PC). But in case of a shared computer is the admin is forced to switch OpenDNS back to direct connection for accessing few blocked sites, manually changing the LAN settings whenever required (Or by changing the filter level which consumes few mts to apply the changes). This process can be achieved in a single click with the help of a free tool called as NetSetMan.

Enable/Disable OpenDNS with NetSetMan

NetSetMan is a tiny tool which allows to create multiple profile for managing our LAN settings. This feature can be utlized to create two profiles which serves the purpose of enabling and disabling OpenDNS.
Open NetSetMan and create 2 profiles as mentioned
1. Profile 1 for enabling direct internet connection by providing DNS NS provided by our ISP
profiledirect
2. Profile 2 which is configured for enabling OpenDNS
profileopendns
The profiles can by activated right clicking the NetSetMan from the system tray.
profileswitching

Tips

  1. NetSetMan can work in portable mode which means the program folder can be moved to any location which is not ideally accessible by the unintended user.
  2. Execute NetSetMan only when required and close it once the switch is accomplished.

Links

OpenDNS – http://www.opendns.com/
NetSetMan -http://www.netsetman.com/index.php?s=nsm

Extract Android apk from Market and Decompile it to Java Source

Extract Android apk from Market and Decompile it to Java Source

This post talks about process of extracting apk file of any app available in market and then decompiling it to Java source. This can be helpful for those who perform code review (for security vulnerabilities) on apps whose source code is not available. Once Java source code is obtained, we can either do manual code review or run any free/commercial automated code scanners.

Download .apk file from market

  1. Search in market for the app you want to decompile and install it on your phone.
  2. Install Astro File Manager from market (link). Open Astro > Tools > Application Manager/Backup and select the application to backup on to the SD card .
  3. Mount phone as USB drive and access '\backups\apps\' folder to find the apk of target app (lets call it targetapp.apk) . Copy it to your local drive.

Decomiling apk to Dex format

  1. Download Dex2Jar (link) (Android runs applications which are in Dalvik Executable (.dex) format).
  2. Run the command to convert apk to jar
dex2jar targetapp.apk file(./dex2jar targetapp.apk on terminal)
File ‘targetapp.apk.dex2jar.jar’ is created
Converting Apk (Dex) to Jar

Viewing/Decompiling the Jar files to Java

Method 1 : Use JavaDecompiler (JD)

  1. Open ‘targetapp.apk.dex2jar.jar’ with jd-gui (link)
  2. File > Save All Sources to sava the class files in jar to java files.
JD GUI Viewer

Method 2: JAD

  1. Extract contents of jar file on to a folder named src. Use and unarchival utility like 7zip
  2. Keep ‘src’ folder in the same directory where JAD and targetapp jar is present
  3. Open JAD in cmd and execute the following command
  4. jad -o -r -sjava -dsrc src/**/*.class (./jad on terminal)
Extract jar contents to src folder
Running jad command
Now src will contain decompiled Java files ready for manual code review.
Decompiled java files

Tools Used

  1. Sample app – RemoteDroid (Opensource – link)
  2. Astro File Manager (Android Market – link)
  3. Dex2Jar (link)
  4. jd-gui (link)
  5. JAD (link)
Dex2Jar Info
App Name Dex2Jar
License free
Type
  • portable
  • code
App URL Download
More Info link          

Hacking Exposed: Web Applications 3rd Edition

Hacking Exposed: Web Applications 3rd Edition

Hacking Exposed: Web Applications 3rd Edition

Hacking Exposed: Web Applications, 3rd Edition By Joel Scambray, Vincent Liu, Caleb Sima
2011 | 482 Pages | ISBN: 0071740643 | PDF | 7 MB
The latest Web app attacks and countermeasures from world-renowned practitioners
Protect your Web applications from malicious attacks by mastering the weapons and thought processes of today's hacker. Written by recognized security practitioners and thought leaders, Hacking Exposed Web Applications, Third Edition is fully updated to cover new infiltration methods and countermeasures. Find out how to reinforce authentication and authorization, plug holes in Firefox and IE, reinforce against injection attacks, and secure Web 2.0 features. Integrating security into the Web development lifecycle SDL and into the broader enterprise information security program is also covered in this comprehensive resource.



Sustainable Buildings In Practice: What The Users Think

Sustainable Buildings In Practice: What The Users Think
Sustainable Buildings in Practice: What the Users Think By George Baird
2010 | 352 Pages | ISBN: 0415399327 | PDF | 32 MB
Current assessment methods of sustainable buildings do not adequately account for the users’ needs. Given that over the life of a building, total salary costs far outweigh both operating costs and combined capital and rental costs, the occupants’ needs are not something which should be sensibly ignored.



Windows Phone 8 Development Internals By Andrew Whitechapel

Windows Phone 8 Development Internals By Andrew Whitechapel

Windows Phone 8 Development Internals By Andrew Whitechapel, Sean McKenna
2013 | 800 Pages | ISBN: 0735676232 | EPUB | 36 MB
Drill into Windows Phone 8 design and architecture—and learn best practices for building a variety of applications. Led by two senior members of the core Windows Phone Developer Platform team, you'll learn the underlying technology that will help you build better apps. Each chapter focuses on a single Windows Phone building block or feature area and shows you how to apply it in your applications—offering you invaluable insights into the Windows Phone platform design and API surface.