Month: March 2017

Home / Month: March 2017

There is a misconception in some community that Windows doesn’t support hard link and symbolic link as in Unix world. Most of us think that Windows OS only support link (with .lnk extension) and I’ve seen that there are also several articles point out that symbolic linking in Unix world is closely resemble to Windows .lnk file.

Though the concept is not very similar, we can say that Windows has three type of linking: hard link, junction, and symbolic link. Before we go through them, let’s give the concept of hard link and symbolic link (soft link).

Links in Unix

In Unix world, symbolic link (also termed as soft link) is a special kind of file that points to another file. Well, hard link too is a special kind of file that points to another file. The difference between two is symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system. The difference gives symbolic link certain qualities that hard links does not offer, such as the ability to link to directories, or to files on remote computers network through NFS. When we delete a target file, symbolic links to the file become unusable. Whereas the hard links preserve the contents of the file. So we can say that hard link is essentially a label or another name assigned to a file. Operation executed upon any of these “different names” will be operated upon the original file. When the original file is deleted, the hard link will still persist. You can think it as a reference count.

In Unix, these commands create symbolic link and hard link respectively.

# Symbolic Link
ln -s target link

# Hard Link
ln target link

Concept of Links in Windows

Now let’s go to the Windows world. The definition of hard link and symbolic link is nearly similar.

A hard link is the file system representation of a file by which more than one path references a single file in the same volume.MSDN states that any changes to the file are instantly visible to applications that access it through the hard links that reference it. Changes in the original file will be reflected in every hard link made to that file. Thus, if there are multiple hard link point to a READ-ONLY file and we want to delete a particular hard link, then after delete it we need to reset the READONLY attribute to any of remaining hard link (or original file).

A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target. They are transparent to users; the links appear as normal file or directories and can be acted upon by the user or application in exactly the same manner.

Then, what is junction?

Junction (Microsoft refer it as soft link) is similar to hard link. Indeed it is a hard link. It differs from a hard link in that the storage object it references are separate directories and a junction can link directories located on different local volumes on the same computer. Otherwise it is identical to hard link.

The Command (Utility)

Hard Link

mklink /H link target

Symbolic Link

# File Symbolic Link
mklink link target

# Directory Symbolic Link
mklink /D link target


mklink /J link target

Create Link Programmatically

Hard Link: CreateHardLink

Symbolic Link: CreateSymbolicLink


So what’s the different of these links with .lnk file?

Well we need to see the representation. Links are file system object while the .lnk file is a file. The .lnk file is a file describe the redirection and any extra operation need to perform when it is executed. The links are only redirection to the file.

To feed our brain, NTFS has many advanced options that is unknown to us as end-user.

List of Alternative Android Emulator

March 25, 2017 | Article | No Comments

Android is a popular operating system for handheld and now dominating the market share. Though the there are already exists various cheap devices running android, many of us want want to run android on our PC. I myself has two reasons for this: first to play some games without open my device, and second is to test my application.

Fortunately, there are plenty of them available, from free to paid one. This article is not an exhaust list of android emulator, but serve as a purpose as a documentation of emulator I had known and taste (some of them).

The Basic Concept

Many years ago the only processor supported by android is ARM architecture. The only way to start an android in our PC is through official Android emulator, bundled with the SDK. It is so slow due to many things. We name it emulator, as we are emulating the android environment (in ARM) to run in our PC environment (in x86/x86-64). Then some projects exists to port Android to x86 architecture. This unofficial build is known as Android x86. Later, Android officially support x86 processor which is not very different to PC one. However, we still need this piece of software, emulator. Why?

Android is an operating system for mobile device such as mobile phone, tablet, smart TV, etc. Android device has many different hardware variation as each manufacture can ship any hardware they like but android ensure that the platform is viewed as one uniform. Android abstract the complicated and give it as a single platform. As a platform, android has different component those are different to PC (typically a Windows PC). For example the interface and the application format, they are different. So to make android application running on top our Windows PC, there should be something that can bridge this two platform, and that would be an emulator.

Simply, an emulator is a hardware or software that enables one platform (called host) to behave like another platform (called guest). These android emulator can run the application simply by providing environment that looks like the real device. We are not seeing Android from the point of processor is run on, but the Android platform as a whole.

Android, in Android SDK, has ship an official emulator for testing. But this emulator is proven to be slow and need much time for startup. So there are many people starts to create some lightweight android emulators that can boot android faster and consume less resource, compared to official one. Unless you tweak the emulator, like enabling Intel HAXM (Hardware Accelerated Execution Manager), these alternative emulators are preferable.

You can also see other article about Inside the Android Emulator series to discuss something deeper than this.

