buffer-overflow

Consequences of this buffer overflow?

↘锁芯ラ 提交于 2019-11-30 11:03:08
So here I believe I have a small buffer overflow problem I found when reviewing someone else's code. It immediately struck me as incorrect, and potentially dangerous, but admittedly I couldn't explain the ACTUAL consequences of this "mistake", if any. I had written up a test app to demonstrate the error, but found (to my dismay) that it seems to run correctly regardless of the overflow. I want to believe that this is just by chance, but wanted some feedback to determine if my thinking were wrong, or if there truly is a problem here that just isn't showing its head in my test app. The problem

gdb showing different address than in code

左心房为你撑大大i 提交于 2019-11-30 09:53:15
I am trying to implement a buffer overflow attack and I need to know the address of my buffer that I am trying to overflow. The address that is displayed using GDB is different than if I just did this in the code: Exact code: #include<stdio.h> int main() { char buffer[20]; printf("%p\n", buffer); // 0xbffff320 return 0; } However, in gdb if I do: p &buffer I get: 0xbffff330 Why is there a difference and will it mess up my buffer overflow attack? I have ALSR and stack guard disabled. Thanks. EDIT 1: Even when I step through gdb and it encounters the print line, I get 0xbffff320 as the address

How to skip a line doing a buffer overflow in C

懵懂的女人 提交于 2019-11-30 08:22:30
问题 I want to skip a line in C, the line x=1; in the main section using bufferoverflow ; however, I don't know why I can not skip the address from 4002f4 to the next address 4002fb in spite of the fact that I am counting 7 bytes form <main+35> to <main+42> . I also have configured the options the randomniZation and execstack environment in a Debian and AMD environment, but I am still getting x=1; . What it's wrong with this procedure? I have used dba to debug the stack and the memory addresses:

How are buffer overflows used to exploit computers?

你离开我真会死。 提交于 2019-11-30 06:23:29
问题 How are buffer overflows used to exploit computers? How is one able to execute arbitrary code simply by causing stack or heap overflows? I understand that portions of the programs memory are overwritten that aren't supposed to be, but I don't see how this leads to one executing their own code. Also, must the 3rd party's malicious code be written in the target processors assembly language? 回答1: This is the most widely known document on the subject: Smashing the Stack for Fun and Profit However

Format String Attack

旧街凉风 提交于 2019-11-29 22:01:07
问题 I have a small C program to be exploited. And I also understood the logic behind the attack to be performed. However, as much as I try, it is just not working for me. #include <stdio.h> #include <stdlib.h> #define SECRET1 0x44 #define SECRET2 0x55 int main(int argc, char *argv[]) { char user_input[100]; int *secret; int int_input; int a, b, c, d; /* other variables, not used here.*/ /* The secret value is stored on the heap */ secret = (int *) malloc(2*sizeof(int)); /* getting the secret */

How can I invoke buffer overflow?

无人久伴 提交于 2019-11-29 20:21:52
I got a homework assignment asking me to invoke a function without explicitly calling it, using buffer overflow. The code is basically this: #include <stdio.h> #include <stdlib.h> void g() { printf("now inside g()!\n"); } void f() { printf("now inside f()!\n"); // can only modify this section // cant call g(), maybe use g (pointer to function) } int main (int argc, char *argv[]) { f(); return 0; } Though I'm not sure how to proceed. I thought about changing the return address for the program counter so that it'll proceed directly to the address of g(), but I'm not sure how to access it. Anyway

Consequences of this buffer overflow?

喜你入骨 提交于 2019-11-29 17:01:46
问题 So here I believe I have a small buffer overflow problem I found when reviewing someone else's code. It immediately struck me as incorrect, and potentially dangerous, but admittedly I couldn't explain the ACTUAL consequences of this "mistake", if any. I had written up a test app to demonstrate the error, but found (to my dismay) that it seems to run correctly regardless of the overflow. I want to believe that this is just by chance, but wanted some feedback to determine if my thinking were

gdb showing different address than in code

淺唱寂寞╮ 提交于 2019-11-29 15:29:04
问题 I am trying to implement a buffer overflow attack and I need to know the address of my buffer that I am trying to overflow. The address that is displayed using GDB is different than if I just did this in the code: Exact code: #include<stdio.h> int main() { char buffer[20]; printf("%p\n", buffer); // 0xbffff320 return 0; } However, in gdb if I do: p &buffer I get: 0xbffff330 Why is there a difference and will it mess up my buffer overflow attack? I have ALSR and stack guard disabled. Thanks.

Buffer Overflow not working

北战南征 提交于 2019-11-29 14:06:47
I was trying to do a buffer overflow (I'm using Linux) on a simple program that requires a password. Here's the program code: #include <stdio.h> #include <stdlib.h> #include <string.h> int check_authentication(char *password){ int auth_flag = 0; char password_buffer[16]; strcpy(password_buffer, password); if(strcmp(password_buffer, "pass1") == 0) auth_flag = 1; if(strcmp(password_buffer, "pass2") == 0) auth_flag = 1; return auth_flag; } int main(int argc, char **argv) { if(argc < 2){ printf("\t[!] Correct usage: %s <password>\n", argv[0]); exit(0); } if(check_authentication(argv[1])){ printf("

Which stream does “stack smashing detected” message get printed to?

隐身守侯 提交于 2019-11-29 12:13:22
Consider the following very basic program, which has appeared in many forms on other questions here. #include <string.h> int main() { char message[8]; strcpy(message, "Hello, world!"); } On my system, if I put this in a file called Classic.c , compile it with no special flags and run it, I get the following output. $ gcc -o Classic Class.c $ ./Classic *** stack smashing detected ***: ./Classic terminated Aborted (core dumped) Normally, program output goes to stderr or stdout , so I expected that the following would produce no output. ./Classic 2> /dev/null > /dev/null However, the output is