招募六边形战士队员
一起学习 代码审计、安全开发、web攻防、逆向等。。。
私信联系
原chying工具代码分析
前有 Chying 后有 Tscanplus
并发访问控制
type SMap struct {
sync.RWMutex // 标准读写锁
Map map[int]*HTTPBody
}
并发 原子 写入
func (l *SMap) WriteMap(key int, value *HTTPBody) {
l.Lock()
l.Map[key] = value
l.Unlock() //释放写锁
}
读取
//使用读写锁来允许多个 goroutine 同时读取数据,而不会相互阻塞。
func (l *SMap) ReadMap(key int) *HTTPBody {
l.RLock() //读锁
value, _ := l.Map[key] //若给定的键不存在于 Map 中,返回的值将为 nil。
l.RUnlock()
return value
}
通道
// HttpHistory 接受 mitmproxy 代理信息var HttpHistory chan HTTPHistory
文章来源:https://www.toymoban.com/news/detail-812613.html
嵌套映射结构
// RepeaterBodyMap Repeater 中回退、前进使用 todo前端还未实现var RepeaterBodyMap map[string]map[int]*HTTPBody
文章来源地址https://www.toymoban.com/news/detail-812613.html
初始化
func init() {
HttpHistory = make(chan HTTPHistory, 1) //创建一个缓冲大小为 1 的通道
HTTPBodyMap = &SMap{
Map: make(map[int]*HTTPBody), //创建一个空的 map[int]*HTTPBody 映射
}
IntruderMap = make(map[string]*SMap)
RepeaterBodyMap = make(map[string]map[int]*HTTPBody)
}
启动代理服务器
func Run(port int) {
opts := &proxy.Options{ //配置代理服务器的选项
Debug: 2,
Addr: fmt.Sprintf(":%d", port),
StreamLargeBodies: 1024 * 1024 * 5, //数据的阈值
SslInsecure: false, //不安全选项
CaRootPath: "", //CA 根证书路径
}
var err error
Proxy, err = proxy.NewProxy(opts)
if err != nil {
logging.Logger.Fatal(err)
}
// 这种不错,通过添加插件的形式,这样只要实现了接口,p.AddAddon(xxxx), 然后就会自动执行相应的操作
// 添加一个日志记录插件
//Proxy.AddAddon(&proxy.LogAddon{})
Proxy.AddAddon(&Burp{}) //向代理服务器添加一个 Burp 插件
logging.Logger.Errorln(Proxy.Start()) //程序在该函数调用处阻塞,直到代理服务器停止运行。
}
重启代理服务器
func Restart(port int) string {
// 先关闭然后再启动
err := Proxy.Shutdown(context.TODO()) //关闭代理服务器
if err != nil {
logging.Logger.Errorln(err)
return err.Error()
}
go Run(port) //放入一个新的 goroutine 中运行
//避免阻塞主程序,使其继续执行其他任务。
return ""
}
vite 构建前端页面
ChYing-main\frontend>
npm install vite
vite build
编译
go install github.com/wailsapp/wails/v2/cmd/wails@latest 安装 Wails CLI。
go: downloading github.com/wailsapp/wails/v2 v2.7.1
go: downloading github.com/wailsapp/wails v1.16.9
go: downloading github.com/jaypipes/ghw v0.12.0
go: downloading github.com/leaanthony/clir v1.3.0
go: downloading github.com/flytam/filenamify v1.0.0
go: downloading github.com/pterm/pterm v0.12.49
go: downloading github.com/tidwall/sjson v1.1.7
go: downloading github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
go: downloading github.com/fsnotify/fsnotify v1.4.9
go: downloading github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
go: downloading github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
go: downloading golang.org/x/mod v0.12.0
go: downloading github.com/wzshiming/ctc v1.2.3
go: downloading github.com/Masterminds/semver v1.5.0
go: downloading github.com/charmbracelet/glamour v0.5.0
go: downloading github.com/wailsapp/go-webview2 v1.0.10
go: downloading github.com/jackmordaunt/icns v1.0.0
go: downloading github.com/leaanthony/winicon v1.0.0
go: downloading github.com/tc-hib/winres v0.2.1
go: downloading github.com/go-git/go-git/v5 v5.3.0
go: downloading github.com/tidwall/gjson v1.9.3
go: downloading atomicgo.dev/cursor v0.1.1
go: downloading atomicgo.dev/keyboard v0.2.8
go: downloading github.com/gookit/color v1.5.2
go: downloading github.com/lithammer/fuzzysearch v1.1.5
go: downloading github.com/mattn/go-runewidth v0.0.13
go: downloading golang.org/x/term v0.13.0
go: downloading golang.org/x/sys v0.13.0
go: downloading github.com/wzshiming/winseq v0.0.0-20200112104235-db357dc107ae
go: downloading github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
go: downloading github.com/StackExchange/wmi v1.2.1
go: downloading github.com/jaypipes/pcidb v1.0.0
go: downloading github.com/ghodss/yaml v1.0.0
go: downloading github.com/muesli/termenv v0.9.0
go: downloading github.com/yuin/goldmark v1.4.13
go: downloading github.com/yuin/goldmark-emoji v1.0.1
go: downloading golang.org/x/image v0.12.0
go: downloading github.com/go-git/go-billy/v5 v5.2.0
go: downloading github.com/imdario/mergo v0.3.12
go: downloading golang.org/x/crypto v0.14.0
go: downloading github.com/containerd/console v1.0.3
go: downloading github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778
go: downloading github.com/alecthomas/chroma v0.10.0
go: downloading github.com/microcosm-cc/bluemonday v1.0.17
go: downloading github.com/muesli/reflow v0.3.0
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/emirpasic/gods v1.12.0
go: downloading github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
go: downloading github.com/dlclark/regexp2 v1.4.0
go: downloading golang.org/x/net v0.17.0
go: downloading github.com/go-git/gcfg v1.5.0
go: downloading github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351
go: downloading github.com/xanzy/ssh-agent v0.3.0
go: downloading gopkg.in/warnings.v0 v0.1.2
go: downloading github.com/Microsoft/go-winio v0.4.16
wails build
Wails CLI v2.7.1
# Build Options
Platform(s) | windows/amd64
Compiler | D:\golang\bin\go.exe
Skip Bindings | false
Build Mode | production
Devtools | false
Frontend Directory | E:\code\go_test\ChYing-main\frontend
Obfuscated | false
Skip Frontend | false
Compress | false
Package | true
Clean Bin Dir | false
LDFlags |
Tags | []
Race Detector | false
Warning: go.mod is using Wails '2.5.1' but the CLI is 'v2.7.1'. Consider updating your project's `go.mod` file.
• Generating bindings: Done.
• Installing frontend dependencies: Done.
• Compiling frontend: Done.
• Generating application assets: Done.
• Compiling application: Done.
INFO Wails is now using the new Go WebView2Loader. If you encounter any issues with it, please report them to https://github.com/wailsapp/wails/issues/2004. You could also use the old legacy loader with `-tags native_webview2loader`, but keep in mind this will be deprecated in the near future.
Built 'E:\code\go_test\ChYing-main\build\bin\ChYing.exe' in 53.613s.
♥ If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony
到了这里,关于红队专题-Golang工具ChYing的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!