stack-smash

pragma pack(push) without corresponding pop leads to stack smashing

好久不见. 提交于 2021-01-28 12:26:21
问题 I used #pragma pack(push, 2) at the beginning of a struct in a header file but forgot the corresponding #pragma pack(pop) . After including this header file, I included fstream. On creating an ofstream object, I am seeing stack smashing. Details of the exact scenario and code are as follows. I was following a C++ course and had written a code for the project. My program was crashing due to stack smashing. I tried to look for any obvious overflow errors but couldn't find any. I changed almost

what is stack smashing (C)?

我的未来我决定 提交于 2020-05-25 05:13:11
问题 Code: int str_join(char *a, const char *b) { int sz =0; while(*a++) sz++; char *st = a -1, c; *st = (char) 32; while((c = *b++)) *++st = c; *++st = 0; return sz; } .... char a[] = "StringA"; printf("string-1 length = %d, String a = %s\n", str_join(&a[0],"StringB"), a); Output: string-1 length = 7, char *a = StringA StringB *** stack smashing detected **** : /T02 terminated Aborted (core dumped) I don't understand why it's showing stack smashing ? and what is *stack smashing? Or is it my

Different Int values for the same value?

[亡魂溺海] 提交于 2019-12-13 03:13:24
问题 I ran into an integer overflow problem, which I managed to solve, but only by trial and error. Since it's an integer overflow problem, I've wrote some code to print out the buffer. The beginning of the buffer is the address where array[0] is stored. Then, I started to pass MAX_INT and MIN_INT values to the program. I've noticed that when I passed MIN_INT value to argv[1], it overwrote the begining of the buffer. so I passed MIN_INT+1 value, and noticed that it overwrote the second address of

Buffer Overflow - SegFaults in regular user

依然范特西╮ 提交于 2019-12-10 06:31:33
问题 Below is my code, both the vulnerable program (stack.c) and my exploit (exploit.c). This code works on a pre-packaged Ubuntu 9 that the prof sent out for windows users (I had a friend test it on his computer), but on Ubuntu 12 that I run on my iMac, i get segfaults when I try and do this in a normal user. here's stack: //stack.c #include <stdio.h> int bof(char *str) { char buffer[12]; //BO Vulnerability strcpy(buffer,str); return 1; } int main(int argc, char* argv[]) { char str[517]; FILE

Buffer Overflow - SegFaults in regular user

我的梦境 提交于 2019-12-05 14:15:55
Below is my code, both the vulnerable program (stack.c) and my exploit (exploit.c). This code works on a pre-packaged Ubuntu 9 that the prof sent out for windows users (I had a friend test it on his computer), but on Ubuntu 12 that I run on my iMac, i get segfaults when I try and do this in a normal user. here's stack: //stack.c #include <stdio.h> int bof(char *str) { char buffer[12]; //BO Vulnerability strcpy(buffer,str); return 1; } int main(int argc, char* argv[]) { char str[517]; FILE *badfile; badfile = fopen("badfile","r"); fread(str, sizeof(char),517, badfile); bof(str); 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

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

戏子无情 提交于 2019-11-28 06:09:02
问题 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