Skip to content

Commit 45c78ae

Browse files
committed
improve comments for x86/x64 shellcode in TestCombine.
1 parent 508f9de commit 45c78ae

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

combiner_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ import (
1414

1515
func TestCombine(t *testing.T) {
1616
t.Run("common", func(t *testing.T) {
17+
// xor eax, eax
18+
// add eax, 0x86
19+
// ret
1720
x86 := []byte{
18-
// xor eax, eax
1921
0x31, 0xC0,
20-
// add eax, 86
2122
0x05, 0x86, 0x00, 0x00, 0x00,
22-
// ret
2323
0xC3,
2424
}
25+
// xor eax, eax
26+
// add rax, 0x64
27+
// ret
2528
x64 := []byte{
26-
// xor eax, eax
2729
0x31, 0xC0,
28-
// add rax, 64
2930
0x48, 0x83, 0xC0, 0x64,
30-
// ret
3131
0xC3,
3232
}
3333
shellcode := Combine(x86, x64)
@@ -46,12 +46,12 @@ func TestCombine(t *testing.T) {
4646
})
4747

4848
t.Run("padding x86", func(t *testing.T) {
49+
// xor eax, eax
50+
// add rax, 0x64
51+
// ret
4952
x64 := []byte{
50-
// xor eax, eax
5153
0x31, 0xC0,
52-
// add rax, 64
5354
0x48, 0x83, 0xC0, 0x64,
54-
// ret
5555
0xC3,
5656
}
5757
shellcode := Combine(nil, x64)
@@ -70,12 +70,12 @@ func TestCombine(t *testing.T) {
7070
})
7171

7272
t.Run("padding x64", func(t *testing.T) {
73+
// xor eax, eax
74+
// add eax, 0x86
75+
// ret
7376
x86 := []byte{
74-
// xor eax, eax
7577
0x31, 0xC0,
76-
// add eax, 86
7778
0x05, 0x86, 0x00, 0x00, 0x00,
78-
// ret
7979
0xC3,
8080
}
8181
shellcode := Combine(x86, nil)

0 commit comments

Comments
 (0)