merrychap / shellen

:cherry_blossom: Interactive shellcoding environment to easily craft shellcodes
MIT License
891 stars 97 forks source link

fixed linux system call abi: rcx -> r10 #23

Closed f0rki closed 3 years ago

f0rki commented 3 years ago

fixes #22 but is still a bit ugly:

L:asm:x86_64 > sys open

╔════════╦══════╦═══════╦═══════════╦═══════╦═══════════╗
║ NAME   ║ R10  ║ RAX   ║ RDI       ║ RDX   ║ RSI       ║
╠════════╬══════╬═══════╬═══════════╬═══════╬═══════════╣
║ open   ║ -    ║ 0x02  ║ *filename ║ mode  ║ flags     ║
║ openat ║ mode ║ 0x101 ║ dfd       ║ flags ║ *filename ║
╚════════╩══════╩═══════╩═══════════╩═══════╩═══════════╝

L:asm:x86_64 > sys sendfile

╔══════════╦═══════╦══════╦════════╦═════════╦═══════╗
║ NAME     ║ R10   ║ RAX  ║ RDI    ║ RDX     ║ RSI   ║
╠══════════╬═══════╬══════╬════════╬═════════╬═══════╣
║ sendfile ║ count ║ 0x28 ║ out_fd ║ *offset ║ in_fd ║
╚══════════╩═══════╩══════╩════════╩═════════╩═══════╝

L:asm:x86_64 > sys mmap

╔════════╦═══════╦══════╦══════╦═════════╦═════════╦══════════╦═════╗
║ NAME   ║ R10   ║ RAX  ║ RDI  ║ RDX     ║ RSI     ║ R8       ║ R9  ║
╠════════╬═══════╬══════╬══════╬═════════╬═════════╬══════════╬═════╣
║ mmap   ║ flags ║ 0x09 ║ addr ║ prot    ║ len     ║ fd       ║ off ║
║ munmap ║ -     ║ 0x0b ║ addr ║ -       ║ len     ║ -        ║ -   ║
║ mremap ║ flags ║ 0x19 ║ addr ║ new_len ║ old_len ║ new_addr ║ -   ║
╚════════╩═══════╩══════╩══════╩═════════╩═════════╩══════════╩═════╝
merrychap commented 3 years ago

Thanks for your help. x86_64 syscalls ABI for Linux really was corrupted somehow. Also, it would be nice to set an order of registers because right now they are totally messed up :disappointed: Hope I will be able to find some time to fix it. Thanks again!