now we will share how to inline assembly programing language in C programing . This tutorial's made by Mywisdom, so let's see the example here :
code :
mov al, 1 : move 1 to the register al is a condition called syscall number 1 (exit) .
xor ebx, ebx : exclusive or ebx with the result becomes zero -> the terms exit syscall .
int 80h : is the interrupt number in the typical linux syscall to execute (eg. if the DDoS int 21h).
for gcc inline, asm code must be convert first from intel asm to asm AT&T as follows:
AT&T;
code :
code :
code :
code :
#include <stdio.h>
#v3n0m.c
#coding by: mywisdom
int main()
{
__asm__ ("xor %eax, %eax\n\t"
"mov $0x1,%al\n\t"
"xor %ebx,%ebx\n\t"
"int $0x80");
}
example, suppose there is assembly code using the syscall number 1 (exit function):
code :
[SECTION .text]
global _start
_start:
xor eax, eax
mov al,1
xor ebx,ebx
int 0x80
explanation of the asm code above :
xor eax, eax : means exclusive or eax eax with the result eax is 0 (zero) -> syscall exit requirement.
xor eax, eax : means exclusive or eax eax with the result eax is 0 (zero) -> syscall exit requirement.
xor ebx, ebx : exclusive or ebx with the result becomes zero -> the terms exit syscall .
int 80h : is the interrupt number in the typical linux syscall to execute (eg. if the DDoS int 21h).
for gcc inline, asm code must be convert first from intel asm to asm AT&T as follows:
AT&T;
code :
xor %eax, %eax
mov $0x1,%al
xor %ebx,%ebx
int $0x80
then for make the inline asm code should start from this syntax:code :
__asm__ ( "type asm code here");
in this bellow are example insertion asm AT&T above to the C programing language eg. name v3n0m.c
code :
#include <stdio.h>
#v3n0m.c
#coding by: mywisdom
int main()
{
__asm__ ("xor %eax, %eax\n\t"
"mov $0x1,%al\n\t"
"xor %ebx,%ebx\n\t"
"int $0x80");
}
then compile the code above :code :
gcc -o v3n0m v3n0m.c
Testing program : run dg:(immediate exit, because call syscall exit)
./v3n0m