Thursday, March 29, 2012

Android Programming 101

1. Install Eclipse
2. Install the SDK: http://developer.android.com/sdk/installing.html
3. Install the ADT Plugins for Eclipse: http://developer.android.com/sdk/eclipse-adt.html#installing

4. You should see an Android button in you Eclipse menu. Click -> open Android Virtual Device Manger

5. Press New button to create a new Android Virtual Device (AVD)

6. Start your AVD

7. Open a shell, type $ which adb 
if you didn't see the adb bin file path, you need to add the SDK tools path to the $PATH environment variable. 
Add 
export PATH=/Users/username/Desktop/android-sdk-macosx/platform-tools:$PATH
to the ~/.profile 

8. $adb devices
you should see the list of available devices connected to the machine including the AVD we just started. 

9. $adb shell
It will start a shell which running in your device. You can run commands in the shell. 

10. Some interesting commands in Android Shell:
# id // shows username
# su // change to root when your device is rooted.
# logcat // shows the system log message
# cd /sdcard // this is the sdcard directory. Mounted from /mnt/sdcard. For emulator, you specify the size. when you create the new Android Virtual Device.
e.g. if you take a picture, the picture should be in the file /sdcard/DCIM/
if you want to copy something from your local machine to device, you could run $adb push filename. Then the file will saved in the sdcard directory
If you type run #mount in your Android device, you will see some block will be ready only. For example, the /system directory is read only. 
/device/block/mtdblock0 /system yaffs2 ro 0 0

11. you will find out a lot of Linux commands cannot run in Android shell, you can install busybox to solve this problem

12. If your phone is locked by a password, you could login from command:
$adb shell login <password>

13. if you want to get a file from android device, you could run:
$adb pull /mnt/sdcard/filename

14. if you want to install an .apk app to the android
$ adb install app.apk

15. All the installed application are stored at /data/app

16. if you want to debug the crashed application
$ adb logcat | tee logcat.file

Tuesday, March 27, 2012

QEMU Start

$ qemu-system-i386 -m 512 -hda winxpsp2.img -net user -net nic

-m 512 // memory size
-hda winxpsp2.img // this is the image for booting, plays same function as the hard drive
-net user -net nice // enables the networking


Create a QEMU disk image

http://en.wikibooks.org/wiki/QEMU/Images

1. create a blank disk image
qemu-img create -f qcow2 winxp.img 3G

2. install a guest OS into the bank disk image (from ISO file or CD-ROM)
qemu -m 256 -hda winxp.img -cdrom winxpsp2.iso -boot d
or
qemu -m 256 -hda winxp.img -cdrom /dev/cdrom -boot d

more info:
http://en.wikibooks.org/wiki/QEMU/Images

Install QEMU

Install QEMU on Linux:
1. Download the source code
wget http://wiki.qemu.org/download/qemu-1.0.1.tar.gz
or
http://wiki.qemu.org/Download


2. Configure the source code


./configure [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]
The prefix argument specifies where to install QEMU; without it QEMU will install to /usr/local by default. Since you do not have root access on CLIC machines, set PFX to be inside your home directory, such as $PWD/install. The target-list argument simply slims down the architectures QEMU will build support for.


3. Run make && make install
You may also install QEMU on your own machine. On Linux, you may need to install the SDL development libraries to get a graphical VGA window. On Debian/Ubuntu, this is the libsdl1.2-dev package. You can find out more information about the version of QEMU we're using here.

Other links: 
http://www.cs.columbia.edu/~junfeng/12sp-w4118/tools.html
http://jianggmulab.blogspot.com/search/label/qemu

If you have some problems for make, you may want to install some libraries before do make. 

Install QEMU on Mac:
I also tried to install it in Mac OS 10.7, and there are some errors for $make
But you always could install it from:
$ sudo port install qemu
or you can install by homebrew
Mac (Homebrew)brew install qemu


$ which qemu-system-i386
/opt/local/bin/qemu-system-i386

$ qemu-
qemu-ga             qemu-io             qemu-system-i386
qemu-img            qemu-nbd            qemu-system-x86_64


Saturday, March 24, 2012

translate assembly to machine code

On Linux Machine:
1. write your assembly code into code.S
2. compile your code: $ gcc -c code.S
3. use objdump to see the binarry code: $ objdump -d code.o 

Wednesday, March 14, 2012

Firefox Extension Development Tutorial

http://www.rietta.com/firefox/Tutorial/overview.html

Tuesday, March 13, 2012

Create mailing list


-bash-4.1$ sudo vim /etc/aliases  

-bash-4.1$ sudo postalias /etc/aliases



More: http://linuxgazette.net/issue72/teo.html

Friday, March 9, 2012

Security of extension, Addons, Plugins

Difference of them:
http://forums.mozillazine.org/viewtopic.php?f=38&t=1067295

Abuse the Firefox extension
http://malerisch.net/docs/defcon17/roberto_suggi_liverani_nick_freeman_abusing_firefox_extensions_defcon17.pdf
http://www.youtube.com/watch?v=vffa4FshXWY

Plugins
http://www.quora.com/Why-didnt-Firefox-implement-multi-process-architecture

Firefox Heap Spray:
http://static.usenix.org/event/sec09/tech/full_papers/ratanaworabhan.pdf

Chrome Extension architecture:
http://www.adambarth.com/papers/2010/barth-felt-saxena-boodman.pdf

Wednesday, March 7, 2012

Remote desktop access of Mac

Android malware site

http://contagiodump.blogspot.com/