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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ ressrf -h
| **`-o`** | `--outdir` | `vulns` | Output directory path for log captures and finding summaries. |
| **`-s`** | `--silent` | `false` | Suppress text banners, informational stats, and milestone lines. |
| **`-b`** | `--color-blind` | `false` | Strip ANSI terminal color sequences from stdout streams. |
| **`-v`** | `--verbose` | `false` | Show livestream of active connection updates and status codes |

### Operational Examples

Expand All @@ -106,6 +107,21 @@ Quiet fuzz execution routed to custom output storage destinations:
ressrf -l targets.txt -s -o ssrf_audit
```

You can it pipe with other tools:

```bash
subfinder -d target.com -all -silent | httpx -silent | katana -silent | gf ssrf | ressrf
```

To watch connection status modifications or debugging logs in real-time, add the verbose flag. It streams active network interactions, status codes, and connection failures straight to your terminal screen:

```bash
cat targets.txt | ressrf -v
```

> [!NOTE]
> The silent flag (`-s`) will completely suppress console output. If you want to see live verbose updates on your screen, ensure that you do not pass `-s` in your command chain.

## Custom Payloads

The underlying validation rules utilize embedded engine tracking. Default vectors located at `~/.config/ressrf/payloads.cfg` incorporate structural placeholder tags:
Expand Down
13 changes: 10 additions & 3 deletions lib/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"github.com/R0X4R/ressrf/pkg"
)

// ExecuteHeaderPhase enqueues header-injection jobs for each target URL and header vector using both payload formats (with and without an HTTP scheme).
//
// For each generated payload an identifier is allocated (incrementing trackCounter) and corresponding metadata is stored in requestTracker. Each job, when executed, will wait on rl, set the specified header to the payload, send the request, and invoke logActivity with either "ERROR" (on send failure) or "SENT" (on success) including the target URL, status code, and a short detail string.
//
// ExecuteHeaderPhase schedules work onto the provided jobs channel and increments wg for each scheduled job; it does not block waiting for job completion.
func ExecuteHeaderPhase(
urls []string,
collab string,
Expand All @@ -16,7 +21,7 @@ func ExecuteHeaderPhase(
trackMutex *sync.Mutex,
trackCounter *int,
requestTracker map[string]pkg.VulnerabilityMetadata,
logActivity func(string, ...interface{}),
logActivity func(string, string, int, string),
) {
for _, rawURL := range urls {
for _, header := range pkg.HeadersInject {
Expand Down Expand Up @@ -47,10 +52,12 @@ func ExecuteHeaderPhase(
hdrs[hdrKey] = payloadStr
status, _, err := pkg.SendRequest(targetURL, hdrs)
if err != nil {
logActivity("REQUEST ERROR - Header Target: %s [%s: %s] | Err: %v", targetURL, hdrKey, payloadStr, err)

logActivity("ERROR", targetURL, 0, fmt.Sprintf("Header Key [%s] - %s", hdrKey, err.Error()))
return
}
logActivity("REQUEST SENT - Status: [%d] | Header: [%s: %s] | Target URL: %s", status, hdrKey, payloadStr, targetURL)

logActivity("SENT", targetURL, status, fmt.Sprintf("Header Vector [%s]", hdrKey))
}
}(u, h, p)
}
Expand Down
17 changes: 14 additions & 3 deletions lib/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import (
"github.com/R0X4R/ressrf/pkg"
)

// ExecuteParameterPhase constructs and enqueues URL-parameter injection test requests for each input URL.
//
// For each URL this function creates two test variants (one with an explicit "http://" scheme and one without),
// reserves a unique tracking id while holding trackMutex, records metadata in requestTracker[id] with InjectType
// "URL Parameter Injection", and increments the provided WaitGroup for each enqueued job. Each job sent to the
// jobs channel waits on rl before issuing the HTTP request and reports results through logActivity: an "ERROR"
// entry with status 0 and the error message on failure, or a "SENT" entry with the response status and the
// message "URL Parameter Phase Vector" on success.
//
// This function does not return a value; it performs side effects on the WaitGroup, trackCounter, requestTracker,
// and by sending closures to the jobs channel.
func ExecuteParameterPhase(
urls []string,
collab string,
Expand All @@ -16,7 +27,7 @@ func ExecuteParameterPhase(
trackMutex *sync.Mutex,
trackCounter *int,
requestTracker map[string]pkg.VulnerabilityMetadata,
logActivity func(string, ...interface{}),
logActivity func(string, string, int, string),
) {
for _, rawURL := range urls {
for _, useScheme := range []bool{false, true} {
Expand All @@ -43,10 +54,10 @@ func ExecuteParameterPhase(
rl.Wait()
status, _, err := pkg.SendRequest(targetURL, pkg.BaseHeaders())
if err != nil {
logActivity("REQUEST ERROR - URL Param Target: %s | Err: %v", targetURL, err)
logActivity("ERROR", targetURL, 0, err.Error())
return
}
logActivity("REQUEST SENT - Status: [%d] | Target URL: %s", status, targetURL)
logActivity("SENT", targetURL, status, "URL Parameter Phase Vector")
}
}(u)
}
Expand Down
16 changes: 12 additions & 4 deletions lib/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ import (
"github.com/fatih/color"
)

// ExecuteProtocolPhase schedules protocol-bypass HTTP request jobs for every combination of the provided URLs and protocol payload templates.
//
// ExecuteProtocolPhase reads payload templates from pkg.PayloadsFile, substitutes `{COLLAB}` and `{COLLAB_URL}` with the provided collab value, and for each resulting payload–URL pair enqueues a job on the provided jobs channel. Each job waits on rl, sends the HTTP request, and reports activity via logActivity. If a request fails it is logged with an "ERROR" activity and not further processed; successful requests are logged as "SENT". When the response body matches pkg.AltProtoRegex the function prints a hit line, appends a findings entry to the file at *pkg.OutDir+"/findings.txt", and logs a vulnerability-identification activity.
//
// If reading pkg.PayloadsFile fails, the function optionally prints a skip message and returns without scheduling any jobs. The function increments wg for each scheduled job and ensures wg.Done() is called when a job completes.
func ExecuteProtocolPhase(
urls []string,
collab string,
rl *pkg.RateLimiter,
jobs chan<- func(),
wg *sync.WaitGroup,
logActivity func(string, ...interface{}),
logActivity func(string, string, int, string),
) {
payloads, err := pkg.ReadLines(pkg.PayloadsFile)
if err != nil {
Expand All @@ -36,11 +41,13 @@ func ExecuteProtocolPhase(
defer wg.Done()
rl.Wait()
status, body, err := pkg.SendRequest(targetURL, pkg.BaseHeaders())

if err != nil {
logActivity("REQUEST ERROR - Alt Proto Target: %s | Err: %v", targetURL, err)
logActivity("ERROR", targetURL, 0, err.Error())
return
}
logActivity("REQUEST SENT - Status: [%d] | Alt Proto Payload URL: %s", status, targetURL)

logActivity("SENT", targetURL, status, "Protocol Bypass Vector")

if pkg.AltProtoRegex.MatchString(body) {
displayLine := fmt.Sprintf("%s [%s] [%s]",
Expand All @@ -49,7 +56,8 @@ func ExecuteProtocolPhase(

fmt.Println(displayLine)
pkg.AppendLine(*pkg.OutDir+"/findings.txt", logStorageLine)
logActivity("VULNERABILITY IDENTIFIED - %s", logStorageLine)

logActivity("SENT", targetURL, status, "VULNERABILITY IDENTIFIED: ALT-PROTO HIT Local Content Leak")
}
}
}(u)
Expand Down
105 changes: 93 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bufio"
"fmt"
"os"
"os/signal"
Expand All @@ -17,18 +18,73 @@ import (
"github.com/projectdiscovery/interactsh/pkg/server"
)

func logActivity(format string, args ...interface{}) {
// logActivity writes a timestamped activity entry to the activity.log file and, when verbose and not silent, prints a colored console message.
// For evtType == "ERROR", it records an "UNABLE TO CONNECT" entry including details; otherwise it records a "REQ SENT" entry including status, target, and optional details.
// The console output colorizes the status (green for 2xx, cyan for 3xx, yellow for others) and the log is appended to (*pkg.OutDir)/activity.log.
func logActivity(evtType string, target string, status int, details string) {
timestamp := time.Now().Format("2006-01-02 15:04:05")
msg := fmt.Sprintf("[%s] ", timestamp) + fmt.Sprintf(format, args...)
var msg, consoleMsg string

if evtType == "ERROR" {
msg = fmt.Sprintf("[%s] [UNABLE TO CONNECT] Target: %s | Details: %s", timestamp, target, details)
consoleMsg = fmt.Sprintf("[%s] %s Target: %s", timestamp, color.RedString("[UNABLE TO CONNECT]"), target)
} else {
msg = fmt.Sprintf("[%s] [REQ SENT] Status: [%d] | Target: %s", timestamp, status, target)
if details != "" {
msg += " | " + details
}

statusStr := fmt.Sprintf("[%d]", status)
if status >= 200 && status < 300 {
statusStr = color.GreenString("[%d]", status)
} else if status >= 300 && status < 400 {
statusStr = color.CyanString("[%d]", status)
} else {
statusStr = color.YellowString("[%d]", status)
}
consoleMsg = fmt.Sprintf("[%s] %s STATUS %s == %s", timestamp, color.BlueString("[REQ SENT]"), statusStr, target)
}

pkg.AppendLine(*pkg.OutDir+"/activity.log", msg)

if *pkg.Verbose && !*pkg.Silent {
fmt.Println(consoleMsg)
}
}

// logCallback appends a timestamped log line, formatted with the provided printf-style
// format and arguments, to the callback.log file in the configured output directory.
func logCallback(format string, args ...interface{}) {
timestamp := time.Now().Format("2006-01-02 15:04:05")
msg := fmt.Sprintf("[%s] ", timestamp) + fmt.Sprintf(format, args...)
pkg.AppendLine(*pkg.OutDir+"/callback.log", msg)
}

// hasStdinData reports whether standard input has data available (i.e., stdin is not a terminal).
// It returns true when stdin is not a character device, and false if stdin is a terminal or if Stat() fails.
func hasStdinData() bool {
stat, err := os.Stdin.Stat()
if err != nil {
return false
}
return (stat.Mode() & os.ModeCharDevice) == 0
}

// main is the program entry point that orchestrates configuration parsing, target collection,
// collaboration session initialization, concurrent scanning phases, out-of-band callback polling,
// and final result reporting.
//
// It parses CLI options and prepares the output directory, sources target URLs from stdin
// when available or from the configured input file, and either starts an Interactsh client
// or normalizes a provided collab server string. It launches worker goroutines, installs an
// interrupt handler that cleans up and logs a termination event, and starts a poller to
// process out-of-band interactions which are recorded to findings and activity logs.
// The function executes header, parameter, and protocol scan phases, waits for completion,
// keeps the session open for a short grace period to collect late callbacks, and then
// prints and stores summarized OOB results.
//
// The function terminates the process on fatal configuration or runtime errors (printing
// an error message before exiting).
func main() {
_, err := pkg.ParseOptions()
if err != nil {
Expand All @@ -42,17 +98,39 @@ func main() {

os.MkdirAll(*pkg.OutDir, 0755)

urls, err := pkg.ReadLines(*pkg.InputFile)
if err != nil || len(urls) == 0 {
fmt.Printf("[-] Cannot read input file or file is empty: %s\n", *pkg.InputFile)
os.Exit(1)
var urls []string

if hasStdinData() {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line != "" {
urls = append(urls, line)
}
}

if err := scanner.Err(); err != nil {
fmt.Printf("[!] ERROR READING STANDARD INPUT STREAM: %v\n", err)
os.Exit(1)
}

} else {
if *pkg.InputFile == "" {
fmt.Println("[!] ERROR: No targets provided. Pipeline urls via stdin or specify an input file using -l <file>")
os.Exit(1)
}
urls, err = pkg.ReadLines(*pkg.InputFile)
if err != nil || len(urls) == 0 {
fmt.Printf("[!] ERROR: Cannot read input file or file is empty: %s\n", *pkg.InputFile)
os.Exit(1)
}
}

var collab string
if *pkg.CollabServer == "" {
collab, err = pkg.StartInteractsh()
if err != nil {
fmt.Printf("[-] %v\n", err)
fmt.Printf("[!] ERROR: FAILED TO START INTERACTSH CLIENT: %v\n", err)
os.Exit(1)
}
defer pkg.ClientInstance.Close()
Expand Down Expand Up @@ -87,13 +165,12 @@ func main() {
go func() {
<-sigChan
if !*pkg.Silent {
fmt.Println(color.RedString("\n[!] INTERRUPT SIGNAL RECEIVED! FLUSING LOGS AND SHUTTING DOWN GRACEFULLY..."))
fmt.Println(color.RedString("\n[!] INTERRUPT SIGNAL RECEIVED! FLUSHING LOGS AND SHUTTING DOWN GRACEFULLY..."))
}
if pkg.ClientInstance != nil {
pkg.ClientInstance.Close()
}
logActivity("SCAN TERMINATED - User aborted scan via Interrupt signal.")
logCallback("SCAN TERMINATED - User aborted scan via Interrupt signal.")
logActivity("SCAN TERMINATED", "USER ABORTED SCAN VIA INTERRUPT SIGNAL", 0, "")
os.Exit(0)
}()

Expand Down Expand Up @@ -128,15 +205,19 @@ func main() {

if _, alreadyHit := uniqueHits[logStorageLine]; !alreadyHit {
uniqueHits[logStorageLine] = displayLine
fmt.Println(displayLine)
if *pkg.Verbose {
fmt.Print("\n" + displayLine + "\n\n")
} else {
fmt.Println(displayLine)
}
pkg.AppendLine(*pkg.OutDir+"/findings.txt", logStorageLine)
}
}
}
hitsMutex.Unlock()
})
if err != nil && !*pkg.Silent {
fmt.Printf("[-] FAILED TO LAUNCH LIVE TRANSACTION POLLER: %v\n", err)
fmt.Printf("[!] FAILED TO LAUNCH LIVE TRANSACTION POLLER: %v\n", err)
}
}

Expand Down
Loading
Loading