【pwnable.kr】 shellshock

pwnable从入门到放弃,第五题。

ssh [email protected] -p2222 (pw:guest)

这题主要涉及了一个关于bash的CVE漏洞。

首先还是下载源代码审计一下,shellshock.c

#include <stdio.h>
int main(){
    setresuid(getegid(), getegid(), getegid());
    setresgid(getegid(), getegid(), getegid());
    system("/home/shellshock/bash -c ‘echo shock_me‘");
    return 0;
}

首先是一个关于可执行程序权限的问题,就是关于uid和gid的。

先看一下各个文件的权限

首先启动时,用户是shellshock权限,也就是other权限,这样的话对flag还是不可读的。linux开关机熟练选手根本就没懂啥意思。

后来发现shellshock这个可执行文件对group是具有特殊权限w的,这就意味着egid是属于shellshock_pwn的,这个权限很高,对flag文件是可读的,这也就涉及到了linux可执行文件权限继承和赋予问题。

我查阅了一下《C和C++安全编码》书中讲权限部分的,这相当于设置了egid,因此在代码中setreuid中设置的各uid均是预置的高权限,即egid——shellshock_pwn,因此这个可执行文件在执行到system一行时,就已经是具有shellshock_pwn组权限的程序了。

bash也是用这个组权限在打开,所以对flag是可读的。

解决了权限问题,就可以考虑如何代码执行了,这个破壳漏洞是可以作为一个本地提权漏洞使用,参考金山毒霸在freebuf上的漏洞分析贴,:http://www.freebuf.com/articles/system/45390.html

可以使用上面提到了poc,

env x=‘() { :;}; echo vulnerable‘ bash -c "echo this is a test"

可验证这个漏洞在./bash上是存在的:

将echo v...‘ 换成想执行的命令 bash -c "cat ./flag"‘

而./ bash -c "echo this is a test" 换成./shellshock

偷个懒,破壳漏洞明天再看。

时间: 2024-08-02 02:51:26

【pwnable.kr】 shellshock的相关文章

【pwnable.kr】bof

pwnable从入门到放弃,第三题. Download : http://pwnable.kr/bin/bofDownload : http://pwnable.kr/bin/bof.c Running at : nc pwnable.kr 9000 很简单的一道栈溢出题目. 依然先读代码: #include <stdio.h> #include <string.h> #include <stdlib.h> void func(int key){ char overfl

【pwnable.kr】leg

pwnable从入门到放弃第八题. Download : http://pwnable.kr/bin/leg.cDownload : http://pwnable.kr/bin/leg.asm ssh [email protected] -p2222 (pw:guest) 先下载这两个文件:leg.c #include <stdio.h> #include <fcntl.h> int key1(){ asm("mov r3, pc\n"); } int key2

【pwnable.kr】 asm

一道写shellcode的题目, #include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/mman.h> #include <seccomp.h> #include <sys/prctl.h> #include <fcntl.h> #include <unistd.h> #define LENGTH 128 void sa

【pwnable.kr】 codemap

pwnable新的一题. download: http://pwnable.kr/bin/codemap.exe ssh [email protected] -p2222 (pw:guest) 这道题虽然是在pwnable下,但是是一道逆向题... //前web狗膜一发二进制大佬 根据提示,需要查看 0x403E65 运行时,寄存器 EAX,EBX 的内容. 先不考虑运行的内容,先看程序.首先这个程序没有加壳,直接可以用ida查看内容. 然后可以看到程序的框架,在main函数中,默默按下F5..

【pwnable.kr】 unlink

pwnable.kr 第一阶段的最后一题! 这道题目就是堆溢出的经典利用题目,不过是把堆块的分配与释放操作用C++重新写了一遍,可参考<C和C++安全编码一书>//不是广告 #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct tagOBJ{ struct tagOBJ* fd; struct tagOBJ* bk; char buf[8]; }OBJ; void

【pwnable.kr】 flag

pwnable从入门到放弃 第四题 Download : http://pwnable.kr/bin/flag 下载下来的二进制文件,对着它一脸懵逼,题目中说是逆向题,这我哪会啊... 用ida打开看一下源代码,居然没有main函数. 继续懵逼. 对, 又一次看了别人的题解,居然是加壳的,怪不得图片就是个壳,我哪会砸壳啊??? 还好有工具,轮子大法好,用strings命令发现程序有许多"UPX"字符串,是UPX壳. 在GitHub上找了一个UPX壳砸壳自动化工具: https://gi

【pwnable.kr】blackjack

又一道pwnable nc pwnable.kr 9009 读题找到源代码在:http://cboard.cprogramming.com/c-programming/114023-simple-blackjack-program.html 第一反应是源代码这么长,还不如先玩玩看. 首先,看一下游戏规则发现和21点游戏是一样的,可能国外就叫blackjack吧. 每次,让游戏中下注,然后和电脑比赛,下注的金额不能超过所持有的金额. 这尼玛发牌函数也是随机的,就算你运气再好,算法再牛,想挣100w

【pwnable.kr】 mistake

又一道pwnable,我还没放弃.. ssh [email protected] -p2222 (pw:guest) 源代码如下: #include <stdio.h> #include <fcntl.h> #define PW_LEN 10 #define XORKEY 1 void xor(char* s, int len){ int i; for(i=0; i<len; i++){ s[i] ^= XORKEY; } } int main(int argc, char*

【pwnable.kr】 uaf

目测是比较接近pwnable的一道题.考察了uaf(use after free的内容),我觉得说白了就是指针没有初始化的问题. ssh [email protected] -p2222 (pw:guest) 先看一下代码 #include <fcntl.h> #include <iostream> #include <cstring> #include <cstdlib> #include <unistd.h> using namespace