Skip to content

Instantly share code, notes, and snippets.

@robindimyan
Created January 31, 2016 21:06
Show Gist options
  • Save robindimyan/6ec583ee5663f7e9ba2f to your computer and use it in GitHub Desktop.
Save robindimyan/6ec583ee5663f7e9ba2f to your computer and use it in GitHub Desktop.
int myfunction( int arg1, // [ebp+0x8]
char * arg2 // [ebp+0xc]
){
int a = 0; // mov DWORD PTR [ebp-0xc], 0x0
int len = strlen(arg2); // push DWORD PTR [ebp+0xc]
// call <strlen>
// mov DWORD PTR [ebp-0x14], eax ; saving the value returned from strlen()
for(int i=0; i<=len; i++) { // mov DWORD PTR[ebp-0x10], 0x0
// jmp addr2
// <addr1>:
if (arg2[i] == arg1) // mov eax, DWORD PTR [ebp+0xc]
// mov edx, DWORD PTR [ebp-0x10]
// add eax, edx
// movzx eax, BYTE PTR [eax]
// movsx eax, al
// cmp eax, DWORD PTR [ebp+0x8]
// jne addr2
a++; // add DWORD PTR [ebp-0xc], 0x1
} // add DWORD PTR [ebp-0x10], 0x1
// <addr2>:
// mov eax, DWORD PTR [ebp-0x10]
// cmp eax, [ebp-0x14]
// jne addr1
return a; // mov eax, DWORD PTR [ebp-0xc]
// leave
} // ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment