Nebula level04

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

This level requires you to read the token file, but the code restricts the files that can be read. Find a way to bypass it :)

To do this level, log in as the level04 account with the password level04 . Files for this level can be found in /home/flag04.

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

int main(int argc, char **argv, char **envp)
{
	char buf[1024];
	int fd, rc;

	if(argc == 1) {
		printf("%s [file to read]\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	if(strstr(argv[1], "token") != NULL) {
		printf("You may not access '%s'\n", argv[1]);
		exit(EXIT_FAILURE);
	}

	fd = open(argv[1], O_RDONLY);
	if(fd == -1) {
		err(EXIT_FAILURE, "Unable to open %s", argv[1]);
	}

	rc = read(fd, buf, sizeof(buf));

	if(rc == -1) {
		err(EXIT_FAILURE, "Unable to read fd %d", fd);
	}

	write(1, buf, rc);
}

首先先去/home/flag04目录下运行cat token 发现没有文件的读取权限。

只能使用上面源代码提供的flag04 程序来读取token文件, 但是flag04 文件从源代码中可以看出, 已经对token关键字的读取做了过滤, 所以直接运行./flag04 token会直接退出。

但是由于我们对/tmp目录有权限, 所以我们可以创建一个符号链接, 而且由于没有权限,只能创建软符号链接。

ln -s /home/flag04/token /tmp/exploit_04

然后运行./flag04 /tmp/exploit_04

发现可以读取出来!

tmp这个目录对于漏洞挖掘者来说真是不错的目录, 因为这个目录中你可以为所欲为!


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值