Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added interactsh additional variables support #1468

Merged
merged 7 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions v2/pkg/protocols/common/interactsh/interactsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Client struct {
pollDuration time.Duration
cooldownDuration time.Duration

hostname string
firstTimeGroup sync.Once
generated uint32 // decide to wait if we have a generated url
matched bool
Expand Down Expand Up @@ -93,6 +94,7 @@ func New(options *Options) (*Client, error) {
if err != nil {
return nil, errors.Wrap(err, "could not parse server url")
}
hostanme := parsed.Hostname()

configure := ccache.Configure()
configure = configure.MaxSize(options.CacheSize)
Expand All @@ -111,6 +113,7 @@ func New(options *Options) (*Client, error) {
dotHostname: "." + parsed.Host,
options: options,
requests: cache,
hostname: hostanme,
pollDuration: options.PollDuration,
cooldownDuration: options.ColldownPeriod,
}
Expand Down Expand Up @@ -255,6 +258,15 @@ func (c *Client) ReplaceMarkers(data string, interactshURLs []string) (string, [
return data, interactshURLs
}

// MakePlaceholders does placeholders for interact URLs and other data to a map
func (c *Client) MakePlaceholders(urls []string, data map[string]interface{}) {
data["interactsh-server"] = c.hostname
if len(urls) == 1 {
data["interactsh-url"] = urls[0]
data["interactsh-id"] = urls[0][:strings.Index(urls[0], ".")]
}
}

// SetStopAtFirstMatch sets StopAtFirstMatch true for interactsh client options
func (c *Client) SetStopAtFirstMatch() {
c.options.StopAtFirstMatch = true
Expand Down
5 changes: 5 additions & 0 deletions v2/pkg/protocols/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,17 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
}
outputEvent["curl-command"] = curlCommand
outputEvent["ip"] = httpclientpool.Dialer.GetDialedIP(hostname)

if request.options.Interactsh != nil {
request.options.Interactsh.MakePlaceholders(generatedRequest.interactshURLs, outputEvent)
}
for k, v := range previousEvent {
finalEvent[k] = v
}
for k, v := range outputEvent {
finalEvent[k] = v
}

// Add to history the current request number metadata if asked by the user.
if request.ReqCondition {
for k, v := range outputEvent {
Expand Down
3 changes: 3 additions & 0 deletions v2/pkg/protocols/network/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ func (request *Request) executeRequestWithPayloads(variables map[string]interfac
for k, v := range inputEvents {
outputEvent[k] = v
}
if request.options.Interactsh != nil {
request.options.Interactsh.MakePlaceholders(interactshURLs, outputEvent)
}

var event *output.InternalWrappedEvent
if len(interactshURLs) == 0 {
Expand Down