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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Level 11: 1. 登录后,发现页面上有一个输入框,可以输入任意的字符串,然后点击“Submit Query”按钮,就会返回一个加密后的字符串。 2. 查看网页源代码,发现有一段JavaScript代码,其中包含了一个函数`encodeString`,它是用来加密输入的字符串的。 3. 通过分析`encodeString`函数的代码,发现它是对输入的字符串进行了简单的替换和反转操作,最终得到了一个加密后的字符串。 4. 我们可以尝试对加密后的字符串进行反向操作,还原出原始的字符串。 5. 将得到的原始字符串作为参数,构造一个URL,然后访问这个URL,即可通过该关卡。 Level 12: 1. 登录后,发现页面上有一个输入框,可以输入任意的字符串,然后点击“Submit Query”按钮,就会返回一个加密后的字符串。 2. 查看网页源代码,发现有一段PHP代码,其中包含了一个函数`echo base64_encode(strrev(xor_encrypt($data, $key)));`,它是用来加密输入的字符串的。 3. 通过分析`xor_encrypt`函数的代码,发现它是对输入的字符串进行了异或加密操作,并且加密的密钥是一个固定的字符串。 4. 我们可以尝试对加密后的字符串进行反向操作和异或解密操作,还原出原始的字符串。 5. 将得到的原始字符串作为参数,构造一个Cookie,然后将该Cookie发送给服务器,即可通过该关卡。注意,这里要修改的是Cookie,而不是URL。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值