Tag: 缓冲区溢出

为什么缓冲区溢出不会影响此代码?

我有以下代码: int main(int argc, char *argv[]) { char ch[10]; printf(“String 10 max. :: “); gets( ch ); printf(“String: %s\n”, ch); return 0; } 当我使用”12345678″运行时,它运行良好。 奇怪的是当我用”123456789012345678901234567890″运行时! 第二个printf所有字符串(30个字符)打印到屏幕上。 为什么会这样? 为什么我的代码没有崩溃? 谢谢你的时间, 阿兹台克

Shellcode:执行2次execve()调用

我试图在汇编中编写shellcode。 我需要执行/usr/bin/killall命令和/usr/bin/wget命令。 我有两个命令在shellcode中使用execve()系统调用完美运行。 但是现在我想要将这两个结合起来,但这是不可能的,因为程序在执行第一个execve()调用时退出。 (来自execve()的手册页: execve()在成功时不返回)。 如何执行2次execve()调用? 或者是否有另一种方法可以从同一个shell代码中调用/usr/bin/killall和/usr/bin/wget ? 提前致谢并表示感谢!

如何从终端编译这个简单的shellcode c程序?

我试图使用ubuntu 12上的终端编译它: #include #include main() { /*declare argument array*/ char *args[2]; args[0] = “/bin/bash”; args[1] = NULL; execve(args[0], args, NULL); exit(0); } 我在http://www.securitytube.net/video/235上找到了这个例子,这也恰好是’Smashing the Stack for Fun and Profit’中使用的一个Aleph One。 我知道自那以后发生了很多变化。 在我使用的更简单的例子中: gcc -ggdb -mpreferred-stack-boundary = 2 -fno-stack-protector filename filename.c 其他时候我可能包括静态实用程序。 它一直在努力,直到我试图编译上面的C代码。 我从终端收到的消息是: ss@ss-laptop:~$ gcc -static -mpreferred-stack-boundary=2 -fno-stack-protector -o shell shell.c shell.c: In function ‘main’: […]

gcc是否在编译时重新排序局部变量?

我现在正在阅读(第二次)“黑客:剥削的艺术”并且偶然发现了一些事情。 本书提出了两种不同的方法来利用这两个类似的程序: auth_overflow和auth_overflow2 在第一个中,有一个像这样的密码检查function int check_authentication(char *password) { int auth_flag = 0; char password_buffer[16]; strcpy(password_buffer, password); … } 输入超过16个ASCII字符会将auth_flag的值更改为大于0的值,从而绕过检查,如此gdb输出所示: gdb$ x/12x $esp 0xbffff400: 0xffffffff 0x0000002f 0xb7e0fd24 0x41414141 0xbffff410: 0x41414141 0x41414141 0x41414141 0x00000001 0xbffff420: 0x00000002 0xbffff4f4 0xbffff448 0x08048556 password_buffer @ 0xbffff40c auth_flag @ 0xbffff41c 第二个程序反转了两个变量: int check_authentication(char *password) { char password_buffer[16]; int auth_flag = 0; strcpy(password_buffer, […]

缓冲区溢出无法正常工作

我试图在一个需要密码的简单程序上进行缓冲区溢出(我正在使用Linux)。 这是程序代码: #include #include #include 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 \n”, argv[0]); exit(0); } if(check_authentication(argv[1])){ printf(“\n-=-=-=-=-=-=-=-=\n”); printf(” Access granted.\n”); […]

缓冲区溢出攻击格式

通常我们都会看到基本的缓冲区溢出格式,它有: – NOPs + shellcode + return_address 为什么我们不使用, NOPs + return_address + shellcode? 我们将返回地址指向shellcode的开头? 我猜这是因为如果漏洞位于main()中,我们可能会尝试在堆栈段外写入数据。 我对吗? 如果我,那是唯一的原因吗? 哦,是的,我不是指使用return-to-libc,ptrace等的其他类型的攻击; 我只是想知道为什么最基本的缓冲区溢出攻击以第一种方式展示而不是第二种方式。

简单缓冲区溢出漏洞利用

我正在尝试编写一个非常简单的程序,突出显示如何使用缓冲区溢出漏洞绕过受密码保护的系统。 代码如下: #include #include int main(void) { char buff[15]; char tempbuff[15]; int pass = 0; printf(“\n Enter a password of length between 1 and 15 characters : \n”); gets(buff); //strcpy(“%s”,buff); printf(“\n Enter your password : \n”); gets(tempbuff); //strcpy(“%s”,tempbuff); if(strcmp(tempbuff, buff)) { printf (“\n Wrong Password \n”); } else { printf (“\n Correct Password \n”); pass […]

Valgrind不会检测缓冲区溢出

#include main() { char buf[8]; sprintf(buf,”AAAA%3s”,”XXssssssssXXXsssssXXX”); printf(“%s\n”,buf); } 我希望valgrind使用上面的代码检测缓冲区溢出。 但它不会报告任何错误或警告。 我需要为此启用任何特殊标志吗?

C中的缓冲区溢出

我试图在Mac OS X 10.6 64位上使用C编写一个简单的缓冲区溢出。 这是概念: void function() { char buffer[64]; buffer[offset] += 7; // i’m not sure how large offset needs to be, or if // 7 is correct. } int main() { int x = 0; function(); x += 1; printf(“%d\n”, x); // the idea is to modify the return address so that […]

粉碎堆栈example3.c混乱

文章可以在这里找到。 我正在阅读粉碎堆栈并发现自己被卡在example3.c上。 0x80004a3 : call 0x8000470 0x80004a8 : addl $0xc,%esp 0x80004ab : movl $0x1,0xfffffffc(%ebp) 0x80004b2 : movl 0xfffffffc(%ebp),%eax 作者指出我们想要从0x80004a8跳到0x80004b2并且这个跳转是8个字节; 作者如何确定这是8个字节? 我重新创建了代码并通过objdump发送它,发现它不是8个字节(我在64位机器上,但我确保使用32位编译): 8048452: e8 b5 ff ff ff call 804840c 8048457: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp) 804845e: 00 804845f: 8b 44 24 1c mov 0x1c(%esp),%eax 8048463: 89 44 24 04 mov %eax,0x4(%esp) […]