Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
 新增base64文件编码、输出分割命令文件
  • Loading branch information
corunb committed Jan 4, 2024
1 parent 40021e4 commit 5c79daa
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 101 deletions.
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
## 功能介绍

```
-f string
-e string
指定base64编码文件
-f string
指定分割的文本
-n int
设置长度进行切割,默认32 (default 32)
-n int
设置长度进行切割,默认64 (default 64)
```

只有两个功能
功能

​ 1、根据文件后缀进行分割:

Expand All @@ -28,19 +30,32 @@

分割txt:

![image-20230307093119027](image//image-20230307093119027.png)
![image-20230307093119027](./assets/image-20230307093119027.png)

![image-20230307093211722](image//image-20230307093211722.png)
![image-20230307093211722](./assets/image-20230307093211722.png)



分割木马:

![image-20230307111110423](image//image-20230307111110423.png)
![image-20230307093032359](./assets/image-20230307093032359.png)

​ 2、可设置分割的长度

```
./Split_tools -f 1.txt -n 64
```

​ 3、可对文件进行base64编码
```
编码文件后,将生成./results/enbase64.txt文件
上传编码文件后,结合certutil -decode xxx.txt xxx.exe命令进行还原;
```

![image-20240104111644639](./assets/image-20240104111644639.png)

## 更新记录:
```
[+] 2024.1.4 新增base64文件编码、输出分割命令文件
```

Binary file added assets/image-20230307093032359.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added assets/image-20240104111644639.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
::mac
SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=amd64
go build -ldflags="-s -w" -trimpath -o Split_tools_darwin main.go
::m1
SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=arm64
go build -ldflags="-s -w" -trimpath -o Split_tools_m1 main.go
::linux
SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
go build -ldflags="-s -w" -trimpath -o Split_tools_linux main.go
::win
SET CGO_ENABLED=0
SET GOOS=windows
SET GOARCH=amd64
go build -ldflags="-s -w" -trimpath -o Split_tools.exe main.go
29 changes: 16 additions & 13 deletions cmd/ReadandWrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func ReadFile(File string) string {
return ""
}


fd, err := ioutil.ReadAll(f)
if err != nil {
fmt.Println("read to fd fail", err)
Expand All @@ -25,20 +24,24 @@ func ReadFile(File string) string {
return string(fd)
}


// Write 写文件
func Write(output string,number int) {
func Write(output string, number int) {
//创建文件夹
_ = os.Mkdir("./results", os.ModePerm)
filename := "./results/"+strconv.Itoa(number) +".txt"
file, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
fmt.Printf("文件错误,错误为:%v\n", err)
return
}
str := []byte(output)
_,_ = file.Write(str) //将str字符串的内容写到文件中,强制转换为byte,因为Write接收的是byte。
var filename string
if number >= 1 {
filename = "./results/" + strconv.Itoa(number) + ".txt"
} else if number == 0 {
filename = "./results/" + "log.txt"
} else {
filename = "./results/" + "enbase64.txt"
}



file, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
fmt.Printf("文件错误,错误为:%v\n", err)
return
}
str := []byte(output)
_, _ = file.Write(str) //将str字符串的内容写到文件中,强制转换为byte,因为Write接收的是byte。
}
10 changes: 10 additions & 0 deletions cmd/encode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cmd

import "encoding/base64"

func EnBase64() {
en64 := ReadFile(EncodeFile)
//base64压缩
sourcestring := base64.StdEncoding.EncodeToString([]byte(en64))
Write(sourcestring, -1)
}
12 changes: 4 additions & 8 deletions cmd/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import (

var Number int
var File string


var EncodeFile string

func init() {
flag.IntVar(&Number,"n",32,"设置长度进行切割,默认32")
flag.StringVar(&File, "f","","指定分割的文本")
flag.IntVar(&Number, "n", 64, "设置长度进行切割,默认32")
flag.StringVar(&File, "f", "", "指定分割的文本")
flag.StringVar(&EncodeFile, "e", "", "指定base64编码文件")
flag.Parse()


logo := `
____ _ _ _ _ _
/ ___| _ __ | (_) |_ | |_ ___ ___ | |___
Expand All @@ -29,7 +28,4 @@ func init() {
`
color.HiGreen.Println(logo)


}


115 changes: 57 additions & 58 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,108 +9,107 @@ import (
"strings"
)


func Run(){
func Run() {
if File != "" {
if strings.Contains(Filename(File),".txt") ==true {
//判断文件后缀类型是不是txt
if strings.Contains(Filename(File), ".txt") == true {
Partition()
}else {
Partitions(ReadFile(File),Number)
} else {
Partitions(ReadFile(File), Number)
}
}else {
} else if EncodeFile != "" {
EnBase64()
color.HiGreen.Println("[+] 编码文件成功,请见results目录!")
color.HiGreen.Println("上传base64编码后的文件可使用还原命令:" +
"certutil -decode test.txt test.exe\n")

} else {
fmt.Println("啥也没有,干点啥呢!!")
}



}

// Partitions 分割并生成写入命令
func Partitions(str string,Number int){
newstrs := strings.Replace(str,`"`,`'`,-1)
wins :=SplitSubN(newstrs,Number)
//strs := strings.Replace(str,"<","^<",-1)
//newstrs := strings.Replace(strs,">","^>",-1)
//wins := SplitSubN(newstrs,10)
//for _,v := range wins {
// fmt.Println(v)
//}
//fmt.Printf("\n分成了%v个片段\n\n", len(wins))
// Partitions 分割木马文件并生成写入命令
func Partitions(str string, Number int) {
//替换 " 为 '
newstrs := strings.Replace(str, `"`, `'`, -1)
wins := SplitSubN(newstrs, Number)
fmt.Println("windows写入多个文件后合并命令:")
Write("windows写入多个文件后合并命令:\n", 0)

var winstr []string
for i := 0; i< len(wins); i++ {
//fmt.Println("echo "+ wins[i] +" >" + strconv.Itoa(i) + ".txt")
req := "echo|set /p=\""+wins[i] + "\">" + strconv.Itoa(i) + ".txt"
winstr = append(winstr,req)
for i := 0; i < len(wins); i++ {
req := "echo|set /p=\"" + wins[i] + "\">" + strconv.Itoa(i) + ".txt"
winstr = append(winstr, req)
}
for _,v := range winstr {
for _, v := range winstr {
fmt.Println(v)
Write(v+"\n", 0)
}
fmt.Println("使用copy命令合并文件!")
//fmt.Println("示例:copy 0.txt + 1.txt out.txt!")
color.HiGreen.Println("示例:copy 0.txt + 1.txt out.txt!")
Write("使用copy命令合并文件!\n", 0)
Write("示例:copy 0.txt + 1.txt out.txt!\n", 0)
fmt.Println()
fmt.Println("windows追加字符:")
Write("windows追加字符:\n", 0)
var winstrs []string
for i := 0; i< len(wins); i++ {
//fmt.Println("echo "+ wins[i] +" >" + strconv.Itoa(i) + ".txt")
req := "echo|set /p=\""+wins[i] + "\">>" + "test"+ Filename(File)
winstrs = append(winstrs,req)
for i := 0; i < len(wins); i++ {
req := "echo|set /p=\"" + wins[i] + "\">>" + "test" + Filename(File)
winstrs = append(winstrs, req)
}
for _,v := range winstrs {
for _, v := range winstrs {
fmt.Println(v)
Write(v+"\n", 0)
}
fmt.Println("================================================================")
Write("================================================================\n", 0)

//________________________________________________________________

newlinuxstrs := strings.Replace(str,`'`,`"`,-1)
lins := SplitSubN(newlinuxstrs,Number)
//for _,v := range lins {
// fmt.Println(v)
//}
//fmt.Printf("分成了%v个片段\n\n", len(lins))
newlinuxstrs := strings.Replace(str, `'`, `"`, -1)
lins := SplitSubN(newlinuxstrs, Number)
fmt.Println()
fmt.Println("linux追加写入命令:")
Write("linux追加写入命令:\n", 0)
var linstr []string
for i := 0; i< len(lins); i++ {
//fmt.Println("echo '"+ lins[i] +"' >" + strconv.Itoa(i) + ".txt")
req := "echo -n '"+ lins[i] +"' >>" + "1.txt"
linstr = append(linstr,req)
for i := 0; i < len(lins); i++ {
req := "echo -n '" + lins[i] + "' >>" + "1.txt"
linstr = append(linstr, req)
}
for _, v := range linstr{
for _, v := range linstr {
fmt.Println(v)
Write(v+"\n", 0)
}

fmt.Printf("\nlinux写入多个文件后合并:\n")
linsr := SplitSubN(str,Number)
//for _,v := range lins {
// fmt.Println(v)
//}
//fmt.Printf("分成了%v个片段\n\n", len(lins))

Write("linux写入多个文件后合并:\n", 0)
linsr := SplitSubN(str, Number)
fmt.Println("linux分割写入后合并命令:")
Write("linux分割写入后合并命令:\n", 0)
var linstrs []string
for i := 0; i< len(linsr); i++ {
for i := 0; i < len(linsr); i++ {
//fmt.Println("echo '"+ lins[i] +"' >" + strconv.Itoa(i) + ".txt")
req := "echo -n '"+ linsr[i] +"' >" + strconv.Itoa(i) + ".txt"
linstrs = append(linstrs,req)
req := "echo -n '" + linsr[i] + "' >" + strconv.Itoa(i) + ".txt"
linstrs = append(linstrs, req)
}
for _, v := range linstrs{
for _, v := range linstrs {
fmt.Println(v)
Write(v+"\n", 0)
}
//fmt.Printf("示例命令:paste -d '' 1.txt 2.txt > 3.txt\n")
color.HiGreen.Printf("合并文件示例命令:paste -d '' 1.txt 2.txt > 3.txt\n")
Write("合并文件示例命令:paste -d '' 1.txt 2.txt > 3.txt\n", 0)

}

// Partition 分割txt文件
func Partition() {
str := SplitSubN(ReadFile(File),Number)
fmt.Printf("分割为 %v 个\n",len(str))
for i,v := range str {
str := SplitSubN(ReadFile(File), Number)
fmt.Printf("分割为 %v 个\n", len(str))
for i, v := range str {
fmt.Println(v)
Write(v,i)
Write(v, i)
}
}

Expand All @@ -133,11 +132,11 @@ func SplitSubN(s string, n int) []string {
return subs
}


func Filename(File string) string{
// Filename 读取文件后缀
func Filename(File string) string {

filenameWithSuffix := path.Base(File)
fileSuffix := path.Ext(filenameWithSuffix)

return fileSuffix
}
}
Binary file removed image/image-20230307111110423.png
Binary file not shown.

0 comments on commit 5c79daa

Please sign in to comment.