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
5 changes: 5 additions & 0 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 Down
11 changes: 11 additions & 0 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 Down
5 changes: 5 additions & 0 deletions lib/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ 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,
Expand Down
22 changes: 22 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import (
"github.com/projectdiscovery/interactsh/pkg/server"
)

// 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")
var msg, consoleMsg string
Expand Down Expand Up @@ -49,12 +52,16 @@ func logActivity(evtType string, target string, status int, details string) {
}
}

// 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 {
Expand All @@ -63,6 +70,21 @@ func hasStdinData() bool {
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 Down
13 changes: 12 additions & 1 deletion pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ var (
QsReplaceRegex = regexp.MustCompile(`=([^?|&]*)`)
)

// EnsurePayloadsConfig initializes or appends default vectors safely on the host system
// EnsurePayloadsConfig ensures the payloads configuration file exists and contains the embedded default vectors.
//
// If the configured payload file does not exist, it will be created containing the embedded defaults.
// If the file exists, any default vectors not already present will be appended (with a separator) so existing
// user content is preserved. When `silent` is false a brief status message is printed.
//
// Errors are returned for filesystem failures such as directory creation, file reads, or writes.
func EnsurePayloadsConfig(silent bool) error {
configDir := filepath.Dir(PayloadsFile)

Expand Down Expand Up @@ -120,6 +126,11 @@ func EnsurePayloadsConfig(silent bool) error {
return nil
}

// ParseOptions parses command-line flags into an Options value and initializes package-level option pointers.
//
// It validates the optional InputFile when provided (must exist, must not be a directory, must be non-empty).
// It also ensures the payloads configuration is present by running the sync routine and will return an error if that setup fails.
// Returns the populated *Options on success or a non-nil error if flag parsing, input validation, or config setup fails.
func ParseOptions() (*Options, error) {
os.Args[0] = "ressrf"

Expand Down