How to view the contents of an Android Application Package [APK] Certificate

Android APK packages are signed in almost the same way Java jar files are signed. Booth APK and normal jar file are a collection of files contained in a zip archives. This zip file contains a special directory called META-INF. You can list the content of an apk or jar by unzipping it.

shingu@abyss:~/workspace/apk_tool/app$ unzip -l SysScope.apk 
Archive:  SysScope.apk
  Length      Date    Time    Name
---------  ---------- -----   ----
     3912  2011-06-22 22:25   AndroidManifest.xml
    20480  2011-06-22 22:25   assets/databases/SysScope.db
    50780  2011-06-22 22:25   classes.dex
   132964  2011-06-22 22:25   lib/armeabi/
     3966  2011-06-22 22:25   res/drawable-hdpi/icon.png
     1537  2011-06-22 22:25   res/drawable-ldpi/icon.png
     2200  2011-06-22 22:25   res/drawable-mdpi/icon.png
     1200  2011-06-22 22:25   res/layout/main.xml
    18216  2011-06-22 22:25   resources.arsc
      722  2011-06-22 22:25   META-INF/MANIFEST.MF
      783  2011-06-22 22:25   META-INF/CERT.SF
     1772  2011-06-22 22:25   META-INF/CERT.RSA
---------                     -------
   238532                     12 files

META-INF/MANIFEST.MF contains the list of files present in the APK and their digest of their content. The default digest used is SHA-1
it’s representation in the the manifest is the base64 encoded binary value ( unix tools like sha1sum or openssl sha1 display the hexadecimal encoded binary value)

shingu@abyss:~/workspace/apk_tool/app$ unzip -p SysScope.apk META-INF/MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.0 (Android)

Name: res/layout/main.xml
SHA1-Digest: nYLGdLfUklqrTBMXivY0tP7FmuI=

Name: res/drawable-ldpi/icon.png
SHA1-Digest: i7vxaosoiS+9HzKB7ZgIsXMYRLY=

Name: assets/databases/SysScope.db
SHA1-Digest: Pp+lZmoaigZ3Lby0SuT0A4L4agk=

Name: AndroidManifest.xml
SHA1-Digest: 27hkQcGfk0AxcQpmadjaRZzIeME=

Name: res/drawable-mdpi/icon.png
SHA1-Digest: 7Ft/Rirt+l/JRX2KjDREScdbCZk=

Name: resources.arsc
SHA1-Digest: XYx73APeTgDEHLnwBhn4K5cEdHI=

Name: lib/armeabi/
SHA1-Digest: QaKl9JJy03zb8M60RJHjERIZwQ0=

Name: classes.dex
SHA1-Digest: Ufn0Gq4pfRiUq30Gk7T9e3fwH88=

Name: res/drawable-hdpi/icon.png
SHA1-Digest: Vj/qhxk8ic8FE0/kT6E3vgRJ4mE=


META-INF/CERT.SF (Signature file) In the manifest file, the SHA digest value for each source file is the digest (hash) of the binary data in the source file. In the .SF file, on the other hand, the digest value for a given source file is the hash of the three lines in the manifest file for the source file. The lines are “dos” terminated.

shingu@abyss:~/workspace/apk_tool/app$ unzip -p SysScope.apk META-INF/CERT.SF
Signature-Version: 1.0
Created-By: 1.0 (Android SignApk)
SHA1-Digest-Manifest: 5nayND/U8KFF85e23PLmiFxQYVw=

Name: res/layout/main.xml
SHA1-Digest: ZuC7g0HMvoicNdIyQPGeZFTkFJ4=

Name: AndroidManifest.xml
SHA1-Digest: sUzgN805uQc1gAvQL3jHjcd25Kc=

Name: assets/databases/SysScope.db
SHA1-Digest: CI1B8j8dBCkiWEUINw1n3qGrHMo=

Name: res/drawable-ldpi/icon.png
SHA1-Digest: Z/yxmMxGRNbFUkjqWONvJQH5rQw=

