OverTheWire的natas游戏(6-10)

natas solution(6-10)

Natas Level 5 → Level 6

Username: natas6
URL:      http://natas6.natas.labs.overthewire.org

这一关不难,但是有一点可以讲一讲的。进去之后要我们往框框里输入东西后提交。不过旁边就有源码,直接看看源码吧

<?
include "includes/secret.inc";

if(array_key_exists("submit", $_POST)) {
   
   
    if($secret == $_POST['secret']) {
   
   
        print "Access granted. The password for natas7 is <censored>";
    } else {
   
   
        print "Wrong secret";
    }
}
?>

一个非常敏感的函数include猜测可能是文件包含但是看到下面的代码又没有相关的灵感。而且这个secret在哪呢?根据前面关卡的思路来看看includes目录?http://natas6.natas.labs.overthewire.org/includes/看到返回的错误是403这是一个非常有用的信息,这表明存在该目录但是我们没有权限访问,那我们再看看includes/secret.inc呢?

进去之后看到

<?
	$secret=FOEIUWGHFEEUHOFUOIU    
?>

很明了了吧,直接把这串字符串提交过去

Access granted. The password for natas7 is 7z3hEENjQtflzgnT29q7wAvMNfZdh0i9 

那么这里有一个知识点就是后缀为.inc的这个文件

What is an .inc and why use it?

可以看到这是一个用于php项目里的后缀,根据高赞回答,这个后缀是一个习惯:当一个文件要被其他php文件include时就会使用.inc作为后缀。

.inc.include的缩写。

It has no meaning, it is just a file extension. It is some people’s convention to name files with a .inc extension if that file is designed to be included by other PHP files, but it is only convention.

It does have a possible disadvantage which is that servers normally are not configured to parse .inc files as php, so if the file sits in your web root and your server is configured in the default way, a user could view your php source code in the .inc file by visiting the URL directly.

Its only possible advantage is that it is easy to identify which files are used as includes. Although simply giving them a .php extension and placing them in an includes folder has the same effect without the disadvantage mentioned above.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值