Вот шеллкод, который у меня в итоге получился:
Код: Выделить всё
shellcode = (
"\x48\x31\xf6" # xor rsi, rsi | create a null register in rsi
"\x48\x31\xd2" # xor rdx,rdx | create a null register in rdx
"\x56" # push rsi | push rsi in order to create null string terminator
"\x48\xbb\x2f\x62\x69\x6e\x2f\x63\x61\x74" # movabs rbx, 0x7461632f6e69622f | assign to rbx the value of /bin/cat
"\x53" # push rbx | and push the rbx value to the stack
"\x54" # push rsp | push the top stack pointer to the stack
"\x5f" # pop rdi | and pop it to the register rdi. which is the command argument in execve
"\x56" # push rsi | push rsi in order to create null string terminator
"\x48\xbb\x66\x6c\x61\x67\x2e\x74\x78\x74" # movabs rbx, 0x7478742e67616c66 | assign to rbx the value of flag.txt
"\x53" # push rbx | push the rbx value to the stack
"\x54" # push rsp | push the top stack pointer to the stack
"\x5e" # pop rsi | and pop it to the register rsi. which is the parameters argument in execve
"\x6a\x3b" # push 0x3b | then push the value of 0x3b due being the syscall number for execve in x86_64
"\x58" # pop rax | and then pop it in order to store it to rax register
"\x0f\x05" # syscall | proceed to do the syscall.
)
rdi (arg1 системного вызова): /bin/cat
rsi (arg2 системного вызова): flag.txt
С другой стороны, регистр rax должен иметь значение 0x3b, что является вызовом execve.
Я создал свой код на следующих веб-сайтах:
https://man7.org/linux/man-pages/man2/syscall.2.html
https ://man7.org/linux/man-pages/man2/execve.2.html
https://blog.rchapman.org/posts/Linux_S ... or_x86_64/
Любой помощь будет более чем желательна, спасибо.
Подробнее здесь: https://stackoverflow.com/questions/781 ... 4bit-linux