Nebula level03

http://exploit-exercises.com/nebula/level03


Check the home directory of flag03 and take note of the files there.
There is a crontab that is called every couple of minutes.
To do this level, log in as the level03 account with the password level03 . Files for this level can be found in /home/flag03.

Listing of the /home/flag03 looks like this:

$ ls
writable.d/ writeable.sh

After reading writeable.sh you’ll know that it basically executes any file within writeable.d/ with ulimit -t 5 limitation and then removes it.
The first thing that popped to my mind is to just try execute /bin/getflag but that didn’t work (technically it worked but you need to redirect your output).

However the easiest way to get the flag here is to write a little C wrapper for executing /bin/getflag and set SUID bit on the binary. (The way SUID works, basically, is that it lets the user run programs with the privileges of the owner of a file; So here the owner is the process that actually compiled it and SUID let us run it).

Source code of the wrapper:

#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
    system("/bin/getflag");
    return 0;
}


Next I created the file under writeable.d/ directory called foobar with following line

 gcc /tmp/getflag.c -o getflag && chmod +s getflag 

and waited couple of minutes for cron to do its job. After that you just need to run /home/flag03/getflag. Boom goes the dynamite.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值