Thursday 9 February 2012

Reverse Engineering and Analysing (Static Code Analysis) of Android .APK Files Using Agnitio

Agnitio 2.1 which is the latest version, can be downloaded here. Developed by David Rook (Security Ninja), it''s a great tool for secure code review.

Here is the Wikipedia definition of Static Code Analysis. It involves pattern matching inside the source code, usually done by an automated tool.

Agnitio also supports reverse engineering of Android .APK files and the doing a static analysis of the Java code. This is an automated tool, this procedure can also be performed manually using Baksmali utility, where we can extract the source code of the Android application using the binary.


Here's a step-by-step procedure to reverse engineer Android .APK file using Agnitio :-

Step 1 :- Download and install Agnitio.



Step  2:- Agnitio doesn't create a folder in the start menu. So, go to the path where you installed it. Generally it is at C:\Program Files\Agnitio\ path. Run the Agnitio application.




Step 3:- Click on Static Analysis Tab.




Step 4:- Click on Browse, and select the path of folder where your .APK file (application binary) is stored.







Step 5:- Now select Java and as the language, select the .APK file and then click on Scan.





Step 6:- Click on OK for the following prompt.



Step 7:- After the scan is complete, expand the tree to reveal the structure of the code.




Step 8:- Select the file that you want to do static code analysis for and again click on Scan after selecting Java as the language.




Step 9:- This will display all of the vulnerabilities that the Agnitio reveals during the scan using static analysis of the code.


Agnitio performs a line by line pattern matching in the code, and highlights the vulnerabilities that are found in terms of insecure coding.

Friday 3 February 2012

Convenient Hack To Convert Dynamic Disk to Basic Disk in Windows 7

Good news !!! Converting to basic disk from dynamic disks is possible !!! And it works like Magic !!!

Microsoft has made it frighteningly easy to convert from Basic Disks to Dynamic Disks. And it is supposed to be irreversible. As a solution, there is always the option of formatting the OS and installing windows again, as windows by default sets the Hard Disk to basic disk. But that's not what most would prefer. Not to worry, there is hope. :)

And if you are one like me who accidentally or just out of curiosity clicked on convert to Dynamic Disk, without doing proper research... well there is a way to go back to basic disks. In case of Dynamic Disks, all of the drives in your system is just shown as one big pale yellow slab as shown below. The reversing option is disabled as soon as you convert to dynamic disk, shown as follows :-


Except for that there is no other difference in the way you access your drives, and it would look just normal from My Computer :-



Here is a good post (though confusing) on how to convert dynamic to basic disks.
This one also show 3 different methods for the same. We'll be using the 2nd method from here.

Disclaimer : Even though the procedure is is possible and is low risk, it might corrupt your Hard Disk if you are not careful enough. So, I am not responsible for any damage that you may cause. 

Lets go step-by-step to the procedure to convert dynamic disks to basic disk in Windows 7 :-

Step 1 :- 

Take the Backup of your data (All of it !!!)


Step 2 :-

Read up on Dynamic disk and Basic Disk types first.
      Here's a few links :-
      http://sh0aib.blogspot.in/2012/01/dynamic-disks-sucks.html
      http://www.dynamic-disk.com/convert-dynamic-disk-to-basic.html
      http://msdn.microsoft.com/en-us/library/windows/desktop/aa363785%28v=vs.85%29.aspx

Step 3 :-

Download HxD - Freeware Hex Editor and Disk Editor here.



Step 4 :- 

Run as administrator -> HxD


 

Step 6 :-

Click on menu Extras >> Open Disk



Step 7 :-

Open disk >> Physical disks >> Hard Disk 1
      Unselect Open as ReadOnly (since we'd like to make changes) and click OK.




Step 8 :- 

At the end of Sector 0 (just before start of sector 1), search for the four consecutive 42s as shown. These 42s when converted to 07s, will convert the Dynamic Disks to Basic Disks.




Step 9 :-

Just type 07 in place of 42 at all of the four locations. Do not make any other changes, otherwise your Hard Disk might get corrupt.



Step 10 :-

Close HxD and it will ask confirmation to Save the Changes. Click Yes.


Step 11 :-

Reboot. In case your system does not start... blame yourself and reinstall Windows.

But if Windows restarts properly... time to cheer :)

Then open Disk Management to confirm the changes.


The Disk Management will show your Hard Disk as a Basic Disk, with Primary Partition marked in dark blue.

Do leave comments / doubts behind.