Last active
May 23, 2019 20:22
-
-
Save dnetguru/84665b349d6bfc10a1048a9af1a1a6c5 to your computer and use it in GitHub Desktop.
Sample ASM code to do a call and simple arithmatics for my R/E presentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defines the entry point for the console application. | |
// $author: @dNetGuru | |
// TConsole.cpp : Defines the entry point for the console application. | |
// | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include<time.h> | |
char message[] = "Hello World!\n"; | |
char format[] = "%d * 8 = %d\n"; | |
int __stdcall getrand(void) | |
{ | |
__asm | |
{ | |
xor eax, eax | |
push eax | |
call time | |
push eax | |
call srand | |
call rand | |
xor edx, edx | |
mov ecx, 0x25 | |
idiv ecx | |
mov eax, edx | |
} | |
} | |
void __cdecl main(void) | |
{ | |
__asm | |
{ | |
call getrand | |
mov ebx, eax | |
shl eax, 3 | |
mov ecx, eax | |
push ecx | |
push offset message | |
call printf | |
add esp, 0x4 | |
pop ecx | |
push ecx | |
push ebx | |
push offset format | |
call printf_s | |
add esp, 0x10 | |
xor eax, eax | |
} | |
} | |
// by dNetGuru | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment