-
Notifications
You must be signed in to change notification settings - Fork 10
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
11 changed files
with
323 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,15 @@ | ||
all: win linux mac m1 | ||
|
||
win: | ||
# windows | ||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o Split_tools.exe main.go | ||
linux: | ||
# linux | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o Split_tools_linux main.go | ||
mac: | ||
# MacOS | ||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o Split_tools_darwin_mac main.go | ||
m1: | ||
# MacOSm1 | ||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w " -trimpath -o Split_tools_darwin_arm main.go | ||
|
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,46 @@ | ||
## 前言 | ||
|
||
每当获取一个命令执行,但是服务器不出网,不能进行远程下载,或者写木马有限制,命令长度也有限制的苛刻条件下,可使用该工具进行木马分割,一键生成写入命令和合并或者追加命令写入木马; | ||
|
||
windows在苛刻条件下也可以分段写入文本,再合并写入二进制文件,具体可以与Certutil配合,将二进制文件转换为txt,再分段写入后合并还原二进制文件; | ||
|
||
## 功能介绍 | ||
|
||
``` | ||
-f string | ||
指定分割的文本 | ||
-n int | ||
设置长度进行切割,默认32 (default 32) | ||
``` | ||
|
||
只有两个功能: | ||
|
||
1、根据文件后缀进行分割: | ||
|
||
``` | ||
当文件是txt时,会直接分割成几个txt | ||
./Split_tools -f 1.txt | ||
当文件是木马后缀时,会分割后生成写入命令 | ||
./Split_tools -f 1.jsp | ||
``` | ||
|
||
分割txt: | ||
|
||
![image-20230307093119027](image//image-20230307093119027.png) | ||
|
||
![image-20230307093211722](image//image-20230307093211722.png) | ||
|
||
|
||
|
||
分割木马: | ||
|
||
![image-20230307093032359](image//image-20230307093032359.png) | ||
|
||
2、可设置分割的长度 | ||
|
||
``` | ||
./Split_tools -f 1.txt -n 64 | ||
``` | ||
|
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,44 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
// ReadFile 读取文件列表返回数组 | ||
func ReadFile(File string) string { | ||
f, err := os.Open(File) | ||
if err != nil { | ||
fmt.Println("read file fail", err) | ||
return "" | ||
} | ||
|
||
|
||
fd, err := ioutil.ReadAll(f) | ||
if err != nil { | ||
fmt.Println("read to fd fail", err) | ||
return "" | ||
} | ||
|
||
return string(fd) | ||
} | ||
|
||
|
||
// Write 写文件 | ||
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。 | ||
} | ||
|
||
|
||
|
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,35 @@ | ||
package cmd | ||
|
||
import ( | ||
"flag" | ||
"github.com/gookit/color" | ||
) | ||
|
||
var Number int | ||
var File string | ||
|
||
|
||
|
||
func init() { | ||
flag.IntVar(&Number,"n",32,"设置长度进行切割,默认32") | ||
flag.StringVar(&File, "f","","指定分割的文本") | ||
flag.Parse() | ||
|
||
|
||
logo := ` | ||
____ _ _ _ _ _ | ||
/ ___| _ __ | (_) |_ | |_ ___ ___ | |___ | ||
\___ \| '_ \| | | __| | __/ _ \ / _ \| / __| | ||
___) | |_) | | | |_ | || (_) | (_) | \__ \ | ||
|____/| .__/|_|_|\__|___\__\___/ \___/|_|___/ | ||
|_| |_____| | ||
[+] code by Corun V1.0 | ||
[+] https://github.com/corunb/Split_tools | ||
` | ||
color.HiGreen.Println(logo) | ||
|
||
|
||
} | ||
|
||
|
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,143 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"github.com/gookit/color" | ||
"path" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
|
||
func Run(){ | ||
if File != "" { | ||
if strings.Contains(Filename(File),".txt") ==true { | ||
Partition() | ||
}else { | ||
Partitions(ReadFile(File),Number) | ||
} | ||
}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)) | ||
fmt.Println("windows写入多个文件后合并命令:") | ||
|
||
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 _,v := range winstr { | ||
fmt.Println(v) | ||
} | ||
fmt.Println("使用copy命令合并文件!") | ||
//fmt.Println("示例:copy 0.txt + 1.txt out.txt!") | ||
color.HiGreen.Println("示例:copy 0.txt + 1.txt out.txt!") | ||
fmt.Println() | ||
fmt.Println("windows追加字符:") | ||
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 _,v := range winstrs { | ||
fmt.Println(v) | ||
} | ||
fmt.Println("================================================================") | ||
|
||
//________________________________________________________________ | ||
|
||
newlinuxstrs := strings.Replace(str,`'`,`"`,-1) | ||
lins := SplitSubN(newlinuxstrs,Number) | ||
//for _,v := range lins { | ||
// fmt.Println(v) | ||
//} | ||
//fmt.Printf("分成了%v个片段\n\n", len(lins)) | ||
fmt.Println() | ||
fmt.Println("linux追加写入命令:") | ||
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 _, v := range linstr{ | ||
fmt.Println(v) | ||
} | ||
|
||
fmt.Printf("\nlinux写入多个文件后合并:\n") | ||
linsr := SplitSubN(str,Number) | ||
//for _,v := range lins { | ||
// fmt.Println(v) | ||
//} | ||
//fmt.Printf("分成了%v个片段\n\n", len(lins)) | ||
|
||
fmt.Println("linux分割写入后合并命令:") | ||
var linstrs []string | ||
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) | ||
} | ||
for _, v := range linstrs{ | ||
fmt.Println(v) | ||
} | ||
//fmt.Printf("示例命令:paste -d '' 1.txt 2.txt > 3.txt\n") | ||
color.HiGreen.Printf("合并文件示例命令:paste -d '' 1.txt 2.txt > 3.txt\n") | ||
} | ||
|
||
// Partition 分割txt文件 | ||
func Partition() { | ||
str := SplitSubN(ReadFile(File),Number) | ||
fmt.Printf("分割为 %v 个\n",len(str)) | ||
for i,v := range str { | ||
fmt.Println(v) | ||
Write(v,i) | ||
} | ||
} | ||
|
||
// SplitSubN 按照长度切割字符串 | ||
func SplitSubN(s string, n int) []string { | ||
var sub string | ||
var subs []string | ||
|
||
runes := bytes.Runes([]byte(s)) | ||
l := len(runes) | ||
for i, r := range runes { | ||
sub = sub + string(r) | ||
if (i+1)%n == 0 { | ||
subs = append(subs, sub) | ||
sub = "" | ||
} else if (i + 1) == l { | ||
subs = append(subs, sub) | ||
} | ||
} | ||
return subs | ||
} | ||
|
||
|
||
func Filename(File string) string{ | ||
|
||
filenameWithSuffix := path.Base(File) | ||
fileSuffix := path.Ext(filenameWithSuffix) | ||
|
||
return fileSuffix | ||
} |
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,10 @@ | ||
module Split_tools | ||
|
||
go 1.19 | ||
|
||
require github.com/gookit/color v1.5.2 | ||
|
||
require ( | ||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect | ||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 // indirect | ||
) |
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,20 @@ | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/gookit/color v1.5.2 h1:uLnfXcaFjlrDnQDT+NCBcfhrXqYTx/rcCa6xn01Y8yI= | ||
github.com/gookit/color v1.5.2/go.mod h1:w8h4bGiHeeBpvQVePTutdbERIUf3oJE5lZ8HM0UgXyg= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= | ||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= | ||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= | ||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c= | ||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
package main | ||
|
||
import ( | ||
"Split_tools/cmd" | ||
) | ||
|
||
func main() { | ||
cmd.Run() | ||
} | ||
|