The List

  1. Nox App Player
  2. BlueStacks
  3. GenyMotion
  4. Andyroid
  5. YouWave
  6. Visual Studio Android Emulator
  7. MEmu
  8. Jar of Beans
  9. Manymo
  10. Xamarin Android Player
  11. MEmu

Nox App Player


Definitely my favorite. Minimalist yet provide many things.

It is one of the best options available to emulate android on PC. It also supports wide range of Android Gaming controls. And the best part of this, Nox App Player support most of the top android games. This full-fledged android emulator will need us to set some things, such as google accounts. Apart from the standard mouse and keyboard support, Nox also support several input/output devices such as gamepads and controllers. Nox also support multiple emulator instances, or profile you might say. This way we can have more than one emulator each with different configuration.

Technically, Nox App Player use (at this time) an Android 4.4.2 kernel, or preferably called Android KitKat. It mimics UI operations on a tablet or smartphone so the learning curve is not steep. Also Nox comes with the Google Play Store integrated into the install package. In my experience, Nox App Player is also easy to use for penetration testing purpose.



A big player in this emulation world. BlueStacks is mature enough and support almost all of android games and apps that play store is offering. Some sites recommends it as the first option to emulate android. No wonder, BlueStack supports about 96% of the games and apps available on Play Store (in their claim).



What’s interesting for me is their GenyMotion on demand, aside of their android emulator on our local PC. It is an Android AMs on Amazon EC2 infrastructure. While the local emulator is proven fast, it also offer graphic acceleration and use x86 as its base, which is not different to our PC.

Some sites recommends it as the first alternative for BlueStack or now might be the first opinion for Android emulator.



Also known as Andy OS. One of the feature is one can use their phone as remote control while playing a game through the emulator. It even supports seamless, wireless transition of apps from computer to android device.



There are two version available at this time. The free version use Android 4.0 (Ice Cream Sandwich) and the premium version use Android 5.1 Lollipop.

Visual Studio Android Emulator


One of project / component in Visual Studio that can be installed on demand. Similar to Windows Mobile emulator, this product need Hyper-V installed. And when running, Hyper-V (as well as Visual Studio Android Emulator) will locks the virtualization support exclusively and not sharing it with other software like VirtualBox or VMware. One of the feature that highlighted is the Work-From-Home, which makes it works over remote desktop.



A new but promising emulator.

Technically, it uses Android 4.4 as default image for any instance. Optionally, you can also download the Android 5.1 as base system if you like.

Jar of Beans


Sadly, it has been discontinued.

From XDA forum, home of android hackers. It is an android jelly beans emulator and allows us to do easy installation and configuration. It supports multi user in the form of profile and enables us to customize our own settings. We can also create Virtual SD card. It requires no setup as it is completely portable.



Sadly, it has been discontinued.

They said Manymo is a better emulator. Unlike other emulator, Manymo is an in-browser emulator and support multiple android versions. It means, you need no installation, you only launch the emulator you need. Their target audience is developer, which wants to eliminates the tedious task by providing a facility to test apps on different android version without having those devices. They say it’s lightweight as the actual computation is held on their end but you need stable internet connection to use it.

Xamarin Android Player


Sadly, it has been discontinued.

Xamarin specialize itself in mobile application development. They create SDK which makes us able to deliver an application in native Android, iOS, and Windows platform. One of their suite is their emulator.

While the development itself had been ceased, you can still download the Xamarin Android Player for free.

Xamarin provides various version of Android, from 4.1.1 (Jelly Bean) to 5.1.0 (Lollipop). Most of them are preconfigured as Nexus device.




There are other alternative way to run android on PC.

Using Stand Alone Android NDK Compiler

March 21, 2017 | Article | No Comments

Android is an operating system for various mobile device, such as mobile phone, tablet, smart TV, etc. The power of android comes from the use of a process virtual machine, dubbed as Dalvik Virtual Machine (DalvikVM) and later Android Run Time (ART), to abstract complicated and varying modules. You write in Java, compile it, and android environment will run it regardless of whatever hardware it has. It guarantees portability but for us. But if you want to write in native code, android provide us with NDK (Native Development Kit).

The product of NDK is a native code, which will be invoked by Android application (written in java) by JNI means.

There are three ways to use Android NDK as far as I know. This article will discuss all of them. But before it, we need to know some background information to let you know what happen behind the scene.

Obtaining NDK

NDK is free for download. You can download it from this official link.There are four platform available (Windows 32-bit, Windows 64-bit, Mac OS X, Linux 64-bit). Choose the one suitable for your platform. These packages are archived using zip. You can extract them with your favorite extractor / zip program and place it to any directory. Make sure they are invokable or can be called from command line. You can achieve this by setting the environment variable or PATH in your respective platform.

If the directory is mentioned, we will refer it as $NDK.

