Questions tagged [buffer-overflow]

Usually occurs when you attempt to copy data into a buffer without checking for sufficient space, causing data to be overwritten in neighboring cells.

RAM is divided into memory cells with each cell capable of storing a single byte on it's own. Applications use different sizes of the same data type to fulfill their computational needs, which can vary between a single or multiple (arrays) or dynamically allocated (pointers). Problems usually arise when software developers employ the use of arrays or pointers without verifying the destination buffer has sufficient or adequate space.

char Target[10];
char Input[20];
strcpy( Target, Input); // 1st Parameter: Destination, 2nd Parameter: Data

The code listed above plus certain conditions can exhibit the buffer-overflow corruption. If the coder doesn't take the necessary precautions to validate target/input, it will result in data being fed into adjacent memory cells corrupting whatever contents is stored within them.

Such results can be devastating as they affect overall system integrity.

1483 questions
-3
votes
1 answer

Format string vulnerablity

I have the following code, and I need to make an input, on result get "Print me!" #include #define OF_MY_LIFE 0xdead int best_days = OF_MY_LIFE; int main(int argc, char * argv[]){ struct{ int* pbest_days; unsigned hereToHelp; char…
-3
votes
1 answer

Program doesnt output anything

I am currently buffer overflow with C. I am just a beginner so please be easy on me. int main( ) { char *name[2]; name[0] = "/bin/sh"; name[1] = NULL; execve(name[0], name, NULL); } This is the output I got: It seems when I compile and execute…
sctts-lol
  • 557
  • 5
  • 9
-3
votes
1 answer

Problems implementing clang -fno-stack-protector to compile code on Macbook Pro

I am trying to test a buffer overflow example. Below is my code that I am trying to compile with filename buffOVF.c : #include #include int main(void) { //stack corruption char buf2[16] = "overwriteme"; //slightly…
-3
votes
1 answer

Memory addresses

I am workin on Overthewire narnia2(ctf game). Currently I am learning how to use the gdb and I have a simple question. (gdb) x/200x $esp-0xac 0xffffd5a4: 0x08048534 0xffffd5c8 0xf7e5b7d0 0xffffd5c8 0xffffd5b4: 0xf7ffd920 0xf7e5b7d5 …
-3
votes
3 answers

C char array and \0

In C, if I initialize a char array like this: char lines[5]; memcpy((char *)line,"Hello",5) Then if I execute the following expression: line[6]='\0'; Would this cause buffer overflow? Thanks?
XIN LIU
  • 87
  • 1
  • 9
-3
votes
1 answer

C Stack Buffer Overflow

I am trying to replicate a stack buffer overflow. This is my code #include int main(int argc, char *argv[]) { char x[1]; gets(x); printf("%s\n", x); } I am compiling this on a 32 bit machine, which means each memory address is 4…
max_max_mir
  • 1,494
  • 3
  • 20
  • 36
-3
votes
1 answer

Aleph one code - buffer overflow

I got this code of aleph one: shellcode.h #if defined(__i386__) && defined(__linux__) #define NOP_SIZE 1 char nop[] = "\x90"; char shellcode[] = "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b" …
Elad Doocker
  • 197
  • 11
-3
votes
1 answer

Buffer Overflow won't work get Seg Fault

I try to get a Buffer Overflow to work. I have the following simple vulnerable Program: int main(int argc, char** argv) { char buffer[80]; strcpy(buffer,argv[1]); return 1; } With the following Program i want to get a Shell with an…
Kevin
  • 785
  • 2
  • 10
  • 32
-3
votes
1 answer

How to use buffer overflow exploit

I try to learn the buffer overflow exploit . i have this code : #include int read_req(FILE *p) { char buf[16]; int i; fgets(buf, 1024, p); i = atoi(buf); return i; } int main()…
saidmohamed11
  • 275
  • 5
  • 15
-3
votes
1 answer

Buffer overflow - The changes of variables

void go() { //{1} char buffer[2]; gets(buffer); //{2} cout << allow; } I tried to run the procedure above in 2 cases: -1st: I declare "int allow;' at position 1 -2nd: I declare "int allow;' at position 2 In both cases, when i…
user3425082
  • 129
  • 1
  • 2
  • 9
-3
votes
3 answers

function's return address is different from its supposed value, buffer overflow, HELP PLEASE

Good day everyone! I am trying to understand how buffer overflow works. Right now, I’m in the process of determining the address of a function’s return address which I’m supposed to change to perform a buffer overflow attack. I’ve written a simple…
ultrajohn
  • 2,527
  • 4
  • 31
  • 56
-3
votes
2 answers

accessing a function that is defined after main

I have a C source file that I'm not allowed to change and it is defined as follows: int main(int argc, char *argv[]) { //doing something return 0 } void __magic() { __asm__("jmp %esp"); } I do not use the fucntion __magic in my code,…
Lazybeem
  • 105
  • 6
-4
votes
1 answer

How can I allocate the right amount of memory to this?

This has somehow become susceptible to buffer overflow. Not sure why or how to fix it? ps. I am new to programming and any tips to improve the overall quality of the code would be greatly appreciated. #include #include #include…
roja
  • 11
  • 1
-4
votes
1 answer

Why too much data fails to overwrite instruction pointer?

Recently i was trying buffer overflow on a simple c code that has been shown in opensecuritytraining's exploit class 1. Here is the code #include char *secret ="hello"; void go_shell() { printf("This is go_shell\n"); } int…
-4
votes
2 answers

Buffer overflow in C with pointers

I am completely lost with this. I know I have to use a buffer overflow in order to get char 'c' to be the pointer address of ptr, but I have no idea how. /* * Task: Print out "Wecome to overflow!" * Setup: You need to first run the command below…
1 2 3
98
99