bWAPP----HTML Injection - Stored (Blog)
HTML Injection - Stored (Blog)
界面

1 <div id="main">
2
3 <h1>HTML Injection - Stored (Blog)</h1>
4
5 <form action="<?php echo($_SERVER["SCRIPT_NAME"]);?>" method="POST">
6
7 <table>
8
9 <tr>
10
11 <td colspan="6"><p><textarea name="entry" id="entry" cols="80" rows="3"></textarea></p></td>
12
13 </tr>
14
15 <tr>
16
17 <td width="79" align="left">
18
19 <button type="submit" name="blog" value="submit">Submit</button>
20
21 </td>
22
23 <td width="85" align="center">
24
25 <label for="entry_add">Add:</label>
26 <input type="checkbox" id="entry_add" name="entry_add" value="" checked="on">
27
28 </td>
29
30 <td width="100" align="center">
31
32 <label for="entry_all">Show all:</label>
33 <input type="checkbox" id="entry_all" name="entry_all" value="">
34
35 </td>
36
37 <td width="106" align="center">
38
39 <label for="entry_delete">Delete:</label>
40 <input type="checkbox" id="entry_delete" name="entry_delete" value="">
41
42 </td>
43
44 <td width="7"></td>
45
46 <td align="left"><?php echo $message;?></td>
47
48 </tr>
49
50 </table>
51
52 </form>
53
54 <br />
55
56 <table id="table_yellow">
57
58 <tr height="30" bgcolor="#ffb717" align="center">
59
60 <td width="20">#</td>
61 <td width="100"><b>Owner</b></td>
62 <td width="100"><b>Date</b></td>
63 <td width="445"><b>Entry</b></td>
64
65 </tr>
66
// 上面是html,下面开始是PHP源码
67 <?php
68
69 // Selects all the records
70
71 $entry_all = isset($_POST["entry_all"]) ? 1 : 0;
72
73 if($entry_all == false)
74 {
75
76 $sql = "SELECT * FROM blog WHERE owner = '" . $_SESSION["login"] . "'";
77
78 }
79
80 else
81 {
82
83 $sql = "SELECT * FROM blog";
84
85 }
86
87 $recordset = $link->query($sql);
88
89 if(!$recordset)
90 {
91
92 // die("Error: " . $link->connect_error . "<br /><br />");
93
94 ?>
95 <tr height="50">
96
97 <td colspan="4" width="665"><?php die("Error: " . $link->error);?></td>
98 <!--
99 <td></td>
100 <td></td>
101 <td></td>
102 -->
103
104 </tr>
105
106 <?php
107
108 }
109
110 while($row = $recordset->fetch_object())
111 {
112
113 if($_COOKIE["security_level"] == "1" or $_COOKIE["security_level"] == "2")
114 {
115
116 ?>
117 <tr height="40">
118
119 <td align="center"><?php echo $row->id; ?></td>
120 <td><?php echo $row->owner; ?></td>
121 <td><?php echo $row->date; ?></td>
122 <td><?php echo xss_check_3($row->entry); ?></td>
123
124 </tr>
125
126 <?php
127
128 }
129
130 else
131 {
132
133 ?>
134 <tr height="40">
135
136 <td align="center"><?php echo $row->id; ?></td>
137 <td><?php echo $row->owner; ?></td>
138 <td><?php echo $row->date; ?></td>
139 <td><?php echo $row->entry; ?></td>
140
141 </tr>
142
143 <?php
144
145 }
146
147 }
148
149 $recordset->close();
150
151 $link->close();
152
153 ?>
154 </table>
155
156 </div>
感觉防护代码这有点问题,我没看明白
1 function htmli($data)
2 {
3
4 include("connect_i.php"); //链接数据库
5
6 switch($_COOKIE["security_level"]) //检测级别在cookie里
7 {
8
9 case "0" :
10
11 $data = sqli_check_3($link, $data);
12 break;
13
14 case "1" :
15
16 $data = sqli_check_3($link, $data);
17 // $data = xss_check_4($data);
18 break;
19
20 case "2" :
21
22 $data = sqli_check_3($link, $data);
23 // $data = xss_check_3($data);
24 break;
25
26 default :
27
28 $data = sqli_check_3($link, $data);
29 break;
30
31 }
无论case是几,执行的都是
sqli_check_3()进行过滤
sqli_check_3()的定义是
应该把xss的防御加在这里
1 function sqli_check_3($link, $data)
2 {
3
4 return mysqli_real_escape_string($link, $data);
5
6 }
mysql_real_escape_string() 函数转义 SQL 语句中使用的字符串中的特殊字符。
下列字符受影响:
- \x00
- \n
- \r
- \
- '
- "
- \x1a
如果成功,则该函数返回被转义的字符串。如果失败,则返回 false。
1.low
级别同时不进行保护
2.medium
function xss_check_4($data)
{ // addslashes - returns a string with backslashes before characters that need to be quoted in database queries etc.
// These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).
// Do NOT use this for XSS or HTML validations!!! return addslashes($data); }
在预定义字符前加反斜杠
预定义字符是:
- 单引号(')
- 双引号(")
- 反斜杠(\)
- NULL
3.high
1 function xss_check_3($data, $encoding = "UTF-8")
2 {
3
4 // htmlspecialchars - converts special characters to HTML entities
5 // '&' (ampersand) becomes '&'
6 // '"' (double quote) becomes '"' when ENT_NOQUOTES is not set
7 // "'" (single quote) becomes ''' (or ') only when ENT_QUOTES is set
8 // '<' (less than) becomes '<'
9 // '>' (greater than) becomes '>'
10
11 return htmlspecialchars($data, ENT_QUOTES, $encoding);
12
13 }
htmlspecialchars()功能,将部分字符转化为html字符
bWAPP----HTML Injection - Stored (Blog)的更多相关文章
- bWAPP练习--injection篇之HTML Injection - Reflected (GET)
什么是Injection? injection,中文意思就是注入的意思,常见的注入漏洞就是SQL注入啦,是现在应用最广泛,杀伤力很大的漏洞. 什么是HTML injection? 有交互才会产生漏洞, ...
- bWAPP练习--injection篇SQL Injection (GET/Search)
SQL注入: SQL注入,就是通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令.具体来说,它是利用现有应用程序,将(恶意)的SQL命令注入到 ...
- bWAPP练习--injection篇之HTML Injection - Reflected (POST)
POST的和之前的GET的过程差不多,只是表单的提交方式不一样而已. low 我们在表单中填入一个超链接 <a href="http://www.cnblogs.com/ESHLkan ...
- webgote的例子(5)Sql注入(Blog)
SQL Injection - Stored (Blog) (本章内容):留言板的注入 看到这个页面先看以下这个页面是做什么的.进行正常的写入发现我每写一句话,其内容都会写到下面的entry里面 在尝 ...
- Angular2经典文章集锦
Angular Metadata 等基础知识 http://www.jianshu.com/p/aeb11061b82c Metadata告诉Angular如何处理一个类,只有我们将它通告给Angul ...
- sqli-labs学习笔记 DAY8
DAY 8 sqli-lab Page-3 sqli-labs lesson 38 What is Stacked injection? https://blog.csdn.net/Fly_hps/a ...
- Web API接口安全了解
2017版OWASP top 10 将API安全纳入其中,足以说明API被广泛使用且安全问题严重.自己尝试整理一下,但限于本人搬砖经验还不足.水平有限,本文只能算是抛砖引玉,希望大伙不吝赐教. 了解W ...
- Metasploitable2使用指南
Metasploitable2使用指南 Metasploitable2 虚拟系统是一个特别制作的ubuntu操作系统,本身设计作为安全工具测试和演示常见漏洞攻击.版本2已经可以下载,并且比上一个版本包 ...
- 前端 跨站脚本(XSS)攻击的一些问题,解决<script>alert('gansir')</script>
问题1:跨站脚本(XSS)的一些问题,主要漏洞证据: <script>alert('gansir')</script>,对于这个问题怎么解决? (测试应当考虑的前端基础攻击问题 ...
随机推荐
- asp.net web 定时执行任务 定时器 Global.asax
web网站里面,需要每隔1分钟,执行一个任务,并且一直保持这个定时执行状态,可以用如下一个方法: 以下代码是 Global.asax.cs 的全部代码. using System; using Sys ...
- 为啥 Response.Write 后,View就不渲染了?
一:背景 1. 讲故事 前几天群里有一位朋友聊到,为什么我在 Action 中执行一句 Response.Write 之后,后续的 View 就不呈现了,如果脑子中没有画面,那就上测试代码: publ ...
- 树莓派调试PCF8591遇到的小问题
错误提示:bus = smbus.SMBus(1) IOError: [Errno 2] No such file or directory 提示的内容为端口没有打开即IIC端口:如图,打开IIC使能 ...
- 编写C语言的两种方法----Visual Studio/CodeBlocks
1.CodeBlock(安装简单) 参考这个博客的:https://blog.csdn.net/jjjjkkjkk/article/details/80331625?utm_medium=distri ...
- C#Socket通讯(2)
前言 前面已经把游戏的服务端UI搭起来来了,现在需要实现的就是编写服务端控制器与客户端的代码,实现服务端与客户端的数据传输,并将传输情况显示在服务端的UI上 服务端控制器完整代码 private st ...
- Linux入门到放弃之四《磁盘管理》
一,磁盘管理 1.添加一个新磁盘/dev/sdb,用fdisk工具给磁盘分区,要求:一个主分区,一个扩展分区,两个逻辑分区: (1)去虚拟机设置添加一块硬盘,大小自定义 (2)重启系统 命令:rebo ...
- python坐标获取经纬度或经纬度获取坐标免费模块--geopy
一.官方文档 https://github.com/geopy/geopy 二.模块安装 pip3 install geopy 三.简单实用 from geopy.geocoders import N ...
- 蒲公英 · JELLY技术周刊 Vol 27: 平平无奇 React 17
蒲公英 · JELLY技术周刊 Vol.27 这个热闹的十月终于要走到尾声,React 17 历经 4 个 RC 版本之后,也于数天前正式发布了,而同在几天前发布的 CRA 4.0 也已经完成了 Re ...
- JVM的艺术—类加载器篇(二)
分享是价值的传递,喜欢就点个赞 引言 今天我们继续来深入的剖析类加载器的内容.上节课我们讲了类加载器的基本内容,没看过的小伙伴请加关注.今天我们继续. 什么是定义类加载器和初始化类加载器? 定义类加载 ...
- nginx反向代理三台web服务器,实现负载均衡
修改nginx.conf #在http和server之间加入这个模块 upstream guaji{ server 127.0.0.1:8080; server 127.0.0.2:8080; ser ...