704 questions
2 votes
2 answers
225 views
Why do we cast char* to int(*)() when executing shellcode in C?
I'm learning about shellcode execution in C and I've seen two different approaches. I understand the first one is for exploitation, but I'm confused about the type casting. Approach 1: Stack Overflow ...
4 votes
0 answers
152 views
Segmentation fault on a x86-64 push instruction (after execve syscall returns -ENOSYS depending on what value was pushed)
I am executing shell-code in executable stack memory: xor rax,rax ; push rax ; mov rbx,0x68732f2f6e69622f ; push rbx mov rdi,rsp ; ...
4 votes
1 answer
202 views
How can I exploit Buffer Overflow on x86-64 Linux?
I made a simple vulnerable program greet.c: #include <stdio.h> #include <string.h> int main (int argc, char **argv) { char buf[32]; strcpy(buf, argv[1]); printf("%s\n"...
1 vote
1 answer
302 views
Shellcode using chmod in x86-64 linux assembly
Sorry if this sounds like a stupid question but I am new to shellcoding ... Can anyone tell me how to reduce the number of instructions in this assembly code leveraging the chmod (90) syscall: xor ...
1 vote
1 answer
174 views
Shellcode to pop a shell without containing the sequence "sh" or "hs"
I am doing a cybersecurity challenge and need to open a shell using shellcode. The usual shellcode is \x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\x50\x52\x51\...
0 votes
1 answer
95 views
How to properly load and pass a file path to open syscall in x86_64 assembly?
I'm trying to write a shellcode in x86_64 assembly that opens a file located at /challenge/flag using the open syscall. However, my implementation doesn't seem to work as intended. The path seems to ...
-4 votes
1 answer
110 views
CreateRemoteThread failed 5
CreateRemoteThread() fails with error 5 when calling inject_param->allocate() in inject_begin(). Comment it and CreateRemoteThread() is OK. I dont know why. The target platform is 64-bit. #include &...
0 votes
0 answers
149 views
Failed to construct a Palindromic Shellcode
To exploit the buffer overflow vulnerability in a challenge program, I need to craft a payload that satisfies a palindrome check and executes arbitrary code. This requires creating a palindromic ...
3 votes
2 answers
230 views
Segfault shellcode in main C
I'm trying to create a main. I compiled my code with: $ gcc -g3 -o shellcode shellcode.c But I always get a Segmentation fault (core dumped) Using GDB, I see that the first instruction is executed ...
5 votes
2 answers
131 views
Segmentation fault in C shellcode x64
I am learning about shellcode development in C with an example from here. I can compile the assembly code and get de opcodes, also I can run successfully the ELF compiled with NASM, but I get a ...
2 votes
0 answers
154 views
Call dlopen by executing shellcode in linux x86_64
I'm trying to play around with asm and shellcode, my target is to manage to dlopen a custom library. I've created a code in C that calls a fake dlopen method, compiled it and used objdump to extract ...
1 vote
0 answers
99 views
VirtualAllocEx Returns Memory Marked as MEM_FREE/PAGE_NO_ACCESS
I am writing x64 assembly code to invoke VirtualAllocEx win32 API (as part of process injection lab, so I am injecting into explorer.exe) and seeing unusual (to me) behavior. The documentation states ...
2 votes
0 answers
71 views
How to reference data added to the end of position independent shellcode in Windows x86
I have a C program that parses the PEB and gets kernel32.dll and then with a custom GetProcAddress it gets the address to LoadLibrary. After that I get the address of MessageBoxA. My goal is to ...
0 votes
0 answers
78 views
shellcode simulating buffer overflow
Here is a snippet of a shellcode that i have from a course i am taking it claims simulate a buffer overflow I am not clear how it works section .data payload db 'This is the payload of the exploit....
0 votes
0 answers
191 views
I am trying to create a reverse shell using ROP chains by injecting the objdump from the .obj but it does not connect
So basically the problem is as follows: I have written a ROP chain that calls shellcode from the stack. The ROP chain has also been tested with simple shellcode to call a calculator and it works. This ...