forked from sky1983x/DarkEye
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.go
125 lines (110 loc) · 2.69 KB
/
ui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package main
import (
"fmt"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
"github.com/zsdevX/DarkEye/common"
"github.com/zsdevX/DarkEye/ui"
"os"
"time"
)
var (
programName = "DarkEye"
)
func main() {
runApp()
}
func runApp() {
//加载配置
_ = loadCfg()
app := widgets.NewQApplication(len(os.Args), os.Args)
app.SetWindowIcon(gui.NewQIcon5(":/qml/logo.ico"))
app.SetQuitOnLastWindowClosed(false)
//初始化窗口
mainWin := ui.NewMainWindow(nil)
//初始化数据
initMainWin(mainWin)
//托盘图标初始化
sysTray := NewQSystemTrayIconWithCustomSlot(nil)
sysTrayDaemon(sysTray, mainWin, app)
//显示
sysTray.Show()
mainWin.Show()
//通知
sysTray.TriggerSlot()
widgets.QApplication_Exec()
}
func initMainWin(mainWin *ui.MainWindow) {
//FoFa
LoadFoFa(mainWin)
//SecurityTrails
LoadSecurityTrails(mainWin)
//Spider
LoadSpider(mainWin)
//poc
LoadPoc(mainWin)
}
func sysTrayDaemon(sysTray *QSystemTrayIconWithCustomSlot, mainWin *ui.MainWindow, app *widgets.QApplication) {
sysTray.SetIcon(gui.NewQIcon5(":/qml/logo.png"))
sysTray.SetToolTip("白嫖神器")
sysTrayMenu := widgets.NewQMenu(nil)
fucker := sysTrayMenu.AddAction("信息收集神器")
about := sysTrayMenu.AddAction("关于")
quit := sysTrayMenu.AddAction("退出")
sysTray.SetContextMenu(sysTrayMenu)
sysTray.ConnectTriggerSlot(func() {
sysTray.ShowMessage("信息", common.ProgramVersion, widgets.QSystemTrayIcon__Information, 5000)
})
fucker.ConnectTriggered(func(bool) {
mainWin.Show()
})
about.ConnectTriggered(func(bool) {
information := common.ProgramVersion
widgets.QMessageBox_Information(nil, "信息", information,
widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
})
quit.ConnectTriggered(func(bool) {
if widgets.QMessageBox_Information(nil, "信息", "客官再见,欢迎白嫖",
widgets.QMessageBox__Ok, widgets.QMessageBox__Cancel) == widgets.QMessageBox__Ok {
app.Quit()
}
})
}
//外部应使用goroutine调用
func gracefulStop(start, stop *widgets.QPushButton, runCtl chan bool) {
//终止任务时避免卡顿
sec := 0
jumpOut := false
tick := time.NewTicker(time.Second)
stop.SetDisabled(true)
for {
select {
case <-runCtl:
jumpOut = true
case <-tick.C:
sec ++
stop.SetText(fmt.Sprintf("等待%d秒", 60-sec))
}
if jumpOut {
break
}
}
start.SetEnabled(true)
stop.SetText("停止")
}
type QSystemTrayIconWithCustomSlot struct {
widgets.QSystemTrayIcon
_ func() `slot:"triggerSlot"`
}
func logChannel(view *widgets.QTextEdit) (chan string, chan bool) {
logC := make(chan string, 128)
runCtl := make(chan bool, 1)
view.SetReadOnly(true)
go func() {
for {
log := <-logC
view.Append(log)
}
}()
return logC, runCtl
}