forked from vulncheck-oss/go-exploit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencode_test.go
More file actions
47 lines (34 loc) · 870 Bytes
/
encode_test.go
File metadata and controls
47 lines (34 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package payload
import (
"testing"
)
func TestEncodeCommandBrace(t *testing.T) {
encoded := EncodeCommandBrace("foo bar baz")
if encoded != "{foo,bar,baz}" {
t.Fatal(encoded)
}
t.Log(encoded)
}
func TestEncodeCommandIFS(t *testing.T) {
encoded := EncodeCommandIFS("foo bar baz")
if encoded != "foo${IFS}bar${IFS}baz" {
t.Fatal(encoded)
}
t.Log(encoded)
}
func TestEncodeEchoBase64ToBash(t *testing.T) {
encoded := EncodeEchoBase64ToBash("whoami; id;")
if encoded != "echo d2hvYW1pOyBpZDs=|base64 -d|bash" {
t.Fatal(encoded)
}
t.Log(encoded)
}
func TestEncodeSelfRemovingCron(t *testing.T) {
cron, xploit := SelfRemovingCron("root", "/etc/cron.d/hi", "/tmp/test", "id")
if cron != "* * * * * root /bin/sh /tmp/test\n" {
t.Fatal(cron)
}
if xploit != "#!/bin/sh\n\nrm -f /etc/cron.d/hi\nrm -f /tmp/test\nid\n" {
t.Fatal(xploit)
}
}