Name: res/drawable-mdpi/icon.png
SHA1-Digest: iR1AGdcgDutAX/5xyl92TWcEJuw=

Name: lib/armeabi/
SHA1-Digest: 2BEQBw0DTzVveHr1tqbI1LEULwY=

Name: resources.arsc

Name: classes.dex
SHA1-Digest: 74e4iOLLmlNLRgBZ7h2srgsjuBk=

Name: res/drawable-hdpi/icon.png
SHA1-Digest: 3vv9derC/UrLpiam9i2Yo16eHXw=


META-INF/CERT.RSA The .SF file is signed and the signature is placed in the .RSA file.
The .RSA file also contains, encoded inside it, the certificate or certificate chain from
the keystore which authenticates the public key corresponding to the private key used for signing.

You can print out the certificates using the following lines of code:

openssl pkcs7 -inform DER -in CERT.RSA -noout -print_certs -text

keytool -printcert -file CERT.RSA

shingu@abyss:~/workspace/apk_tool/app$ unzip -p SysScope.apk META-INF/CERT.RSA | keytool -printcert 
Owner:, CN=Samsung Cert, OU=DMC, O=Samsung Corporation, L=Suwon City, ST=South Korea, C=KR
Issuer:, CN=Samsung Cert, OU=DMC, O=Samsung Corporation, L=Suwon City, ST=South Korea, C=KR
Serial number: d20995a79c0daad6
Valid from: Wed Jun 22 17:55:12 IST 2011 until: Sun Nov 07 17:55:12 IST 2038
Certificate fingerprints:
	 MD5:  D0:87:E7:29:12:FB:A0:64:CA:FA:78:DC:34:AE:A8:39
	 SHA1: 9C:A5:17:0F:38:19:19:DF:E0:44:6F:CD:AB:18:B1:9A:14:3B:31:63
	 SHA256: 34:DF:0E:7A:9F:1C:F1:89:2E:45:C0:56:B4:97:3C:D8:1C:CF:14:8A:40:50:D1:1A:EA:4A:C5:A6:5F:90:0A:42
	 Signature algorithm name: SHA1withRSA
	 Version: 3


#1: ObjectId: Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 93 2C 3A F7 0B 62 7A 0C   76 10 B5 A0 E7 42 7D 6C  .,
0010: FA EA 3F 1E                                        ..?.
[, CN=Samsung Cert, OU=DMC, O=Samsung Corporation, L=Suwon City, ST=South Korea, C=KR]
SerialNumber: [    d20995a7 9c0daad6]

#2: ObjectId: Criticality=false

#3: ObjectId: Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 93 2C 3A F7 0B 62 7A 0C   76 10 B5 A0 E7 42 7D 6C  .,
0010: FA EA 3F 1E                                        ..?.


Find all of the certificates and Issuer in a folder of apk’s

for filename in *; do 
    if [ "$ext" = "apk" ]; then 
        echo $filename;
        unzip -p ${filename} META-INF/CERT.RSA | keytool -printcert | grep Issuer

Building Linux Kernel

1) Obtain Linux Source code
——-> 1.1) Obtain as a single file

Kernel is hosted at You can download the latest kernel from

$ wget -c

——-> 1.2) Clone using git

$ git clone git:// linux-git

2) Configure
——-> 2.1) Old Config

$ make oldconfig

——-> 2.2) Custom Config

$ make menuconfig

3) Building

$ make -j4

4) Installing

# make modules_install install

Launch other application from your application in Android

