Skip to content

Commit c37b6fe

Browse files
authored
Merge pull request #62 from alphasoc/mariusz/oast
simulator/oast. Add OAST module. Resolves #59
2 parents ccf4a7c + cbb3c2c commit c37b6fe

File tree

3 files changed

+112
-13
lines changed

3 files changed

+112
-13
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,17 @@ All done!
138138

139139
The modules packaged with the utility are listed in the table below.
140140

141-
| Module | Description |
142-
| ------------- | ----------------------------------------------------------------------------- |
143-
| `c2` | Generates both DNS and IP traffic to a random list of known C2 destinations |
144-
| `dga` | Simulates DGA traffic using random labels and top-level domains |
145-
| `imposter` | Generates DNS traffic to a list of imposter domains |
146-
| `miner` | Generates Stratum mining protocol traffic to known cryptomining pools |
147-
| `scan` | Performs a port scan of random RFC 5737 addresses using common TCP ports |
148-
| `sink` | Connects to known sinkholed destinations run by security researchers |
149-
| `spambot` | Resolves and connects to random Internet SMTP servers to simulate a spam bot |
150-
| `ssh-exfil` | Simulates an SSH file transfer to a service running on a non-standard SSH port|
151-
| `ssh-transfer`| Simulates an SSH file transfer to a service running on an SSH port |
152-
| `tunnel-dns` | Generates DNS tunneling requests to \*.sandbox.alphasoc.xyz |
153-
| `tunnel-icmp` | Generates ICMP tunneling traffic to an Internet service operated by AlphaSOC |
141+
| Module | Description |
142+
| ------------- | -------------------------------------------------------------------------------- |
143+
| `c2` | Generates both DNS and IP traffic to a random list of known C2 destinations |
144+
| `dga` | Simulates DGA traffic using random labels and top-level domains |
145+
| `imposter` | Generates DNS traffic to a list of imposter domains |
146+
| `miner` | Generates Stratum mining protocol traffic to known cryptomining pools |
147+
| `oast` | Simulates out-of-band application security testing (OAST) traffic |
148+
| `scan` | Performs a port scan of random RFC 5737 addresses using common TCP ports |
149+
| `sink` | Connects to known sinkholed destinations run by security researchers |
150+
| `spambot` | Resolves and connects to random Internet SMTP servers to simulate a spam bot |
151+
| `ssh-exfil` | Simulates an SSH file transfer to a service running on a non-standard SSH port |
152+
| `ssh-transfer`| Simulates an SSH file transfer to a service running on an SSH port |
153+
| `tunnel-dns` | Generates DNS tunneling requests to \*.sandbox.alphasoc.xyz |
154+
| `tunnel-icmp` | Generates ICMP tunneling traffic to an Internet service operated by AlphaSOC |

cmd/run/run.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@ var allModules = []Module{
287287
HeaderMsg: "Resolving random imposter domains",
288288
Timeout: 1 * time.Second,
289289
},
290+
Module{
291+
Module: simulator.NewOAST(),
292+
Name: "oast",
293+
Pipeline: PipelineDNS,
294+
NumOfHosts: 1,
295+
HeaderMsg: "Preparing to simulate OAST traffic",
296+
Timeout: 3 * time.Second,
297+
},
290298
Module{
291299
Module: simulator.NewSSHTransfer(),
292300
Name: "ssh-transfer",

simulator/oast.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package simulator
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"math/rand"
7+
"net"
8+
"strings"
9+
"time"
10+
11+
"github.com/alphasoc/flightsim/utils"
12+
)
13+
14+
// InteractshDefaultDomains is a list of default domains used by Interactsh.
15+
var InteractshDefaultDomains = []string{
16+
"oast.fun",
17+
"oast.live",
18+
"oast.me",
19+
"oast.online",
20+
"oast.pro",
21+
"oast.site",
22+
"oastify.com",
23+
}
24+
25+
// OAST simulator. This module simulates the out-of-band security testing (OAST) technique
26+
// by trying to resolve random FQDNs under one of default domains used by Interactsh.
27+
type OAST struct {
28+
bind BindAddr
29+
}
30+
31+
// NewOAST creates OAST simulator.
32+
func NewOAST() *OAST {
33+
return &OAST{}
34+
}
35+
36+
func (oast *OAST) Init(bind BindAddr) error {
37+
oast.bind = bind
38+
return nil
39+
}
40+
41+
func (OAST) Cleanup() {
42+
}
43+
44+
// Simulate DNS lookups of random 33-character long hostnames beneath one of the default
45+
// domains used by Interactsh.
46+
func (oast *OAST) Simulate(ctx context.Context, host string) error {
47+
d := &net.Dialer{}
48+
// Set the user overridden bind iface.
49+
if oast.bind.UserSet {
50+
d.LocalAddr = &net.UDPAddr{IP: oast.bind.Addr}
51+
}
52+
r := &net.Resolver{
53+
PreferGo: true,
54+
Dial: d.DialContext,
55+
}
56+
57+
for {
58+
// Keep going until the passed context expires.
59+
select {
60+
case <-ctx.Done():
61+
return nil
62+
// Wait a random amount of time between 100ms and 500ms.
63+
case <-time.After(time.Duration(100+rand.Intn(400)) * time.Millisecond):
64+
}
65+
66+
// Generate a random 33-character long hostname.
67+
hostname := strings.ToLower(utils.RandString(33))
68+
69+
lctx, cancelFn := context.WithTimeout(ctx, 200*time.Millisecond)
70+
defer cancelFn()
71+
_, err := r.LookupIPAddr(lctx, fmt.Sprintf("%s.%s", hostname, host))
72+
73+
// Ignore "no such host". Will ignore timeouts as well.
74+
if err != nil && !isSoftError(err, "no such host") {
75+
return err
76+
}
77+
}
78+
}
79+
80+
// Hosts returns a list of default domains used by Interactsh.
81+
func (OAST) Hosts(scope string, size int) ([]string, error) {
82+
var hosts []string
83+
for _, i := range rand.Perm(len(InteractshDefaultDomains)) {
84+
hosts = append(hosts, InteractshDefaultDomains[i])
85+
if len(hosts) == size {
86+
break
87+
}
88+
}
89+
return hosts, nil
90+
}

0 commit comments

Comments
 (0)