v1.0.0rc1 update

newgen
兔子 4 years ago
parent 4a8458fab6
commit 9e7ad45f06

@ -0,0 +1 @@
package main

@ -0,0 +1,90 @@
package aeschiper
import (
"errors"
"fmt"
"io"
"os"
"b612.me/starcrypto"
"b612.me/staros"
)
func EncodeStr(str, key string) string {
ensdata := starcrypto.AesEncryptCFBNoBlock([]byte(str), starcrypto.Md5([]byte(key)))
return starcrypto.Base91EncodeToString(ensdata)
}
func DecodeStr(str, key string) string {
strtmp := starcrypto.Base91DecodeString(str)
str = string(strtmp)
return string(starcrypto.AesDecryptCFBNoBlock([]byte(str), starcrypto.Md5([]byte(key))))
}
func EncodeFile(fpath, out, key string) error {
if !staros.Exists(fpath) {
return errors.New("SrcFile Not Exists")
}
fpsrc, err := os.Open(fpath)
if err != nil {
return err
}
defer fpsrc.Close()
fpdst, err := os.Create(out)
if err != nil {
return err
}
defer fpdst.Close()
bufsize := 1024 * 1024 //1MB
stat, _ := fpsrc.Stat()
buf := make([]byte, bufsize)
sumAll := 0
for {
n, err := fpsrc.Read(buf)
if err != nil && err != io.EOF {
return err
}
fmt.Print("已完成:%.2f%%\r", float64(sumAll)/float64(stat.Size())*100)
encodeBytes := starcrypto.AesEncryptCFBNoBlock(buf[:n], starcrypto.Md5([]byte(key)))
fpdst.Write(encodeBytes)
if err == io.EOF {
fmt.Print("已完成100%% \n")
break
}
}
return nil
}
func DecodeFile(fpath, out, key string) error {
if !staros.Exists(fpath) {
return errors.New("SrcFile Not Exists")
}
fpsrc, err := os.Open(fpath)
if err != nil {
return err
}
defer fpsrc.Close()
fpdst, err := os.Create(out)
if err != nil {
return err
}
defer fpdst.Close()
bufsize := 1024 * 1024 //1MB
stat, _ := fpsrc.Stat()
buf := make([]byte, bufsize)
sumAll := 0
for {
n, err := fpsrc.Read(buf)
if err != nil && err != io.EOF {
return err
}
fmt.Print("已完成:%.2f%%\r", float64(sumAll)/float64(stat.Size())*100)
encodeBytes := starcrypto.AesDecryptCFBNoBlock(buf[:n], starcrypto.Md5([]byte(key)))
fpdst.Write(encodeBytes)
if err == io.EOF {
fmt.Print("已完成100%% \n")
break
}
}
return nil
}

@ -0,0 +1,14 @@
package aeschiper
import (
"fmt"
"testing"
)
func Test_EncodeStr(t *testing.T) {
fmt.Println(EncodeStr("我喜欢你", "sakurasaiteruyogugugug"))
}
func Test_DecodeStr(t *testing.T) {
fmt.Println(DecodeStr("Z_8aILbog@Kjm$P", "sakurasaiteruyogugugug"))
}

