使用阿里云服务器搭建一道BROP的pwn题

搭建题目环境

题目:HCTF2016 brop

C代码如下:

#include <stdio.h>
#include <unistd.h>
#include <string.h>

int i;
int check();

int main(void) {
    setbuf(stdin, NULL);
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);

    puts("WelCome my friend,Do you know password?");
        if(!check()) {
            puts("Do not dump my memory");
        } else {
            puts("No password, no game");
        }
}

int check() {
    char buf[50];
    read(STDIN_FILENO, buf, 1024);
    return strcmp(buf, "aslvkm;asd;alsfm;aoeim;wnv;lasdnvdljasd;flk");
}
  1. 在服务器上编译:
gcc -z noexecstack -fno-stack-protector -no-pie brop.c
  1. 在服务器上安装socat和screen
apt-get install socat
apt-get install screen
  1. 创建run.sh脚本,将如下代码粘贴
#!/bin/sh
while true; do
        num=`ps -ef | grep "socat" | grep -v "grep" | wc -l`
        if [ $num -lt 5 ]; then
                socat tcp4-listen:10001,reuseaddr,fork exec:./a.out &
        fi
done
  1. 赋予其权限
chmod run.sh 777
  1. 使用screen命令后台运行run.sh脚本
screen sh run.sh
//然后先按crtl+a, 在按d切出来,测试服务器能否访问
nc 127.0.0.1 10001
//如果本地可以的话,再测试远程可不可以。
//我这边是阿里云的服务器,远程连不通
  1. 配置阿里云安全组规则

将授权对象修改为0.0.0.0/0,则所有ip均可访问,如担心安全问题,可设置为你本地的出口ip

  1. 之后本地就可以连通服务器,开始愉快的做题了

    //我的配置环境是10002端口,如按上述教程,请nc 10001端口
发布了285 篇原创文章 · 获赞 81 · 访问量 27万+

猜你喜欢

转载自blog.csdn.net/AcSuccess/article/details/104513555