Merged from upstream.

pull/26/head
Moltivie 2019-12-03 18:32:09 +01:00
commit 41a9af70fa
1 changed files with 90 additions and 1 deletions

View File

@ -1056,6 +1056,95 @@ Reverse Engineering
New RE tool developed by NSA with the same feature as IDA
* Compiling & running ASM code:
You can convert ASM functions from assembly and run them as C functions like the following:
`asm4.S`
```asm
.intel_syntax noprefix
.global asm4
asm4:
push ebp
mov ebp,esp
push ebx
sub esp,0x10
mov DWORD PTR [ebp-0x10],0x27d
mov DWORD PTR [ebp-0xc],0x0
jmp label2
label1:
add DWORD PTR [ebp-0xc],0x1
label2:
mov edx,DWORD PTR [ebp-0xc]
mov eax,DWORD PTR [ebp+0x8]
add eax,edx
movzx eax,BYTE PTR [eax]
test al,al
jne label1
mov DWORD PTR [ebp-0x8],0x1
jmp label3
label4:
mov edx,DWORD PTR [ebp-0x8]
mov eax,DWORD PTR [ebp+0x8]
add eax,edx
movzx eax,BYTE PTR [eax]
movsx edx,al
mov eax,DWORD PTR [ebp-0x8]
lea ecx,[eax-0x1]
mov eax,DWORD PTR [ebp+0x8]
add eax,ecx
movzx eax,BYTE PTR [eax]
movsx eax,al
sub edx,eax
mov eax,edx
mov edx,eax
mov eax,DWORD PTR [ebp-0x10]
lea ebx,[edx+eax*1]
mov eax,DWORD PTR [ebp-0x8]
lea edx,[eax+0x1]
mov eax,DWORD PTR [ebp+0x8]
add eax,edx
movzx eax,BYTE PTR [eax]
movsx edx,al
mov ecx,DWORD PTR [ebp-0x8]
mov eax,DWORD PTR [ebp+0x8]
add eax,ecx
movzx eax,BYTE PTR [eax]
movsx eax,al
sub edx,eax
mov eax,edx
add eax,ebx
mov DWORD PTR [ebp-0x10],eax
add DWORD PTR [ebp-0x8],0x1
label3:
mov eax,DWORD PTR [ebp-0xc]
sub eax,0x1
cmp DWORD PTR [ebp-0x8],eax
jl label4
mov eax,DWORD PTR [ebp-0x10]
add esp,0x10
pop ebx
pop ebp
ret
```
`asm4.c`
```c
#include<stdio.h>
extern int asm4(char* s);
int main(){
char *str = "picoCTF_d899a";
printf("%X", asm4(str));
return 0;
}
```
`bash`
```bash
$ gcc -m32 -o a asm4.c asm4.S
$ ./a
```
PowerShell
-------------
@ -1428,4 +1517,4 @@ OpenToAll - https://opentoallctf.github.io/
[Responder]: https://github.com/SpiderLabs/Responder
[Responder.py]: https://github.com/SpiderLabs/Responder
[International Code of Signals Maritime]: https://en.wikipedia.org/wiki/International_Code_of_Signals
[maritime flags translator]: https://www.dcode.fr/maritime-signals-code
[maritime flags translator]: https://www.dcode.fr/maritime-signals-code