Target Platform

Android has came to various platform. ARM/ARM64, x86/x86-64, MIPS/MIPS64. Your mobile device platform is your target so you need to know and make sure what platform you face. In most case, ARM is sufficient as it is currently dominating the mobile system’s market. But again, make sure you know the platform. You can achieve it by reading the datasheet or information provided by the manufacturer.

Android NDK use GCC infrastructure. So for the platform you chose it will have the triplet which indicating the platform. You can verify it here.

[table “10” not found /]

The toolchain is located at $NDK/toolchains

Sysroot and Target API

Sysroot is a directory containing the system headers and libraries for target. To define sysroot we must know the Android API level we want to target. The Android API levels reside under $NDK/platforms/. Fortunately, unlike SDK, android has shipped all the supported API level so downloading the current NDK is recommended.


Way 1: Use Makefile

In GNU world we know Makefile. Makefile is a small script that is used by “make” command to automatically configure and build the application. It can be thought as a configuration script. It is declarative so we need only declare some parts, such as include directory, sources file, and output then we invoke the makefile to automatically build it without needed to compile each file by yourself.

In android, we have and for this purpose. The file is useful for defining and overriding project-wide settings. It must resides in our project’s $PROJECT/jni/ directory, and describes sources and libraries we use. The is placed under directory of $NDK/apps/ directory.

For example we have these files

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := foo


APP_ABI: armeabi armeabi-v7a

Then we can invoke the build process as this.


The NDK will give output such as this when build is in process.

[armeabi] Compile thumb  : foo <= foo.c
[armeabi] Executable     : foo
[armeabi] Install        : foo => libs/armeabi/foo
[armeabi-v7a] Compile thumb  : foo <= foo.c
[armeabi-v7a] Executable     : foo
[armeabi-v7a] Install        : foo => libs/armeabi-v7a/foo

Way 2: Use compiler Directly

Know the platform we face and it’s API level. To use this way, we need to define the sysroot. The specific invokation will depend on your OS, but generally we need to define a SYSROOT variable which point to our sysroot and then invoking the compiler.

Use this code for example.

int main()
   return 0;


Set these once before compiling.

SET SYSROOT=%NDK%\platforms\android-22\arch-arm
SET TPATH=%NDK%\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin
SET CC=%TPATH%\arm-linux-androideabi-gcc.exe --sysroot=%SYSROOT%

and use this for compiling

%CC% -o code.o code.c


Set these once before compiling.

export SYSROOT=$NDK/platforms/android-22/arch-arm
export TPATH=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
export CC=$TPATH/arm-linux-androideabi-gcc --sysroot=$SYSROOT

and use this for compiling

$CC -o code.o code.c

Mac OS X

Set these once before compiling.

export SYSROOT=$NDK/platforms/android-22/arch-arm
export TPATH=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin
export CC=$TPATH/arm-linux-androideabi-gcc --sysroot=$SYSROOT

and use this for compiling

$CC -o code.o code.c

Way 3: Use Customized Toolchain

NDK provides a wrapper. This is useful if we want to invoke command without necessary using ndk-build. The script is provided to perform a customiezed toolchain installation from command line. The script is located in $NDK/build/tools/ and unfortunately no windows’ .bat version available.

To use it, we can invoke this command:

$NDK/build/tools/ --arch=arm --platform=android-22 --install-dir=/tmp/my-android-toolchain

The wrapper is created in /tmp/my-android/toolchain/ which contain copy of android-22/arch-arm sysroot and the toolchain binaries for 32-bit ARM architecture. This wrapper doesn’t depend on host so we can place it in any location or even move it to any location.

To invoke the wrapper

export PATH=/tmp/my-android-toolchain/bin:$PATH
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++

and use it as usual.

Using DES Algorithm in Various Languages

March 8, 2017 | Article | No Comments

Data Encryption Standard (DES) or should be Data Encryption Algorithm, is a symmetric-key algorithm for the encryption of electronic data. Although this algorithm is now considered as insecure, it was highly influental in the advancement of modern cryptography. Most course on cryptography still present DES when they are discussing about block cipher especially symmetric one.

This article will demonstrate how to use DES for encrypt and decrypt content in various programming language. The snippet code here should be platform independent unless said otherwise. The implementation will be based on library or framework for respective programming language. If there are more than one implementation, we will divide the section for each implementation.

If you need information about specific detail in DES, go to online course such as this

The Implementation

Implementation: C#

In C# implementation, each algorithm is provided by a service provider. All operations should be done in byte array, therefore we have some string and byte array conversion in some place.

The key can be an input from user or generated by you. Just remember to use byte array.

// Library
using System.Text;
using System.Security.Cryptography;