@ -1,45 +1,78 @@
package main
import (
"fmt"
"io"
"os"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var attachcmd = &cobra.Command{
Use: "attach",
Short: "合并个文件",
Long: "合并个文件",
Short: "合并个文件",
Long: "合并个文件",
Run: func(this *cobra.Command, args []string) {
var src, dst, out string
if len(args) == 3 {
src = args[0]
dst = args[1]
out = args[2]
} else {
src, _ = this.Flags().GetString("src")
dst, _ = this.Flags().GetString("dst")
out, _ = this.Flags().GetString("out")
}
if src == "" || dst == "" {
starlog.Criticalln("ERROR PATH")
this.Help()
return
}
cryp := new(starainrt.StarCrypto)
err := cryp.Attach(src, dst, out)
if err != nil {
starlog.Criticalln(err.Error)
} else {
fmt.Println("完成")
src, _ := this.Flags().GetStringArray("src")
out, _ := this.Flags().GetString("out")
if len(src) < 2 || out == "" {
starlog.Criticalln("请输入至少2个输入路径一个输出路径")
os.Exit(1)
}
os.Exit(runAttach(src, out))
},
}
func runAttach(src []string, out string) int {
fpOut, err := os.Create(out)
if err != nil {
starlog.Errorln("Err:无法创建输出文件!", err)
return 2
}
defer fpOut.Close()
for _, file := range src {
fpFile, err := os.OpenFile(file, os.O_RDONLY, 0644)
if err != nil {
starlog.Errorln("Err:Cannot Openfile:", err)
return 3
}
stats, err := fpFile.Stat()
if err != nil {
starlog.Errorln("Err:Cannot Get File Stats:", err)
return 4
}
if stats.Size() == 0 {
starlog.Warningf("文件:%s为空文件跳过\n", stats.Name())
continue
}
buf := make([]byte, 65535)
sumAll := 0
for {
n, err := fpFile.Read(buf)
if err != nil && err != io.EOF {
starlog.Errorln("Err:Error Occured While ReadFile:", err)
fpFile.Close()
return 5
}
sumAll += n
_, errW := fpOut.Write(buf[:n])
if errW != nil {
starlog.Errorln("Error While Write Data to OutFile", errW)
return 6
}
starlog.StdPrintf([]starlog.Attr{starlog.FgGreen}, "文件%s已完成%.2f%%\r", stats.Name(), (float64(sumAll) / float64(stats.Size()) * 100.0000))
if err == io.EOF {
starlog.StdPrintf([]starlog.Attr{starlog.FgGreen}, "文件:%v已完成100.00%% \n", stats.Name())
fpFile.Close()
break
}
}
}
starlog.StdPrintln([]starlog.Attr{starlog.FgGreen}, "Ok!文件合并完成")
return 0
}
func init() {
attachcmd.Flags().StringP("src", "s", "", "源文件路径")
attachcmd.Flags().StringP("dst", "d", "", "目标文件路径")
attachcmd.Flags().StringArrayP("src", "s", []string{}, "源文件路径")
attachcmd.Flags().StringP("out", "o", "", "输出文件路径")
}

@ -0,0 +1,59 @@
package main
import (
"fmt"
"b612.me/starcrypto"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var b64cmd = &cobra.Command{
Use: "base64",
Short: "使用base64处理文件或字符串",
Long: "使用base64处理文件或字符串",
Run: func(this *cobra.Command, args []string) {
var err error
ok, _ := this.Flags().GetBool("file")
de, _ := this.Flags().GetBool("decode")
if len(args) != 1 {
starlog.Criticalln("参数不足,请输入文件地址或字符串")
this.Help()
return
}
shell := func(pect float64) {
if pect == 100 {
fmt.Println("已处理100.000000%")
} else {
fmt.Printf("已处理:%f%%\r", pect)
}
}
if ok {
path, _ := this.Flags().GetString("path")
if !de {
err = starcrypto.Base64EncodeFile(args[0], path, shell)
} else {
err = starcrypto.Base64DecodeFile(args[0], path, shell)
}
} else {
if !de {
data := starcrypto.Base64Encode([]byte(args[0]))
fmt.Println(data)
} else {
var data []byte
data, err = starcrypto.Base64Decode(args[0])
fmt.Println(string(data))
}
}
if err != nil {
starlog.Criticalln(err)
return
}
},
}
func init() {
b64cmd.Flags().BoolP("file", "f", false, "base64处理文件")
b64cmd.Flags().StringP("path", "p", "./b64.encode", "指定处理地址,默认为./b64.encode")
b64cmd.Flags().BoolP("decode", "d", false, "base64解码")
}

@ -0,0 +1,211 @@
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
"b612.me/starainrt"
"github.com/spf13/cobra"
)
var curlcmd = &cobra.Command{
Use: "curl",
Short: "Curl工具",
Long: "Curl小工具",
Run: func(this *cobra.Command, args []string) {
var method string
var err error
var data []byte
o, _ := this.Flags().GetString("output")
d, _ := this.Flags().GetString("data")
f, _ := this.Flags().GetString("file")
h, _ := this.Flags().GetString("header")
c, _ := this.Flags().GetString("cookie")
b, _ := this.Flags().GetString("cookie-jar")
i, _ := this.Flags().GetBool("include")
x, _ := this.Flags().GetString("proxy")
m, _ := this.Flags().GetInt("max-time")
ua, _ := this.Flags().GetString("user-agent")
connecttimeout, _ := this.Flags().GetInt("connect-timeout")
if len(args) != 1 {
this.Help()
return
}
url := args[0]
shell := func(pect float64) {
if pect == 100 {
fmt.Println("已完成100.000000%")
} else {
fmt.Printf("已完成:%f%%\r", pect)
}
}
var postdata map[string]string
if d != "" {
postdata = make(map[string]string)
strip := strings.Split(d, "&")
for _, v := range strip {
tmp := strings.Split(v, "=")
if len(tmp) != 2 {
continue
}
postdata[tmp[0]] = tmp[1]
}
}
if len(d) == 0 {
method = "GET"
} else {
method = "POST"
}
tmp := strings.Split(f, ",")
curl := starainrt.NewStarCurl()
curl.TimeOut = m
curl.DialTimeOut = connecttimeout
curl.ReqHeader.Set("User-Agent", "Victorique - B612.ME")
if ua != "" {
curl.ReqHeader.Set("User-Agent", ua)
}
if x != "" {
curl.Proxy = x
}
if h != "" {
head := strings.Split(h, ",")
for _, v := range head {
hp := strings.Split(v, ":")
if len(hp) != 2 {
continue
}
curl.ReqHeader.Set(hp[0], hp[1])
}
}
if c != "" {
if starainrt.Exists(c) {
ck, err := ioutil.ReadFile(c)
if err != nil {
fmt.Println(err)
return
}
h = strings.TrimSpace(string(ck))
}
cook := strings.Split(h, ",")
for _, v := range cook {
hp := strings.Split(v, "=")
if len(hp) != 2 {
continue
}
curl.ReqCookies = append(curl.ReqCookies, &http.Cookie{Name: hp[0], Value: hp[1]})
}
}
if len(tmp) != 2 && f != "" {
fmt.Println("对file应使用逗号分隔区分文件名和路径")
return
}
if o != "" {
if f != "" {
_, err = curl.CurlWithFile(url, postdata, tmp[0], tmp[1], o, true, shell)
} else {
err = curl.CurlDataToFile(url, []byte(d), method, o, shell)
}
if err != nil {
fmt.Println(err)
}
if i {
for k, v := range curl.RespHeader {
for _, v2 := range v {
fmt.Println(k + ":" + v2)
}
}
fmt.Println("\n")
var cookiewriter string
for _, v := range curl.RespCookies {
fmt.Println(v.Name + ":" + v.Value)
if b != "" {
cookiewriter += v.Name + ":" + v.Value + ","
}
}
fmt.Println("\n\n")
if b != "" {
ioutil.WriteFile(b, []byte(cookiewriter), 0755)
}
}
} else {
if f != "" {
data, err = curl.CurlWithFile(url, postdata, tmp[0], tmp[1], "", false, shell)
} else {
data, err = curl.Curl(url, []byte(d), method)
}
if i {
for k, v := range curl.RespHeader {
for _, v2 := range v {
fmt.Println(k + ":" + v2)
}
}
fmt.Println("\n")
var cookiewriter string
for _, v := range curl.RespCookies {
fmt.Println(v.Name + ":" + v.Value)
if b != "" {
cookiewriter += v.Name + ":" + v.Value + ","
}
}
fmt.Println("\n\n")
if b != "" {
ioutil.WriteFile(b, []byte(cookiewriter), 0755)
}
}
fmt.Println(string(data))
if err != nil {
fmt.Println(err)
}
}
},
}
func init() {
curlcmd.Flags().StringP("output", "o", "", "写入文件而不是标准输出")
curlcmd.Flags().StringP("data", "d", "", "http postdata数据")
curlcmd.Flags().StringP("file", "f", "", "上传文件的地址")
curlcmd.Flags().StringP("header", "H", "", "使用的header")
curlcmd.Flags().StringP("cookie", "b", "", "使用的cookie")
curlcmd.Flags().StringP("cookie-jar", "c", "", "写入返回的cookie到文件中")
curlcmd.Flags().BoolP("include", "i", false, "显示返回的header与cookie")
curlcmd.Flags().StringP("proxy", "x", "", "使用代理")
curlcmd.Flags().IntP("max-time", "m", 0, "最大传输超时时间")
curlcmd.Flags().Int("connect-timeout", 15, "最大连接建立超时时间")
curlcmd.Flags().StringP("user-agent", "A", "", "UA设置")
curlupcmd.Flags().StringP("address", "a", "", "远端ip:端口号")
curlcmd.AddCommand(curlupcmd)
}
var curlupcmd = &cobra.Command{
Use: "upload",
Short: "victorique上传工具",
Long: "victorique上传工具",
Run: func(this *cobra.Command, args []string) {
if len(args) != 1 {
fmt.Println(args, "不合法啊")
return
}
a, _ := this.Flags().GetString("address")
curl := starainrt.NewStarCurl()
curl.TimeOut = 0
shell := func(pect float64) {
if pect == 100 {
fmt.Println("已完成100.000000%")
} else {
fmt.Printf("已完成:%f%%\r", pect)
}
}
data, err := curl.CurlWithFile("http://"+a+"/vtqeupload1127", nil, "victorique", args[0], "", false, shell)
fmt.Println(string(data))
if err != nil {
fmt.Println(err)
}
},
}

@ -0,0 +1,50 @@
package main
import (
"log"
"path/filepath"
filedriver "github.com/goftp/file-driver"
"github.com/goftp/server"
"github.com/spf13/cobra"
)
var ports int
var username, pwd string
var path, ip string
// ftpCmd represents the ftp command
var ftpcmd = &cobra.Command{
Use: "ftp",
Short: `FTP文件服务器`,
Long: `FTP文件服务器`,
Run: func(cmd *cobra.Command, args []string) {
path, _ = filepath.Abs(path)
factory := &filedriver.FileDriverFactory{
RootPath: path,
Perm: server.NewSimplePerm("user", "group"),
}
opts := &server.ServerOpts{
Factory: factory,
Port: ports,
Hostname: ip,
Auth: &server.SimpleAuth{Name: username, Password: pwd},
}
log.Printf("Starting ftp server on %v:%v", opts.Hostname, opts.Port)
log.Printf("Username %v, Password %v", username, pwd)
server := server.NewServer(opts)
err := server.ListenAndServe()
if err != nil {
log.Fatal("Error starting server:", err)
}
},
}
func init() {
ftpcmd.Flags().IntVarP(&ports, "port", "p", 21, "监听端口")
ftpcmd.Flags().StringVarP(&ip, "ip", "i", "0.0.0.0", "监听地址")
ftpcmd.Flags().StringVarP(&username, "user", "u", "1", "用户名默认为1")
ftpcmd.Flags().StringVarP(&pwd, "pwd", "k", "1", "密码默认为1")
ftpcmd.Flags().StringVarP(&path, "folder", "f", "./", "本地文件地址")
}

@ -0,0 +1,52 @@
package main
import (
"fmt"
"os"
"time"
"b612.me/starainrt"
"github.com/spf13/cobra"
)
var gencmd = &cobra.Command{
Use: "generate",
Short: "生成随机文件",
Long: "生成指定大小的随机文件",
Run: func(this *cobra.Command, args []string) {
sum, _ := this.Flags().GetInt("sum")
num, _ := this.Flags().GetInt("num")
cap, _ := this.Flags().GetInt("cap")
if len(args) != 1 {
this.Help()
return
}
if num <= 0 {
fmt.Println("num不合法不应该小于1")
os.Exit(2)
}
if sum <= 0 {
fmt.Println("sum不合法不应该小于1")
os.Exit(2)
}
if cap <= 0 {
fmt.Println("cap不合法不应该小于1")
os.Exit(2)
}
err := starainrt.FillWithRandom(args[0], num, cap, sum, func(pect float64) {
fmt.Printf("文件已处理:%f%%\r", pect)
})
if err != nil {
fmt.Println("err:" + err.Error())
}
fmt.Println("文件已处理100.0000000%")
time.Sleep(time.Millisecond * 10)
},
}
func init() {
gencmd.Flags().IntP("sum", "s", 3, "随机的种子组数")
gencmd.Flags().IntP("num", "n", 1024, "生成的文件大小")
gencmd.Flags().IntP("cap", "c", 1048576, "bufcap大小")
gencmd.MarkFlagRequired("num")
}

@ -0,0 +1,70 @@
package main
import (
"fmt"
"os"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var hashcmd = &cobra.Command{
Use: "hash",
Short: "多种方法哈希值校验",
Long: "进行多种方法哈希值校验",
Run: func(this *cobra.Command, args []string) {
var cumethod, method []string
var result map[string]string
var err error
crypto := new(starainrt.StarCrypto)
cumethod = []string{"md5", "crc32", "sha512", "sha384", "sha256", "sha224", "sha1"}
if ok, _ := this.Flags().GetBool("all"); ok {
method = cumethod
} else {
if len(args) == 0 {
this.Usage()
os.Exit(1)
}
for _, v := range cumethod {
if ok, _ := this.Flags().GetBool(v); ok {
method = append(method, v)
}
}
if len(method) == 0 {
method = append(method, "md5")
}
}
if ok, _ := this.Flags().GetBool("file"); ok {
result, err = crypto.FileSumAll(args[0], method, func(pect float64) {
if pect != 100.0 {
fmt.Printf("校验已完成:%f%%\r", pect)
} else {
fmt.Printf("校验已完成:%f%%\n", pect)
}
})
} else {
result, err = crypto.SumAll([]byte(args[0]), method)
}
if err != nil {
starlog.Criticalln("错误:" + err.Error())
}
for _, v := range method {
fmt.Printf("%s%s\n", v, result[v])
}
},
}
func init() {
hashcmd.Flags().BoolP("all", "a", false, "使用所有的校验方法")
hashcmd.Flags().BoolP("file", "f", false, "对指定文件进行校验")
hashcmd.Flags().BoolP("md5", "m", false, "进行MD5校验默认")
hashcmd.Flags().BoolP("crc32", "c", false, "进行CRC32校验")
hashcmd.Flags().BoolP("sha512", "s", false, "进行SHA512校验")
hashcmd.Flags().Bool("sha384", false, "进行SHA384校验")
hashcmd.Flags().Bool("sha256", false, "进行SHA256校验")
hashcmd.Flags().Bool("sha224", false, "进行SHA224校验")
hashcmd.Flags().Bool("sha1", false, "进行SHA1校验")
}

@ -45,7 +45,7 @@ var httpcmd = &cobra.Command{
starlog.Criticalln("Daemon Error:", err)
os.Exit(1)
}
starlog.StdPrintf([]starlog.Attr{starlog.BgGreen}, "Success,PID=%v\n", pid)
starlog.StdPrintf([]starlog.Attr{starlog.FgGreen}, "Success,PID=%v\n", pid)
return
}
err := run()
@ -68,7 +68,7 @@ func run() error {
}
defer starlog.Close()
} else {
logFp, err := os.OpenFile(logPath, os.O_APPEND, 0755)
logFp, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND, 0755)
if err != nil {
starlog.Errorln("Create LogFile Failed:", err)
os.Exit(2)

@ -0,0 +1,194 @@
package main
import (
"errors"
"image"
"io/ioutil"
"os"
"github.com/golang/freetype"
"github.com/nfnt/resize"
"image/color"
"image/draw"
_ "image/gif"
_ "image/jpeg"
"image/png"
_ "image/png"
"b612.me/starainrt"
)
func OpenImage(name string) (image.Image, error) {
if !starainrt.Exists(name) {
return nil, errors.New("File Not Exists")
}
fso, err := os.Open(name)
if err != nil {
return nil, err
}
img, _, err := image.Decode(fso)
if err != nil {
return nil, err
}
return img, nil
}
func MergePhoto(big, small image.Image, bigsize, smallsize uint, x, y int) image.Image {
big = resize.Resize(bigsize, bigsize, big, resize.Lanczos3)
small = resize.Resize(smallsize, smallsize, small, resize.Lanczos3)
offset := image.Pt(x, y)
b := big.Bounds()
nimg := image.NewRGBA(b)
draw.Draw(nimg, b, big, image.ZP, draw.Src)
draw.Draw(nimg, small.Bounds(), small, offset, draw.Over)
return nimg
}
func SavePhoto(path string, img image.Image) error {
imgf, err := os.Create(path)
if err != nil {
return err
}
defer imgf.Close()
return png.Encode(imgf, img)
}
func SetAlpha(img image.Image, alpha uint8) image.Image {
size := img.Bounds()
nimg := image.NewRGBA(size)
for x := 0; x < size.Dx(); x++ {
for y := 0; y < size.Dy(); y++ {
r, g, b, a := img.At(x, y).RGBA()
r = r >> 8
g = g >> 8
b = b >> 8
a = a >> 8
nimg.Set(x, y, color.NRGBA{uint8(r), uint8(g), uint8(b), alpha})
//nimg.Set(x, y, color.Alpha{alpha})
//nimg.Set(x, y, img.At(x, y))
}
}
return nimg
}
func AddText(text string, img image.Image, x, y int, dpi, size float64, colors color.RGBA, ttf string) (image.Image, error) {
if !starainrt.Exists(ttf) {
return nil, errors.New("File Not Exists")
}
fontbyte, err := ioutil.ReadFile(ttf)
if err != nil {
return nil, err
}
font, err := freetype.ParseFont(fontbyte)
if err != nil {
return nil, err
}
nimg, ok := img.(draw.Image)
if !ok {
size := img.Bounds()
nimg = image.NewRGBA(img.Bounds())
for x := 0; x < size.Dx(); x++ {
for y := 0; y < size.Dy(); y++ {
r, g, b, a := img.At(x, y).RGBA()
nimg.Set(x, y, color.NRGBA{uint8(r), uint8(g), uint8(b), uint8(a)})
}
}
}
f := freetype.NewContext()
f.SetDPI(dpi)
f.SetFontSize(size)
f.SetFont(font)
f.SetClip(nimg.Bounds())
f.SetDst(nimg)
f.SetSrc(image.NewUniform(colors))
_, err = f.DrawString(text, freetype.Pt(x, y))
if err != nil {
return nil, err
}
return nimg, nil
}
type TextImg struct {
Text string
X int
Y int
Dpi float64
Size float64
Color color.NRGBA
}
type TextList struct {
List []TextImg
TTF []byte
}
func AddListTests(list TextList, img image.Image) (image.Image, error) {
font, err := freetype.ParseFont(list.TTF)
if err != nil {
return nil, err
}
nimg, ok := img.(draw.Image)
if !ok {
size := img.Bounds()
nimg = image.NewRGBA(img.Bounds())
for x := 0; x < size.Dx(); x++ {
for y := 0; y < size.Dy(); y++ {
r, g, b, a := img.At(x, y).RGBA()
nimg.Set(x, y, color.NRGBA{uint8(r), uint8(g), uint8(b), uint8(a)})
}
}
}
for _, v := range list.List {
f := freetype.NewContext()
f.SetDPI(v.Dpi)
f.SetFontSize(v.Size)
f.SetFont(font)
f.SetClip(nimg.Bounds())
f.SetDst(nimg)
f.SetSrc(image.NewUniform(v.Color))
_, err = f.DrawString(v.Text, freetype.Pt(v.X, v.Y))
if err != nil {
return nil, err
}
}
return nimg, nil
}
func AddTexts(text string, img image.Image, x, y int, dpi, size float64, colors color.NRGBA, ttf string) (image.Image, error) {
if !starainrt.Exists(ttf) {
return nil, errors.New("File Not Exists")
}
fontbyte, err := ioutil.ReadFile(ttf)
if err != nil {
return nil, err
}
font, err := freetype.ParseFont(fontbyte)
if err != nil {
return nil, err
}
nimg, ok := img.(draw.Image)
if !ok {
size := img.Bounds()
nimg = image.NewRGBA(img.Bounds())
for x := 0; x < size.Dx(); x++ {
for y := 0; y < size.Dy(); y++ {
r, g, b, a := img.At(x, y).RGBA()
nimg.Set(x, y, color.NRGBA{uint8(r), uint8(g), uint8(b), uint8(a)})
}
}
}
f := freetype.NewContext()
f.SetDPI(dpi)
f.SetFontSize(size)
f.SetFont(font)
f.SetClip(nimg.Bounds())
f.SetDst(nimg)
f.SetSrc(image.NewUniform(colors))
_, err = f.DrawString(text, freetype.Pt(x, y))
if err != nil {
return nil, err
}
return nimg, nil
}

@ -0,0 +1,82 @@
package main
import (
"fmt"
"image"
"b612.me/starlog"
"github.com/spf13/cobra"
)
func init() {
imageCmd.AddCommand(imgMirrorCmd)
}
var imageCmd = &cobra.Command{
Use: "image",
Short: "图像处理",
Long: "简单的图像处理工具",
Run: func(this *cobra.Command, args []string) {
this.Help()
},
}
var imgMirrorCmd = &cobra.Command{
Use: "mirror",
Short: "图像镜像翻转",
Long: "图像镜像翻转<水平>",
Run: func(this *cobra.Command, args []string) {
if len(args) == 0 {
starlog.Errorln("请指定需要转换的图像!")
return
}
for _, v := range args {
img, err := OpenImage(v)
if err != nil {
starlog.Errorln(err, v)
continue
}
size := img.Bounds()
nimg := image.NewRGBA(size)
for x := 0; x < size.Dx(); x++ {
for y := 0; y < size.Dy(); y++ {
nimg.Set(size.Dx()-x, y, img.At(x, y))
}
}
if err := SavePhoto(v, nimg); err != nil {
starlog.Errorln(err, v)
continue
} else {
fmt.Println(v, "转换已完成!")
}
}
fmt.Println("任务完成!")
},
}
var imgAlpha = &cobra.Command{
Use: "alpha",
Short: "设置透明度",
Long: "设置alpha通道透明度",
Run: func(this *cobra.Command, args []string) {
if len(args) == 0 {
starlog.Errorln("请指定需要转换的图像!")
return
}
for _, v := range args {
img, err := OpenImage(v)
if err != nil {
starlog.Errorln(err, v)
continue
}
img = SetAlpha(img, 4)
if err := SavePhoto(v, img); err != nil {
starlog.Errorln(err, v)
continue
} else {
fmt.Println(v, "转换已完成!")
}
}
fmt.Println("任务完成!")
},
}

@ -1,20 +1,23 @@
package main
import (
"fmt"
"github.com/spf13/cobra"
)
// Vtqe is my own toolbox
func init() {
cmdMain.AddCommand(tcpingcmd, httpcmd, attachcmd, detachcmd)
cmdMain.AddCommand(tcpingcmd, httpcmd, attachcmd, detachcmd, b64cmd, ftpcmd, gencmd, hashcmd, imageCmd, mergecmd, netcmd, sftpcmd, splitcmd, tcpcmd, udpcmd, viccmd, curlcmd)
}
const vtqe_version string = "v1.0.0NG RC1"
const vtqe_version string = "v1.0.0rc1"
var cmdMain = &cobra.Command{
Short: "Victorique Wisdom ToolBox",
Long: "中二的工具箱:未来を照らし出せ!",
Short: "Victorique's Wisdom ToolBox",
Long: fmt.Sprintf(`Victorique's Wisdom ToolBox @%v
@B612.ME`, vtqe_version),
Version: vtqe_version,
}

@ -0,0 +1,47 @@
package main
import (
"fmt"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var mergecmd = &cobra.Command{
Use: "merge",
Short: "合并文件",
Long: "按路径自动合并分割的文件",
Run: func(this *cobra.Command, args []string) {
var src, dst string
if len(args) == 2 {
src = args[0]
dst = args[1]
} else {
src, _ = this.Flags().GetString("src")
dst, _ = this.Flags().GetString("dst")
}
if src == "" || dst == "" {
this.Help()
return
}
crypto := new(starainrt.StarCrypto)
err := crypto.MergeFile(src, dst, func(pect float64) {
if pect == 100 {
fmt.Println("文件已处理100.000000%")
} else {
fmt.Printf("文件已处理:%f%%\r", pect)
}
})
if err != nil {
starlog.Errorln(err.Error)
}
},
}
func init() {
mergecmd.Flags().StringP("src", "s", "", "源文件地址,用*替换文件数字")
mergecmd.Flags().StringP("dst", "d", "", "目标文件地址")
}

@ -0,0 +1,806 @@
package main
import (
"fmt"
"io"
"net"
"strconv"
"strings"
"time"
"github.com/spf13/cobra"
)
func init() {
netcmd.AddCommand(netforwardcmd, natscmd, natccmd)
netforwardcmd.Flags().BoolP("tcp", "t", false, "TCP转发")
netforwardcmd.Flags().BoolP("udp", "u", false, "UDP转发")
netforwardcmd.Flags().IntP("port", "p", 1127, "转发本地端口")
netforwardcmd.Flags().StringP("address", "a", "0.0.0.0", "监听地址")
natscmd.Flags().BoolP("tcp", "t", false, "TCP穿透")
natscmd.Flags().BoolP("udp", "u", false, "UDP穿透")
natscmd.Flags().IntP("port", "p", 1127, "监听本地端口开始点")
natscmd.Flags().StringP("key", "k", "sakura", "认证密码")
natscmd.Flags().StringP("address", "a", "0.0.0.0", "监听本地地址")
natscmd.Flags().IntP("number", "n", 1, "监听端口数量")
natccmd.Flags().BoolP("tcp", "t", false, "TCP穿透")
natccmd.Flags().BoolP("udp", "u", false, "UDP穿透")
natccmd.Flags().IntP("port", "p", 1127, "转发穿透端口")
natccmd.Flags().StringP("key", "k", "sakura", "认证密码")
natccmd.Flags().StringP("address", "a", "127.0.0.1", "转发穿透地址")
}
var netcmd = &cobra.Command{
Use: "net",
Short: "端口转发,穿透相关",
Long: "端口转发,穿透相关",
}
var netforwardcmd = &cobra.Command{
Use: "forward",
Short: "TCP/UDP端口转发",
Long: "TCP/UDP端口转发",
Run: func(cmd *cobra.Command, args []string) {
t, _ := cmd.Flags().GetBool("tcp")
u, _ := cmd.Flags().GetBool("udp")
p, _ := cmd.Flags().GetInt("port")
a, _ := cmd.Flags().GetString("address")
if len(args) != 1 {
cmd.Help()
return
}
ra := args[0]
if !t && !u {
fmt.Println("请指定TCP或UDP协议")
return
}
localtcp, err := net.ResolveTCPAddr("tcp", a+":"+strconv.Itoa(p))
if err != nil {
fmt.Println(err)
return
}
remotetcp, err := net.ResolveTCPAddr("tcp", ra)
if err != nil {
fmt.Println(err)
return
}
localudp, _ := net.ResolveUDPAddr("udp", a+":"+strconv.Itoa(p))
remoteudp, _ := net.ResolveUDPAddr("udp", ra)
if u {
go UdpForward(localudp, remoteudp)
}
if t {
go TcpForward(localtcp, remotetcp)
}
for {
time.Sleep(time.Second * 100)
}
},
}
var natscmd = &cobra.Command{
Use: "nats",
Short: "TCP/UDP内网穿透服务端",
Long: "TCP/UDP内网穿透服务端",
Run: func(cmd *cobra.Command, args []string) {
t, _ := cmd.Flags().GetBool("tcp")
u, _ := cmd.Flags().GetBool("udp")
p, _ := cmd.Flags().GetInt("port")
k, _ := cmd.Flags().GetString("key")
a, _ := cmd.Flags().GetString("address")
n, _ := cmd.Flags().GetInt("number")
/*udplocal, err := net.ResolveUDPAddr("udp", a+":"+p)
if err != nil {
fmt.Println(err)
return
}
*/
for i := 0; i < n; i++ {
tcplocal, err := net.ResolveTCPAddr("tcp", a+":"+strconv.Itoa(p+i))
if err != nil {
fmt.Println(err)
return
}
udplocal, _ := net.ResolveUDPAddr("udp", a+":"+strconv.Itoa(p+i))
if !t && !u {
fmt.Println("请至少指定一种网络协议!")
return
}
if t {
go TcpNatServer(tcplocal, k)
}
if u {
go UdpNatServer(udplocal, k)
}
}
for {
time.Sleep(time.Second * 10)
}
},
}
var natccmd = &cobra.Command{
Use: "natc",
Short: "TCP/UDP内网穿透客户端",
Long: "TCP/UDP内网穿透客户端",
Run: func(cmd *cobra.Command, args []string) {
t, _ := cmd.Flags().GetBool("tcp")
u, _ := cmd.Flags().GetBool("udp")
p, _ := cmd.Flags().GetInt("port")
k, _ := cmd.Flags().GetString("key")
a, _ := cmd.Flags().GetString("address")
/*udplocal, err := net.ResolveUDPAddr("udp", a+":"+p)
if err != nil {
fmt.Println(err)
return
}
*/
if len(args) != 1 {
cmd.Help()
return
}
if !t && !u {
fmt.Println("请至少指定一种网络协议!")
return
}
tcprmt, err := net.ResolveTCPAddr("tcp", args[0])
if err != nil {
fmt.Println(err)
return
}
tcpforward, err := net.ResolveTCPAddr("tcp", a+":"+strconv.Itoa(p))
if err != nil {
fmt.Println(err)
return
}
udprmt, _ := net.ResolveUDPAddr("udp", args[0])
udpforward, _ := net.ResolveUDPAddr("udp", a+":"+strconv.Itoa(p))
if t {
go TcpNatClient(tcprmt, tcpforward, k)
}
if u {
go UdpNatClient(udprmt, udpforward, k)
}
for {
time.Sleep(time.Second * 10)
}
},
}
type tcpnat struct {
Conn *net.TCPConn
Msg []byte
Date int64
}
func UdpNatClient(udpremote, udpforward *net.UDPAddr, pwd string) {
var trueconn *net.UDPConn
var err error
ismain := false
var lastcheck int64
dialudp := func(udpaddr *net.UDPAddr) (*net.UDPConn, error) {
trueconn, err := net.DialUDP("udp", nil, udpaddr)
if err != nil {
return nil, err
}
return trueconn, nil
}
defer func() {
if err := recover(); err != nil {
fmt.Println("PANIC:", err)
}
}()
for {
trueconn, err = dialudp(udpremote)
if err != nil || trueconn == nil {
time.Sleep(5 * time.Second)
fmt.Println(err)
continue
}
fmt.Println("UDP远端服务器连接成功" + trueconn.RemoteAddr().String())
trueconn.Write([]byte(pwd))
go func() {
for !ismain {
time.Sleep(time.Second * 2)
if trueconn != nil {
if ismain {
return
}
_, err := trueconn.Write([]byte(pwd))
if err != nil {
fmt.Println(err)
return
}
}
}
}()
go func() {
for {
if trueconn == nil {
break
}
var conn1, conn2 *net.UDPConn
buf := make([]byte, 7)
n, err := trueconn.Read(buf)
if n != 7 || err != nil {
fmt.Println(err)
trueconn = nil
ismain = false
fmt.Println("UDP下线01")
break
}
switch string(buf) {
case "yesyesi":
ismain = true
fmt.Println("UDP主节点认证成功")
lastcheck = time.Now().Unix()
go func() {
for {
time.Sleep(time.Second * 2)
if time.Now().Unix()-lastcheck > 4 {
ismain = false
trueconn = nil
fmt.Println("UDP下线02")
return
}
}
}()
case "vicregs":
if trueconn != nil {
trueconn.Write([]byte("vicregs"))
}
lastcheck = time.Now().Unix()
case "newconn":
if !ismain {
trueconn.Close()
break
}
for conn1, err = dialudp(udpforward); err != nil; conn1, err = dialudp(udpforward) {
time.Sleep(time.Second * 2)
}
fmt.Println("UDP已连接转发远端" + conn1.RemoteAddr().String())
for conn2, err = dialudp(udpremote); err != nil; conn2, err = dialudp(udpremote) {
time.Sleep(time.Second * 2)
}
conn2.Write([]byte("v%2^f&K"))
fmt.Println("UDP已连接主控远端" + conn2.RemoteAddr().String())
go UdpCopy(conn1, conn2)
go UdpCopy(conn2, conn1)
}
}
}()
for ismain || trueconn != nil {
time.Sleep(time.Second * 4)
}
ismain = false
}
}
func TcpNatClient(tcpremote, tcpforward *net.TCPAddr, pwd string) {
var trueconn *net.TCPConn
var err error
ismain := false
var lastcheck int64
dialtcp := func(tcpaddr *net.TCPAddr) (*net.TCPConn, error) {
trueconn, err := net.DialTCP("tcp", nil, tcpaddr)
if err != nil {
return nil, err
}
return trueconn, nil
}
defer func() {
if err := recover(); err != nil {
fmt.Println("PANIC:", err)
}
}()
for {
trueconn, err = dialtcp(tcpremote)
if err != nil || trueconn == nil {
fmt.Println(err)
time.Sleep(5 * time.Second)
continue
}
fmt.Println("TCP远端服务器连接成功" + trueconn.RemoteAddr().String())
n, err := trueconn.Write([]byte(pwd))
if err != nil || n == 0 {
fmt.Println(err)
continue
}
go func() {
for {
time.Sleep(time.Second * 2)
if !ismain {
if trueconn != nil {
_, err := trueconn.Write([]byte(pwd))
if err != nil {
return
}
} else {
return
}
} else {
return
}
}
}()
go func() {
for {
if trueconn == nil {
break
}
var conn1, conn2 *net.TCPConn
buf := make([]byte, 7)
n, err := trueconn.Read(buf)
if n != 7 || err != nil {
fmt.Println("TCP下线01")
fmt.Println(err)
trueconn = nil
ismain = false
break
}
switch string(buf) {
case "yesyesi":
ismain = true
fmt.Println("TCP主节点认证成功")
lastcheck = time.Now().Unix()
go func() {
for {
time.Sleep(time.Second)
if time.Now().Unix()-lastcheck > 4 {
fmt.Println("TCP下线02")
ismain = false
trueconn = nil
return
}
}
}()
case "vicb612":
lastcheck = time.Now().Unix()
if trueconn != nil {
trueconn.Write([]byte("vicb612"))
}
case "newconn":
if !ismain {
trueconn.Close()
trueconn = nil
fmt.Println("TCP下线03")
break
}
for conn1, err = dialtcp(tcpforward); err != nil; conn1, err = dialtcp(tcpforward) {
time.Sleep(time.Second * 2)
}
fmt.Println("TCP已连接转发远端" + conn1.RemoteAddr().String())
for conn2, err = dialtcp(tcpremote); err != nil; conn2, err = dialtcp(tcpremote) {
time.Sleep(time.Second * 2)
}
conn2.Write([]byte("v%2^f&K"))
fmt.Println("TCP已连接主控远端" + conn2.RemoteAddr().String())
go TcpCopy(conn1, conn2)
go TcpCopy(conn2, conn1)
}
}
}()
for ismain || trueconn != nil {
time.Sleep(time.Second * 4)
}
ismain = false
}
}
func TcpCopy3(dst net.Conn, src *net.TCPConn) {
defer dst.Close()
defer src.Close()
io.Copy(dst, src)
}
func TcpCopy2(dst *net.TCPConn, src net.Conn) {
defer src.Close()
defer dst.Close()
io.Copy(dst, src)
}
func TcpCopy(dst, src *net.TCPConn) {
defer dst.Close()
defer src.Close()
io.Copy(dst, src)
}
func UdpCopy(dst, src *net.UDPConn) {
defer dst.Close()
defer src.Close()
for {
buf := make([]byte, 131072)
n, err := src.Read(buf)
dst.Write(buf[0:n])
if err != nil {
fmt.Println(err)
break
}
}
}
type udpnat struct {
Conn *net.UDPAddr
Msg []byte
Married bool
LastTrans int64
}
func UdpNatServer(udplocal *net.UDPAddr, pwd string) {
var trueconn *net.UDPAddr
isconn := false
var lastcheck int64
udplistener, err := net.ListenUDP("udp", udplocal)
defer udplistener.Close()
if err != nil {
fmt.Println(err)
return
}
udpconnlist := []string{}
udpool := make(map[string]*udpnat)
udpdial := make(map[string]*net.UDPAddr)
fmt.Println("UDP已建立监听" + udplistener.LocalAddr().String())
removeudplist := func(str string) {
var tmp []string
for _, v := range udpconnlist {
if v != str {
tmp = append(tmp, str)
}
}
udpconnlist = tmp
}
go func() {
for {
time.Sleep(time.Second * 20)
pool := []string{}
for k, v := range udpool {
if time.Now().Unix()-v.LastTrans > 30 {
pool = append(pool, k)
}
}
for _, v := range pool {
if udpool[v].Married {
delete(udpdial, udpool[v].Conn.String())
} else {
removeudplist(v)
}
delete(udpool, v)
}
}
}()
for {
buf := make([]byte, 131072)
n, conn, errp := udplistener.ReadFromUDP(buf)
go func() {
if !isconn {
if errp != nil {
return
}
if string(buf[0:len(pwd)]) == pwd && n == len(pwd) {
isconn = true
trueconn = conn
udplistener.WriteToUDP([]byte("yesyesi"), trueconn)
fmt.Println("UDP穿透客户端已注册")
udpool = make(map[string]*udpnat)
udpdial = make(map[string]*net.UDPAddr)
udpconnlist = []string{}
lastcheck = time.Now().Unix()
go func() {
for {
time.Sleep(time.Second * 2)
go udplistener.WriteToUDP([]byte("vicregs"), trueconn)
if time.Now().Unix()-lastcheck > 6 {
fmt.Println("UDP穿透客户端已下线")
fmt.Println("UDP下线01")
isconn = false
break
}
}
}()
}
} else {
if string(buf[0:7]) == "vicregs" {
lastcheck = time.Now().Unix()
return
}
if string(buf[0:7]) == "v%2^f&K" {
fmt.Println("穿透客户端已建立新连接")
if len(udpconnlist) != 0 {
if v, ok := udpool[udpconnlist[0]]; ok {
if !v.Married {
v.Conn = conn
udplistener.WriteToUDP(v.Msg, conn)
v.Msg = []byte{}
udpaddr, _ := net.ResolveUDPAddr("udp", udpconnlist[0])
udpdial[conn.String()] = udpaddr
v.Married = true
}
}
if len(udpconnlist) == 1 {
udpconnlist = []string{}
} else {
udpconnlist = udpconnlist[1:]
}
}
return
} else {
if v, ok := udpool[conn.String()]; ok {
if !v.Married {
for i := 0; i < n; i++ {
v.Msg = append(v.Msg, buf[i])
}
if len(v.Msg) > 10485760 {
v.Msg = []byte{}
}
} else {
_, err := udplistener.WriteToUDP(buf[0:n], v.Conn)
v.LastTrans = time.Now().Unix()
if errp != nil || err != nil {
fmt.Println(errp, err)
udplistener.WriteToUDP(nil, v.Conn)
udplistener.WriteToUDP(nil, conn)
delete(udpool, conn.String())
delete(udpdial, v.Conn.String())
return
}
}
return
}
if v, ok := udpdial[conn.String()]; ok {
_, err := udplistener.WriteToUDP(buf[0:n], v)
udpool[v.String()].LastTrans = time.Now().Unix()
if errp != nil || err != nil {
fmt.Println(errp, err)
udplistener.WriteToUDP(nil, v)
udplistener.WriteToUDP(nil, conn)
delete(udpool, v.String())
delete(udpdial, conn.String())
return
}
return
}
fmt.Println("链接已加入等待列表")
udpool[conn.String()] = &udpnat{
Msg: buf[0:n],
Married: false,
LastTrans: time.Now().Unix(),
}
udpconnlist = append(udpconnlist, conn.String())
_, err := udplistener.WriteToUDP([]byte("newconn"), trueconn)
if err != nil {
fmt.Println("UDP穿透客户端已下线")
fmt.Println("UDP下线02")
isconn = false
}
}
}
}()
}
fmt.Println("执行完毕")
}
func TcpNatServer(tcplocal *net.TCPAddr, pwd string) {
var trueconn *net.TCPConn
lastcheck := int64(0)
isconn := false
tcplistener, err := net.ListenTCP("tcp", tcplocal)
defer tcplistener.Close()
var waitconn []tcpnat
if err != nil {
fmt.Println(err)
return
}
fmt.Println("TCP已建立监听" + tcplistener.Addr().String())
for {
conn, err := tcplistener.AcceptTCP()
if err != nil {
return
}
go func() {
for {
now := time.Now().Unix()
if len(waitconn) != 0 {
if now-waitconn[0].Date > 8 {
waitconn[0].Conn.Close()
if len(waitconn) > 1 {
waitconn = waitconn[1:]
} else {
waitconn = []tcpnat{}
}
}
}
time.Sleep(time.Second * 2)
}
}()
go func() {
if !isconn {
buf := make([]byte, len(pwd)+1)
n, err := conn.Read(buf)
if n != len(pwd) || err != nil {
conn.Close()
return
}
if string(buf[0:len(pwd)]) == pwd {
isconn = true
trueconn = conn
conn.Write([]byte("yesyesi"))
fmt.Println("TCP穿透客户端已注册")
lastcheck = time.Now().Unix()
go func() {
for isconn && trueconn != nil {
buf := make([]byte, 7)
n, err := trueconn.Read(buf)
if n != 7 || err != nil {
isconn = false
trueconn = nil
return
}
if string(buf) == "vicb612" {
lastcheck = time.Now().Unix()
}
}
}()
go func() {
for {
time.Sleep(time.Second * 2)
if trueconn != nil {
_, err := trueconn.Write([]byte("vicb612"))
if err != nil {
trueconn.Close()
trueconn = nil
isconn = false
fmt.Println("TCP下线01")
return
}
}
if time.Now().Unix()-lastcheck > 4 {
fmt.Println("TCP下线02")
trueconn = nil
isconn = false
return
}
}
}()
}
return
} else {
isRun := false
buf := make([]byte, 7)
if strings.Split(conn.RemoteAddr().String(), ":")[0] == strings.Split(trueconn.RemoteAddr().String(), ":")[0] {
isRun = true
n, err := conn.Read(buf)
if n != 7 || err != nil {
conn.Close()
return
}
}
if string(buf) == "v%2^f&K" {
fmt.Println("穿透客户端已建立新连接")
if len(waitconn) != 0 {
if waitconn[0].Msg != nil {
conn.Write(waitconn[0].Msg)
}
waitconn[0].Msg = []byte{}
go TcpCopy(waitconn[0].Conn, conn)
go TcpCopy(conn, waitconn[0].Conn)
if len(waitconn) > 1 {
waitconn = waitconn[1:]
} else {
waitconn = []tcpnat{}
}
} else {
conn.Close()
}
} else {
fmt.Println("链接已加入等待列表")
var tcpnats tcpnat
if isRun {
tcpnats = tcpnat{Msg: buf, Conn: conn, Date: time.Now().Unix()}
} else {
tcpnats = tcpnat{Msg: nil, Conn: conn, Date: time.Now().Unix()}
}
waitconn = append(waitconn, tcpnats)
if trueconn == nil {
isconn = false
fmt.Println("TCP下线04")
return
}
_, err := trueconn.Write([]byte("newconn"))
if err != nil {
fmt.Println("穿透客户端已下线")
fmt.Println("TCP下线03")
trueconn.Close()
trueconn = nil
isconn = false
}
}
}
}()
}
}
func TcpForward(tcplocal, tcpforward *net.TCPAddr) {
tcplistener, err := net.ListenTCP("tcp", tcplocal)
if err != nil {
fmt.Println(err)
return
}
dialtcp := func() (*net.Conn, error) {
tcpclient, err := net.DialTimeout("tcp", tcpforward.String(), time.Second*10)
if err != nil {
return nil, err
}
return &tcpclient, nil
}
fmt.Println("TCP监听已建立" + tcplocal.String())
for {
conn, err := tcplistener.AcceptTCP()
if err != nil {
continue
}
fmt.Println(conn.RemoteAddr().String() + " 已连接")
tcpclient, err := dialtcp()
if err != nil {
fmt.Println(err)
conn.Write([]byte("Dial To Remote Addr Error"))
conn.Close()
continue
}
fmt.Println("成功连接到转发端口,本地端口:" + (*tcpclient).LocalAddr().String())
go TcpCopy2(conn, *tcpclient)
go TcpCopy3(*tcpclient, conn)
}
}
func UdpForward(udplocal, udpforward *net.UDPAddr) {
udplistener, err := net.ListenUDP("udp", udplocal)
if err != nil {
fmt.Println(err)
return
}
dialudp := func() (*net.UDPConn, error) {
udpclient, err := net.DialUDP("udp", nil, udpforward)
if err != nil {
return nil, err
}
return udpclient, nil
}
fmt.Println("UDP监听已建立" + udplocal.String())
udppool := make(map[string]*net.UDPConn)
for {
buf := make([]byte, 131072)
n, conn, err := udplistener.ReadFromUDP(buf)
udpclient, ok := udppool[conn.String()]
if !ok || udpclient == nil {
fmt.Println(conn.String() + " 已连接")
udpclient, err = dialudp()
if err != nil {
fmt.Println(err)
udplistener.WriteToUDP([]byte("Dial To Remote Addr Error"), conn)
continue
}
udppool[conn.String()] = udpclient
fmt.Println("成功连接到转发端口,本地端口:" + udpclient.LocalAddr().String())
}
go udpclient.Write(buf[0:n])
go func(conns *net.UDPAddr, udpclient *net.UDPConn) {
bufs := make([]byte, 131072)
n, err := udpclient.Read(bufs)
udplistener.WriteToUDP(bufs[0:n], conns)
if err != nil {
udpclient.Close()
udppool[conn.String()] = nil
}
}(conn, udpclient)
if err != nil {
udpclient.Close()
udppool[conn.String()] = nil
}
}
}

@ -0,0 +1,172 @@
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"runtime"
"strings"
"b612.me/starainrt"
"b612.me/sshd"
"github.com/spf13/cobra"
)
var sftpcmd = &cobra.Command{
Use: "sftp",
Short: "sftp上传下载",
Long: "sftp上传下载",
Run: func(this *cobra.Command, args []string) {
d, _ := this.Flags().GetBool("download")
s, _ := this.Flags().GetString("src")
r, _ := this.Flags().GetString("dst")
i, _ := this.Flags().GetString("identify")
k, _ := this.Flags().GetString("password")
p, _ := this.Flags().GetInt("port")
b, _ := this.Flags().GetInt("buffer")
g, _ := this.Flags().GetString("regexp")
var user, host string
var err error
if len(args) != 1 {
fmt.Println("sftp <[user@]Host> -s <Local> -d <Remote>")
this.Help()
return
}
hosts := strings.Split(args[0], "@")
if len(hosts) == 1 {
host = hosts[0]
user = "root"
} else {
user = hosts[0]
host = hosts[1]
}
fmt.Println("进行SSH连接……")
myssh := new(sshd.StarSSH)
err = myssh.Connect(user, k, host, i, p)
if err != nil {
fmt.Println(err)
return
}
defer myssh.Close()
fmt.Println("已连接上……")
sftp, err := sshd.CreateSftp(myssh.Client)
if err != nil {
fmt.Println(err)
return
}
defer sftp.Close()
fmt.Println("已建立SFTP……")
shell := func(pect float64) {
if pect != 100.0 {
fmt.Printf("传输已完成:%f%%\r", pect)
} else {
fmt.Printf("传输已完成:%f%%\n", pect)
}
}
var UploadDir func(string, string)
UploadDir = func(fs, remote string) {
if runtime.GOOS == "windows" {
fs = strings.Replace(fs, "/", "\\", -1)
}
sftp.MkdirAll(remote)
abspath, _ := filepath.Abs(fs)
dir, err := ioutil.ReadDir(fs)
if err != nil {
fmt.Println(err)
return
}
for _, v := range dir {
if v.IsDir() {
if g != "" {
continue
}
UploadDir(abspath+string(os.PathSeparator)+v.Name(), remote+"/"+v.Name())
} else {
if ok, _ := regexp.MatchString(g, v.Name()); !ok {
continue
}
fmt.Println("上传:" + abspath + string(os.PathSeparator) + v.Name())
err = sshd.FtpTransferOutFunc(abspath+string(os.PathSeparator)+v.Name(), remote+"/"+v.Name(), b, shell, sftp)
if err != nil {
fmt.Println(err)
continue
}
}
}
}
var DownloadDir func(string, string)
DownloadDir = func(fs, remote string) {
abspath, _ := filepath.Abs(remote)
os.MkdirAll(abspath, 0755)
dir, err := sftp.ReadDir(fs)
if err != nil {
fmt.Println("读取错误", err)
return
}
for _, v := range dir {
if v.IsDir() {
if g != "" {
continue
}
DownloadDir(fs+"/"+v.Name(), abspath+string(os.PathSeparator)+v.Name())
} else {
if ok, _ := regexp.MatchString(g, v.Name()); !ok {
continue
}
fmt.Println("下载:" + fs + "/" + v.Name())
err = sshd.FtpTransferInFunc(fs+"/"+v.Name(), abspath+string(os.PathSeparator)+v.Name(), b, shell, sftp)
if err != nil {
fmt.Println(err)
continue
}
}
}
}
if !d {
if !starainrt.Exists(s) {
fmt.Println("本地文件或文件夹:" + s + "不存在")
return
}
if starainrt.IsFile(s) {
err = sshd.FtpTransferOutFunc(s, r, b, shell, sftp)
} else {
UploadDir(s, r)
}
} else {
if !myssh.Exists(s) {
fmt.Println("远端文件或文件夹:" + s + "不存在")
return
}
stat, err := sftp.Stat(s)
if err != nil {
fmt.Println("错误:", err)
return
}
if !stat.IsDir() {
err = sshd.FtpTransferInFunc(s, r, b, shell, sftp)
} else {
DownloadDir(s, r)
}
}
if err != nil {
fmt.Println(err)
}
},
}
func init() {
sftpcmd.Flags().BoolP("download", "D", false, "进行下载")
sftpcmd.Flags().StringP("identify", "i", "", "RSA登录密钥")
sftpcmd.Flags().StringP("password", "k", "", "登录密码")
sftpcmd.Flags().StringP("src", "s", "", "本机路径/若为下载则相反")
sftpcmd.Flags().StringP("dst", "d", "", "远程路径/若为下载则相反")
sftpcmd.Flags().IntP("port", "p", 22, "登录端口")
sftpcmd.Flags().StringP("regexp", "r", "", "正则表达式")
sftpcmd.Flags().IntP("buffer", "b", 10240, "buffer大小")
}

@ -0,0 +1,60 @@
package main
import (
"fmt"
"strconv"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var splitcmd = &cobra.Command{
Use: "split",
Short: "分割文件",
Long: "按字节或文件数分割文件",
Run: func(this *cobra.Command, args []string) {
var src, dst string
var num int
if len(args) == 3 {
src = args[0]
dst = args[1]
num, _ = strconv.Atoi(args[2])
} else {
src, _ = this.Flags().GetString("src")
dst, _ = this.Flags().GetString("dst")
num, _ = this.Flags().GetInt("num")
}
if !starainrt.Exists(src) {
starlog.Errorln("源文件不存在")
this.Help()
return
}
if num == 0 {
starlog.Errorln("参数num不合法", "red")
this.Help()
return
}
crypto := new(starainrt.StarCrypto)
ok, _ := this.Flags().GetBool("byte")
err := crypto.SplitFile(src, dst, num, !ok, func(pect float64) {
if pect == 100 {
fmt.Println("文件已处理100.000000%")
} else {
fmt.Printf("文件已处理:%f%%\r", pect)
}
})
if err != nil {
starlog.Errorln(err.Error)
}
},
}
func init() {
splitcmd.Flags().StringP("src", "s", "", "源文件地址")
splitcmd.Flags().StringP("dst", "d", "./split*.vicque", "目标文件地址,用*替换文件数字")
splitcmd.Flags().BoolP("byte", "b", false, "按byte分割")
splitcmd.Flags().IntP("num", "n", 0, "分割数/byte数")
}

@ -0,0 +1,442 @@
package main
import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"time"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var tcpcmd = &cobra.Command{
Use: "tcp",
Short: "发送并监听tcp数据包",
Long: "发送并监听tcp数据包",
Run: func(this *cobra.Command, args []string) {
r, _ := this.Flags().GetBool("recvonly")
if len(args) != 1 && !r {
fmt.Println("请指定远程tcp地址")
return
}
l, _ := this.Flags().GetString("port")
a, _ := this.Flags().GetString("addr")
s, _ := this.Flags().GetBool("local")
b, _ := this.Flags().GetBool("byte")
laddr, err := net.ResolveTCPAddr("tcp", a+":"+l)
if err != nil {
fmt.Println(err)
return
}
if s {
tcplisten, err := net.ListenTCP("tcp", laddr)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("监听已建立")
defer tcplisten.Close()
go func() {
for {
conn, err := tcplisten.AcceptTCP()
if err != nil {
fmt.Printf("Error Connect From %s : %s\n", conn.RemoteAddr(), err.Error())
continue
}
starlog.Infof("Accept Connect From %s\n", conn.RemoteAddr())
go func(conns *net.TCPConn) {
for {
buf := make([]byte, 204800)
n, err := conns.Read(buf)
if err != nil {
starlog.Infof("Error from %s Where Message=%s\n", conns.RemoteAddr(), err.Error())
conn.Close()
return
}
starlog.Infof("Receive Msg From %s : %s\n", conns.RemoteAddr(), string(buf[0:n]))
if b {
starlog.Infof("%#v", buf[0:n])
}
}
}(conn)
}
}()
}
if !r {
mytcp, err := net.DialTimeout("tcp", args[0], time.Second*15)
if err != nil {
fmt.Println(err)
if s {
for {
time.Sleep(time.Second * 10)
}
}
return
}
defer mytcp.Close()
fmt.Println("TCP连接已建立")
go func() {
var err error
for {
txt := starainrt.MessageBox("", "")
if txt == "" {
continue
}
if !b {
_, err = mytcp.Write([]byte(txt))
} else {
var sendbyte []byte
bytes := strings.Split(txt, ",")
for _, v := range bytes {
ints, _ := strconv.Atoi(v)
if ints < 0 || ints > 255 {
continue
}
sendbyte = append(sendbyte, byte(ints))
}
_, err = mytcp.Write(sendbyte)
}
if err != nil {
starlog.Errorf("Error from %s Where Message=%s\n", mytcp.RemoteAddr().String(), err.Error())
return
}
}
}()
for {
buf := make([]byte, 204800)
n, err := mytcp.Read(buf)
if err != nil {
starlog.Errorf("Error from %s Where Message=%s\n", mytcp.RemoteAddr().String(), err.Error())
return
}
starlog.Infof("Receive Msg From %s : %s\n", mytcp.RemoteAddr().String(), string(buf[0:n]))
if b {
starlog.Infof("%#v", buf[0:n])
}
}
} else {
for {
time.Sleep(time.Second)
}
}
},
}
/*
*/
func init() {
tcpcmd.Flags().BoolP("byte", "b", false, "发送二进制数据")
tcpcmd.Flags().StringP("port", "p", "1127", "本地监听端口")
tcpcmd.Flags().StringP("addr", "a", "0.0.0.0", "本地监听ip")
tcpcmd.Flags().BoolP("local", "s", false, "启动本地监听")
tcpsendcmd.Flags().StringP("port", "p", "1127", "远程连接端口")
tcpsendcmd.Flags().StringP("addr", "a", "0.0.0.0", "远程监听ip")
tcpsendcmd.Flags().StringP("regexp", "r", "", "正则匹配字符串")
tcprecvcmd.Flags().StringP("port", "p", "1127", "本地监听端口")
tcprecvcmd.Flags().StringP("addr", "a", "0.0.0.0", "本地监听ip")
tcpcmd.Flags().BoolP("recvonly", "r", false, "仅接收udp包")
tcpcmd.AddCommand(tcpsendcmd, tcprecvcmd)
}
var cansend, backsck, foldercreate bool = false, false, false
var tcpsendcmd = &cobra.Command{
Use: "send",
Short: "通过tcp发送文件",
Long: "通过tcp接受文件",
Run: func(this *cobra.Command, args []string) {
stop := false
p, _ := this.Flags().GetString("port")
a, _ := this.Flags().GetString("addr")
r, _ := this.Flags().GetString("regexp")
if len(args) != 1 {
this.Help()
return
}
mytcp, err := net.DialTimeout("tcp", a+":"+p, time.Second*15)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("TCP连接已建立")
defer mytcp.Close()
go func() {
for {
buf := make([]byte, 1048576)
n, err := mytcp.Read(buf)
if err != nil {
if !stop {
fmt.Println(err)
os.Exit(1)
}
continue
}
data := string(buf[0:n])
if data == "oksend!" {
cansend = true
} else if data == "backsck" {
backsck = true
} else if data == "folderok" {
foldercreate = true
} else {
fmt.Println(data)
os.Exit(1)
}
}
}()
file := args[0]
if file[len(file)-1:] == "\\" || file[len(file)-1:] == "/" {
file = file[0 : len(file)-1]
}
file, _ = filepath.Abs(file)
Scan(file, "", mytcp, r)
stop = true
mytcp.Write([]byte("jane&0&0"))
return
},
}
func tcpupload(file, prefix string, mytcp net.Conn) error {
if runtime.GOOS == "windows" {
file = strings.Replace(file, "/", "\\", -1)
prefix = strings.Replace(prefix, "/", "\\", -1)
}
fmt.Println(file)
fpsrc, err := os.Open(file)
if err != nil {
fmt.Println(err)
return err
}
stat, _ := os.Stat(file)
filebig := float64(stat.Size())
_, err = mytcp.Write([]byte("victorique&" + stat.Name() + "&" + prefix))
if err != nil {
fmt.Println(err)
return err
}
var sakura int = 0
for !cansend {
time.Sleep(time.Millisecond * 100)
sakura++
if sakura > 50 {
mytcp.Write([]byte{1, 9, 9, 6, 1, 1, 2, 7})
time.Sleep(time.Millisecond * 100)
mytcp.Write([]byte("victorique&" + stat.Name() + "&" + prefix))
}
}
cansend = false
sum := 0
for {
buf := make([]byte, 524288)
n, err := fpsrc.Read(buf)
if err != nil {
if err == io.EOF {
err = nil
mytcp.Write([]byte{1, 9, 9, 6, 1, 1, 2, 7})
for !backsck {
time.Sleep(time.Millisecond * 150)
}
backsck = false
break
}
fmt.Println(err)
return err
}
_, err = mytcp.Write(buf[0:n])
if err != nil {
fmt.Println(err)
return err
}
sum += n
fmt.Printf("当前已传输:%f\r", float64(sum)/filebig*100)
}
fmt.Printf("当前已传输:%f\n\n", 100.000000)
fpsrc.Close()
return nil
}
func Scan(path, prefix string, mytcp net.Conn, reg string) {
var err error
var regp *regexp.Regexp
if prefix != "" {
prefix += "/"
}
if reg != "" {
regp, err = regexp.Compile(reg)
if err != nil {
fmt.Println(err)
return
}
}
if runtime.GOOS == "windows" {
path = strings.Replace(path, "/", "\\", -1)
prefix = strings.Replace(prefix, "/", "\\", -1)
}
if starainrt.IsFile(path) {
if reg != "" {
if regp.MatchString(path) {
tcpupload(path, prefix, mytcp)
}
} else {
tcpupload(path, prefix, mytcp)
}
} else if starainrt.IsFolder(path) {
dir, err := ioutil.ReadDir(path)
if err != nil {
fmt.Println(err)
return
}
for _, v := range dir {
if v.IsDir() && (v.Name() != "." || v.Name() != "..") {
mytcp.Write([]byte("b612&" + prefix + v.Name() + "&0"))
count := 0
for !foldercreate {
time.Sleep(time.Millisecond * 100)
count++
if count%30 == 0 {
mytcp.Write([]byte("b612&" + prefix + v.Name() + "&0"))
}
}
foldercreate = false
Scan(path+"/"+v.Name(), prefix+v.Name(), mytcp, reg)
} else {
if reg != "" {
if regp.MatchString(path + "/" + v.Name()) {
err = tcpupload(path+"/"+v.Name(), prefix, mytcp)
}
} else {
err = tcpupload(path+"/"+v.Name(), prefix, mytcp)
}
if err != nil {
fmt.Println(err)
return
}
}
}
}
}
var tcprecvcmd = &cobra.Command{
Use: "recv",
Short: "通过tcp接收文件",
Long: "通过tcp接收文件",
Run: func(this *cobra.Command, args []string) {
p, _ := this.Flags().GetString("port")
a, _ := this.Flags().GetString("addr")
laddr, err := net.ResolveTCPAddr("tcp", a+":"+p)
if err != nil {
fmt.Println(err)
return
}
tcplisten, err := net.ListenTCP("tcp", laddr)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("TCP监听已建立")
defer tcplisten.Close()
for {
conn, err := tcplisten.AcceptTCP()
if err != nil {
fmt.Printf("Error Connect From %s : %s\n", conn.RemoteAddr(), err.Error())
continue
}
fmt.Printf("Accept Connect From %s\n", conn.RemoteAddr())
go func(conns *net.TCPConn) {
canrecv := false
name := ""
var fpdst *os.File
defer conns.Close()
var sum int64
for {
buf := make([]byte, 393216)
n, err := conns.Read(buf)
if !canrecv {
if err != nil {
fmt.Println(err)
return
}
data := string(buf[0:n])
str := strings.Split(data, "&")
if len(str) != 3 {
continue
}
if str[0] == "victorique" {
canrecv = true
name = str[1]
prefix := str[2]
if runtime.GOOS != "windows" {
prefix = strings.Replace(prefix, "\\", "/", -1)
}
if prefix == "" {
fpdst, err = os.Create("./" + name)
} else {
fpdst, err = os.Create(prefix + name)
}
if err != nil {
fmt.Println(err)
conns.Write([]byte(err.Error()))
return
}
conns.Write([]byte("oksend!"))
} else if str[0] == "b612" {
str[1] = ".\\" + str[1]
if runtime.GOOS != "windows" {
str[1] = strings.Replace(str[1], "\\", "/", -1)
}
fmt.Println("进入文件夹:" + str[1] + "\n")
os.MkdirAll(str[1], 0644)
time.Sleep(time.Millisecond * 50)
conns.Write([]byte("folderok"))
} else if str[0] == "jane" {
return
}
} else {
if buf[n-1] == byte(7) && buf[n-2] == byte(2) && buf[n-3] == byte(1) {
ok := func() bool {
for k, v := range []byte{1, 9, 9, 6, 1, 1, 2, 7} {
if buf[n-8+k] != v {
return false
}
}
return true
}()
if ok {
if n > 8 {
fpdst.Write(buf[0 : n-8])
sum += int64(n - 8)
}
fmt.Printf("已写入:%d 字节\n", sum)
fmt.Println(name + "接收成功\n")
fpdst.Close()
canrecv = false
sum = 0
conns.Write([]byte("backsck"))
continue
}
}
fpdst.Write(buf[0:n])
sum += int64(n)
fmt.Printf("已写入:%d 字节\r", sum)
}
}
}(conn)
}
},
}

@ -0,0 +1,33 @@
// +build windows
package main
import (
"os"
"b612.me/wincmd"
"github.com/spf13/cobra"
)
var uaccmd = &cobra.Command{
Use: "uac",
Short: "Windows 使用uac权限打开文件",
Long: "Windows 使用uac权限打开文件",
Run: func(this *cobra.Command, args []string) {
if len(args) == 0 {
return
}
cmdLine := ""
if len(args) > 1 {
for _, v := range args[1:] {
cmdLine += v + " "
}
}
pwd, _ := os.Getwd()
wincmd.StartProcess(args[0], cmdLine, pwd, true, 1)
},
}
func init() {
cmdMain.AddCommand(uaccmd)
}

@ -0,0 +1,126 @@
package main
import (
"fmt"
"net"
"strconv"
"strings"
"time"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var udpcmd = &cobra.Command{
Use: "udp",
Short: "发送并监听udp数据包",
Long: "发送并监听udp数据包",
Run: func(this *cobra.Command, args []string) {
var raddr *net.UDPAddr
r, _ := this.Flags().GetBool("recvonly")
if len(args) != 1 && !r {
fmt.Println("请指定远程udp地址")
return
}
l, _ := this.Flags().GetString("port")
a, _ := this.Flags().GetString("addr")
s, _ := this.Flags().GetBool("local")
b, _ := this.Flags().GetBool("byte")
laddr, err := net.ResolveUDPAddr("udp", a+":"+l)
if !r {
raddr, err = net.ResolveUDPAddr("udp", args[0])
}
if err != nil {
fmt.Println(err)
return
}
if s {
udplisten, err := net.ListenUDP("udp", laddr)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("监听已建立")
go func() {
for {
buf := make([]byte, 204800)
n, addr, err := udplisten.ReadFromUDP(buf)
if err != nil {
starlog.Errorln("Error from %s Where Message=%s\n", addr.String(), err.Error())
continue
}
starlog.Infof("Receive Msg From %s : %s\n", addr.String(), string(buf[0:n]))
if b {
starlog.Infof("%#v\n", buf[0:n])
}
}
}()
}
if !r {
myudp, err := net.DialUDP("udp", nil, raddr)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("UDP虚拟连接已建立")
go func() {
var err error
for {
txt := starainrt.MessageBox("", "")
if txt == "" {
continue
}
if !b {
_, err = myudp.Write([]byte(txt))
} else {
var sendbyte []byte
bytes := strings.Split(txt, ",")
for _, v := range bytes {
ints, _ := strconv.Atoi(v)
if ints < 0 || ints > 255 {
continue
}
sendbyte = append(sendbyte, byte(ints))
}
_, err = myudp.Write(sendbyte)
}
if err != nil {
fmt.Printf("Error from %s Where Message=%s\n", myudp.RemoteAddr().String(), err.Error())
return
}
}
}()
for {
buf := make([]byte, 204800)
n, err := myudp.Read(buf)
if err != nil {
starlog.Infof("Error from %s Where Message=%s\n", myudp.RemoteAddr().String(), err.Error())
return
}
starlog.Infof("Receive Msg From %s : %s\n", myudp.RemoteAddr().String(), string(buf[0:n]))
if b {
starlog.Infof("%#v", buf[0:n])
}
}
} else {
for {
time.Sleep(time.Second)
}
}
},
}
/*
*/
func init() {
udpcmd.Flags().BoolP("byte", "b", false, "发送二进制数据")
udpcmd.Flags().StringP("port", "p", "1127", "本地监听端口")
udpcmd.Flags().StringP("addr", "a", "0.0.0.0", "本地监听ip")
udpcmd.Flags().BoolP("local", "s", false, "启动本地监听")
udpcmd.Flags().BoolP("recvonly", "r", false, "仅接收udp包")
}

@ -0,0 +1,94 @@
package main
import (
"fmt"
"os"
"regexp"
"b612.me/starainrt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var viccmd = &cobra.Command{
Use: "vicque",
Short: "嵐を乗り越えて",
Long: "あの子の未来を照らし出せ",
Run: func(this *cobra.Command, args []string) {
var err error
ok, _ := this.Flags().GetBool("file")
de, _ := this.Flags().GetBool("decode")
pwd, _ := this.Flags().GetString("key")
rep, _ := this.Flags().GetBool("replace")
ext, _ := this.Flags().GetBool("extension")
if len(args) != 2 || args[1] != "sakura" {
starlog.Errorln("ヴィクトリカだけが使えるよ")
return
}
shell := func(pect float64) {
if pect == 100 {
fmt.Println("已处理100.000000%")
} else {
fmt.Printf("已处理:%f%%\r", pect)
}
}
cry := new(starainrt.StarCrypto)
if ok {
path, _ := this.Flags().GetString("path")
if !de {
err = cry.VicqueEncodeV1File(args[0], path, pwd, shell)
if err == nil {
if rep {
os.Remove(args[0])
os.Rename(path, args[0])
path = args[0]
}
if ext {
os.Rename(path, path+".victorique")
}
}
} else {
err = cry.VicqueDecodeV1File(args[0], path, pwd, shell)
if err == nil {
if rep {
os.Remove(args[0])
os.Rename(path, args[0])
path = args[0]
}
if ext {
reg := regexp.MustCompile(`(.*?)\.victorique$`)
if reg.MatchString(path) {
paths := reg.FindStringSubmatch(path)
os.Rename(path, paths[1])
}
}
}
}
} else {
if !de {
data := cry.VicqueEncodeV1([]byte(args[0]), pwd)
fmt.Println(data)
fmt.Println(cry.Base64Encode(data))
} else {
var data []byte
src, _ := cry.Base64Decode(args[0])
data = cry.VicqueDecodeV1(src, pwd)
fmt.Println(string(data))
}
}
if err != nil {
starlog.Errorln(err)
return
}
},
}
func init() {
viccmd.Flags().BoolP("file", "f", false, "VICQUE处理文件")
viccmd.Flags().StringP("path", "p", "./v64.encode", "指定处理地址,默认为./v64.encode")
viccmd.Flags().BoolP("decode", "d", false, "VICQUE解码")
viccmd.Flags().StringP("key", "k", "", "密钥")
viccmd.Flags().BoolP("replace", "r", false, "覆盖原文件")
viccmd.Flags().BoolP("extension", "e", false, "添加/取消.victorique后缀")
viccmd.MarkFlagRequired("key")
}
Loading…
Cancel
Save