protected void launchApp(String packageName) {
	Intent mIntent = getPackageManager().getLaunchIntentForPackage(packageName);
	if (mIntent != null) {
		try {
		} catch (ActivityNotFoundException err) {
			Log.d("Shingu","App not found");

Get List of Installed packages in Android

To get the list of packages installed in the android, use below code.
More details

protected void print_installed_pkgs() {
	final PackageManager pm = getPackageManager();

	//get a list of installed apps.
	List InstPackages = pm. getInstalledPackages(PackageManager.GET_META_DATA);

	for (PackageInfo packageInfo : InstPackages) {
			Log.d("Shingu", packageInfo.packageName);

பிராத்தனை | கோடிட்ட இடங்களை நிரப்புதல் – சுமதி ராம்.

ஒரு நாளும் பள்ளி பேருந்தில்
ஏற்றி விடாத
அப்பா வாய்க்கப்பட்ட மகள்,
பார்த்து விடக்கூடாது,
பேருந்திற்காக காத்திருக்கும்
தன் மகளின் பள்ளி சீருடையை
சரி செய்து கொண்டிருக்கும்
ஏதோ ஒரு அப்பாவை.

- சுமதி ராம்.


Translation :

Title : Entreaty

A girl, whose father has never sent her in a school bus,
Should not see, a father who lovingly adjusts his daughters uniform,
while waiting for her school bus.

This is a poem by Sumathi Ram, Director Ram‘s Wife in her Poetry collection titled “Koditta Idangalai Niraputhal“.

Linux executable without main() Function | Write a C Executable program without main() function

Very Short version :

1) Create the program without main() function.

rajkumar.r@17:56:58:~/workspace/raj/workouts/ex_without_main$ cat exe_wo_main.c 
const char my_interp[] __attribute__((section(".interp"))) = "/lib/";
int fn_wo_main() {
	printf("This is a function without main\n");

2) Compile it as a Shared object

gcc -shared -Wl,-e,fn_wo_main exe_wo_main.c -o

3) Run it!!

rajkumar.r@17:57:36:~/workspace/raj/workouts/ex_without_main$ ./ 
This is a function without main

Longer Version with Explanation :

Generally, all of the C programs starts at main() function. This is a standard defined fro C programming. When we look at the internals of this, we can understand how the system actually works in the background. C is a compiled language, which means, the source code is converted into the executable, before the execution starts. The general C program compilation process goes through the following steps, which is well documented in several other websites.

C Source code
Preprocessor – Intermediate files
Compiler – Object files
Linker – Linked Object file [ Executable file ]
Loader – Loads the executable and executes.

For our goal, we have to understand the linking process. We write our code starting from main(). But before the main(), there are several things happens in the background. Like, setting up of the environment, fetching input, configuring console etc. These are beautifully abstracted by GCC and the host system which hides those process from the user.

Here, we will unravel a small step of the long and complex process. The entry point of the execution. When the source code is preprocessed and compiled, the object codes are generated. After this, the standard and user built object codes are linked to generate the executable. The linking is done by the linker script which directs how to create the binary executable. This is where, the entry point of the executable is defined and configured as main().

Before main(), there happens few configurations. One among them is, configuration of dynamic loader, which loads the required symbols at run time. Usually in Linux, it is /lib/, which inturn links to the corresponding loader provided by the compiler collection. In my case, it seems to be as below.

rajkumar.r@17:59:50:~/workspace/raj/workouts/ex_without_main$ ls -l /lib/ 
lrwxrwxrwx 1 root root 25 Jan 28  2013 /lib/ -> i386-linux-gnu/

GCC Compiler is a very powerful and sophisticated compiler. GCC also offers a lot of control to the developers. One among several wonderful option is, -Wl,option. According to gcc man page,

	   Pass option as an option to the linker.  If option contains commas, it is split
	   into multiple options at the commas.  You can use this syntax to pass an argument
	   to the option.  For example, -Wl,-Map, passes -Map to the
	   linker.  When using the GNU linker, you can also get the same effect with 

From ld manual @t,

The linker command language includes a command specifically for defining the first executable instruction in an output file (its entry point). Its argument is a symbol name:


Like symbol assignments, the ENTRY command may be placed either as an independent command in the command file, or among the section definitions within the SECTIONS command--whatever makes the most sense for your layout.

ENTRY is only one of several ways of choosing the entry point. You may indicate it in any of the following ways (shown in descending order of priority: methods higher in the list override methods lower down).

	the `-e' entry command-line option;
	the ENTRY(symbol) command in a linker control script;
	the value of the symbol start, if present;
	the address of the first byte of the .text section, if present;
	The address 0. 

For example, you can use these rules to generate an entry point with an assignment statement: if no symbol start is defined within your input files, you can simply define it, assigning it an appropriate value---

start = 0x2020;

The example shows an absolute address, but you can use any expression. For example, if your input object files use some other symbol-name convention for the entry point, you can just assign the value of whatever symbol contains the start address to start:

start = other_symbol ;

We are going to combine all of these above features to run a program without main function. The steps are..

1) Create the program without main() function.

rajkumar.r@17:56:58:~/workspace/raj/workouts/ex_without_main$ cat exe_wo_main.c 
const char my_interp[] __attribute__((section(".interp"))) = "/lib/";
int fn_wo_main() {
	printf("This is a function without main\n");

Here, you can see we have a strange thing at line number 2. This is to compensate the missing main() and adding the dynamic loader section. :)

2) Compile it as a Shared object

gcc -shared -Wl,-e,fn_wo_main exe_wo_main.c -o

3) Run it!!

rajkumar.r@17:57:36:~/workspace/raj/workouts/ex_without_main$ ./ 
This is a function without main


Creating a Local Git repository in ubuntu

Agenda :
1) Create a remote repository in local file system
2) Create a workspace
3) Create a empty repository
4) Add Initial file
5) Add remote origin
6) Push the code to remote repo
7) Creation of new branch
8) Pushing the new branch
9) Viewing all branches and Changing branch
10) Merging development branch to Master branch

1) Creation of a local repository
We need to define a location where the git repository will reside.
For this, we will create a local git repo.
To start with the local git repositary setup, first, we have to create a local directory.
I chose the below location for this.

cd /;
sudo mkdir gitrepo;
sudo chmod 777 gitrepo;
cd gitrepo;
mkdir project_1;
cd project_1;
git init –bare;

2) Creation of workspace
To start working, you need a workspace. I chose the below location as workspace

cd ~/;
mkdir workspace;
cd workspace;
mkdir project_1;
cd project_1;

4) Creation of Empty Depositary
Initiate a empty repositary here.

git init;

4) Adding Initial files.
Add your required initial files to the repo.

echo “This repository is to learn creation of local git repos” >>README
git add README;
git commit -m”Initial Commit”

5) Adding Remote origin
Now, we have to specify, where we will store this repository.
Remember?? We have created a local repository at first?
Else, check 1 Creation of a local repository

Now, we are going to use this location as the remote location.

git remote add origin /gitrepo/project_1

6) Pushing the code to remote repo
Now, we can push the code to the remote repo we have added.

git push origin master

The end master indicates, we need to push to the branch called as master in the remote repo.

To test the setup so far.. i.e. to check whether our code is safe at remote repo, lets try the below.

cd ../
rm -rf project_1;

git clone /gitrepo/project_1;
cd project_1;

Now, we should be able to see out previously added file.

7) Creation of new branch
Now, we will create a branch for development..

In the workspace repo, we will create a local branch at first. Then we will push this branch to the remote repo.

git checkout -b devel

git status, should tell that you are in the new branch devel

8) Pushing the new branch to remote :
Once you have added your development code, to push the new branch to the remote repo, follow the below..

git add *;
git commit -m”Adding development code”
git push origin devel

This would push the branch to the remote repo..

9) Viewing all branches and Changing branch
To list all of branches in current repo, run

git branch -a

A start will be present to indicate the active branch.
Remote branches will be preceded with remotes/origin/ in their path.

To change to a particular path, run

git checkout -b branch_name

10) Merging development branch to Master branch

git checkout master
git pull
git merge devel


Get every new post delivered to your Inbox.