how to assemble and link:
nasm -f elf32 -o <filename>.o <filename>.asm
ld -m elf_i386 -o <filename> <filename>.o
template code (hello world):
section .text
global _start
<?php | |
// Taken from : https://gist.github.com/ammarfaizi2/ac9639359a1f315f0aedc6a4bbbc60fb | |
$strings = [ | |
"/bin/sh" | |
// "Enter Password: ", | |
// "Enter Password 2: ", | |
// "Enter Password 3: ", | |
// "Wrong Password!\n", |
// solusi yang saya tulis di : | |
// https://stackoverflow.com/questions/59536438/calling-x86-local-function-using-shellcode | |
#include <stdio.h> | |
#include <string.h> | |
void redirect() { | |
FILE *out = fopen("redirect.txt", "w"); | |
fprintf(out, "REDIRECT WORKED"); | |
fclose(out); |
int timings[64*N]; | |
int main(void) | |
{ | |
int i; | |
__asm__ __volatile__ ( | |
"lea edx, [timings] \n\t" | |
"rdtsc \n\t" | |
".rept 32 \n\t" |