Sunday, January 24, 2010

Blending C and Assembly (nasm)

First difference between 'extern' and 'global'.
extern : Assure assembler that the function will is defined someplace else.
global : Any procedure marked global can be referenced from anywhere.
===========================================================================
blank.asm ( name of file )

; simply returns 0
GLOBAL _blank
section .text
_blank:
mov eax, 0
ret

===========================================================================
test.c ( name of file )

#include

extern int _blank();

int
main(){
int ret = 5;
ret = _blank();
printf("Ret is [%d]\n",ret);
return 0;
}

===========================================================================

$ nasm -felf blank.asm -> outputs -> blank.o
$ gcc -o test test.c blank.o
$ ./test
Ret is [0]

Friday, January 15, 2010

Install pydbg and paimei under windows

01. Get python 2.4.4 for windows.(http://www.python.org/download/releases/2.4.4)
-> Run the installer and install python ( say to c:\python24 )

02. Get ctypes for this version. (http://downloads.sourceforge.net/ctypes/ctypes-1.0.1.win32-py2.4.exe?modtime=1161376216&big_mirror=0)
-> Install by double clicking (Follow the leads given by the installer.)

03. Download paimei. ( http://www.openrce.org/downloads/download_file/208 )
-> ( say your paimei file is PaiMei-1.1-win32.exe )

04. Get source from http://paimei.googlecode.com/svn/trunk
-> put it under c:\paimei_src ( just a folder of your choice )

05. copy (step 03) PaiMei-1.1-win32.exe under "c:\paimei_src"\installer

06. run c:\paimei_src\__install_requirements.py
->
/* Actual output of __install_requirements.py */
looking for PaiMei -> PyDbg ... FOUND
looking for PaiMei -> PIDA ... FOUND
looking for PaiMei -> pGRAPH ... FOUND
looking for PaiMei -> Utilities ... FOUND

Install PaiMei framework libraries to Python site packages? y

...
/* end */

07. Thats it!
-> echo "from pydbg import *" >> test.py
-> python test.py

it should run without any errors.


... And its very fitting to say here

Happing Hacking...

Monday, January 11, 2010

Map partition from a disk for mounting

/* Say there is a disk image(disk_image.img) where individual partitions needs
to be mounted */

# file disk_image.img
disk_image.img : x86 boot sector; partition 4: ID=0x4, active, starthead 1, startsector 32, 8160 sectors, extended partition table (last)\011

/* simple matter of using kpartx utility */
# kpartx -av disk_image.img

/* the output will be ... */
loop1p1 : < string showing start - ends >
...

/* mount the required partition */
# mount /dev/mapper/loop1p1 /mnt/ -o loop

/* clean up */
# kpartx -d disk_image.img

Wednesday, January 6, 2010

Working with Eclipse and pydev under windows

1. Get Python from "http://www.python.org/ftp/python/3.1.1/python-3.1.1.msi"

2. Get Eclipse from "http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR1/eclipse-cpp-galileo-SR1-win32.zip"

3. Extract both to your favorite folder.

4. Launch eclipse and goto Help->Install Software Updates

4a. Input "http://pydev.org/updates" Where it asks to "select for site". And
follow the instructions. Eclipse will restart to reflect the new changes.

5. Under Eclipse Goto Windows->Preference

5a. Under this goto Pydev->"Interpreter-Python"

5b. Click the "New" button on the top left and input the path to your python
interpreter(python.exe) and click apply.