// Key and Initialization Vector
byte[] key = ASCIIEncoding.ASCII.GetBytes("12345678");
byte[] iv  = ASCIIEncoding.ASCII.GetBytes("01234567");

DESCryptoServiceProvider crypto = new DESCryptoServiceProvider();

// Tweak the provider
crypto.Key = key;
crypto.Mode = CipherMode.CBC;    // Options: ECB, CFB

The following is using stream for manipulating content.

// Encrypt
ICryptoTransofrm transform = crypto.CreateEncryptor();
MemoryStream memStream = new MemoryStream();
CryptoStream cryStream = new CryptoStream(memStream, transform, CryptoStreamMode.Write);
StreamWriter writer = new StreamWriter(cryStream);
byte[] ciphertext = memStream.GetBuffer();

// Decrypt
ICryptoTransform transform = crypto.CreateDecryptor();
MemoryStream memStream = new MemoryStream(ciphertext);
CryptoStream cryStream = new CryptoStream(memStream, transform, CryptoStreamMode.Read);
StreamReader reader = new StreamReader(cryStream);
string plaintext = reader.ReadToEnd();

This one is straightforward implementation without utilizing stream

// Encrypt
byte[] buff = ASCIIEncoding.ASCII.GetBytes(plaintext);
crypto.CreateEncryptor().TransformFinalBlock(buff, 0, buff.Length);

// Decrypt
byte[] buff = ASCIIEncoding.ASCII.GetBytes(ciphertext);
crypto.CreateDecryptor().TransformFinalBlock(buff, 0, buff.Length);

Implementation: Java

The java implementation is called JCE (Java Cryptography Extension). All operations should be done in byte array, therefore we have some string and byte array conversion in some place.

// Library

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;

In this case we can generate a key or using our own key.

// Key generator
KeyGenerator keygen = KeyGenerator.getInstance("DES");
SecretKey key = keygen.generateKey();

// Using own key
String strkey = "12345678";
DESKeySpec dks = new DESKeySpec(strkey.getBytes());
SecretKeyFactory skf = SecretKeyFactory.getInstance("DES");
SecretKey key = skf.generateSecret(dks);

Creating cipher instance from Cipher class, specifying some information such as algorithm name, mode, and padding scheme. The last two are optional. All should be separated by a slash.

// Encrypt
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS7Padding");
byte[] text = plaintext.getBytes();
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] result = cipher.doFinal(text);

// Decrypt
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS7Padding");
byte[] text = ciphertext.getBytes();
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] result = cipher.doFinal(text);

Implementation: Visual Basic (VB) .NET

Actually, VB.NET implementation is similar to C# one. Each algorithm is provided by a service provider. All operations should be done in byte array, therefore we have some string and byte array conversion in some place.

The key can be an input from user or generated by you. Just remember to use byte array.

// Library
Imports System.Security.Cryptography;

// Key and Initialization Vector
Dim key() As Byte = System.Text.Encoding.Unicode.GetBytes("12345678");
Dim iv()  As Byte = System.Text.Encoding.Unicode.GetBytes("01234567"); 

Dim crypto As DESCryptoServiceProvider = new DESCryptoServiceProvider; // Tweak the provider 
crypto.Key = key;
crypto.Mode = CipherMode.CBC; // Options: ECB, CFB

The following is using stream for manipulating content.

// Encrypt
Dim transform As ICryptoTransform = crypto.CreateEncryptor();
Dim memStream As New System.IO.MemoryStream;
Dim cryStream As New CryptoStream(memStream, transform, CryptoStreamMode.Write);
Dim text() As Byte = System.Text.Encoding.Unicode.GetBytes(plaintext);

cryStream.Write(text,0, text.Length)

Dim result() As Byte = memStream.ToArray

// Decrypt
Dim transform As ICryptoTransform = crypto.CreateDecryptor();
Dim memStream As New System.IO.MemoryStream;
Dim cryStream As New CryptoStream(memStream, transform, CryptoStreamMode.Write);

cryStream.Write(ciphertext,0, ciphertext.Length)

Dim result() As Byte = memStream.ToArray

Implementation: Python

There are some libraries in python that implementing DES algorithm.Each has different style and flavor. Here we use PyCrypto library as example. As Python is not strongly typed, we should not worry about the data type. However internally all operation is done in block so you might consider to use byte array.

The key and be an input from user or generated by you. Here, we have two example.

# Library
from Crypto.Cipher import DES
from Crypto import Random

key = b'eight byte key'
iv =

crypto =, MODE_CBC, iv)
# other option: MODE_ECB, MODE_CFB

Then we did something like this:

# Encrypt
result = crypto.encrypt(plaintext)

# Decrypt
result = crypto.decrypt(plaintext)


Social Share Buttons and Icons powered by Ultimatelysocial