Merge pull request #33 from hacklcx/dev

Dev
This commit is contained in:
SanJin 2019-09-15 21:22:10 +08:00 committed by GitHub
commit 65f1b104a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 47 additions and 80 deletions

View File

@ -384,9 +384,13 @@
_h += ' <td class="td"><span class="ipinfo">本机地址</span></td>'; _h += ' <td class="td"><span class="ipinfo">本机地址</span></td>';
} else if (data.result[i].country == "局域网") { } else if (data.result[i].country == "局域网") {
_h += ' <td class="td"><span class="ipinfo">局域网</span></td>'; _h += ' <td class="td"><span class="ipinfo">局域网</span></td>';
} } else {
else { if (data.result[i].country == "中国") {
_h += ' <td class="td"><span class="ipinfo">' + data.result[i].country + ' ' + data.result[i].region + ' ' + data.result[i].city + '</span></td>'; _h += ' <td class="td"><span class="ipinfo">' + data.result[i].country + ' ' + data.result[i].region + ' ' + data.result[i].city + '</span></td>';
} else {
// 国外IP只能拿到国家
_h += ' <td class="td"><span class="ipinfo">' + data.result[i].country + '</span></td>';
}
} }
_h += ' <td><span class="info" onclick="show(' + data.result[i].id + ')">点击查看</span></td>'; _h += ' <td><span class="info" onclick="show(' + data.result[i].id + ')">点击查看</span></td>';

View File

@ -25,6 +25,12 @@
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane fade in active" id="home-2"> <div class="tab-pane fade in active" id="home-2">
<div class="timeline-2"> <div class="timeline-2">
<div class="time-item">
<div class="item-info">
<small class="text-muted">2019-09-16</small>
<p>发布 v0.3.2 版本</p>
</div>
</div>
<div class="time-item"> <div class="time-item">
<div class="item-info"> <div class="item-info">
<small class="text-muted">2019-09-09</small> <small class="text-muted">2019-09-09</small>

View File

@ -5,8 +5,8 @@ name = Server # 状态1 服务端 名称 状
[admin] # RPC 状态为2 集群客户端的时候 admin 可以删掉 [admin] # RPC 状态为2 集群客户端的时候 admin 可以删掉
addr = 0.0.0.0:9001 # 管理后台启动地址 addr = 0.0.0.0:9001 # 管理后台启动地址
account = admin # 登录账号 account = admin # 登录账号,不能带 #
password = admin # 登录密码 password = admin # 登录密码,不能带 #
db_type = sqlite # sqlite or mysql db_type = sqlite # sqlite or mysql
db_max_open = 50 # 最大连接池0 表示无限制 db_max_open = 50 # 最大连接池0 表示无限制
db_max_idle = 50 # 最大空闲数0 表示无限制 db_max_idle = 50 # 最大空闲数0 表示无限制

View File

@ -13,10 +13,9 @@ import (
"HFish/view/data" "HFish/view/data"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"HFish/error" "HFish/error"
"sync"
) )
func AlertMail(model string, typex string, agent string, ipx string, country string, region string, city string, infox string, wg *sync.WaitGroup) { func AlertMail(model string, typex string, agent string, ipx string, country string, region string, city string, infox string) {
// 判断邮件通知 // 判断邮件通知
try.Try(func() { try.Try(func() {
// 只有新加入才会发送邮件通知 // 只有新加入才会发送邮件通知
@ -56,14 +55,11 @@ func AlertMail(model string, typex string, agent string, ipx string, country str
send.SendMail(config[4:], "[HFish]提醒你,"+typex+"有鱼上钩!", text, config) send.SendMail(config[4:], "[HFish]提醒你,"+typex+"有鱼上钩!", text, config)
} }
} }
wg.Done()
}).Catch(func() { }).Catch(func() {
wg.Done()
}) })
} }
func AlertWebHook(id string, model string, typex string, projectName string, agent string, ipx string, country string, region string, city string, infox string, time string, wg *sync.WaitGroup) { func AlertWebHook(id string, model string, typex string, projectName string, agent string, ipx string, country string, region string, city string, infox string, time string) {
// 判断 WebHook 通知 // 判断 WebHook 通知
try.Try(func() { try.Try(func() {
result, err := dbUtil.DB().Table("hfish_setting").Fields("status", "info").Where("type", "=", "webHook").First() result, err := dbUtil.DB().Table("hfish_setting").Fields("status", "info").Where("type", "=", "webHook").First()
@ -110,10 +106,7 @@ func AlertWebHook(id string, model string, typex string, projectName string, age
defer resp.Body.Close() defer resp.Body.Close()
//defer request.Body.Close() //defer request.Body.Close()
} }
wg.Done()
}).Catch(func() { }).Catch(func() {
wg.Done()
}) })
} }

View File

@ -11,8 +11,6 @@ import (
"HFish/core/report" "HFish/core/report"
"HFish/utils/is" "HFish/utils/is"
"HFish/core/rpc/client" "HFish/core/rpc/client"
"sync"
"github.com/panjf2000/ants"
"HFish/core/pool" "HFish/core/pool"
) )
@ -332,19 +330,10 @@ func (cmd commandPass) RequireAuth() bool {
return false return false
} }
// 加入线程池
var (
wg sync.WaitGroup
poolX *ants.Pool
)
func init() {
wg, poolX = pool.New(10)
defer poolX.Release()
}
func (cmd commandPass) Execute(conn *ftpConn, param string) { func (cmd commandPass) Execute(conn *ftpConn, param string) {
wg, poolX := pool.New(10)
defer poolX.Release()
wg.Add(1) wg.Add(1)
poolX.Submit(func() { poolX.Submit(func() {

View File

@ -11,8 +11,6 @@ import (
"HFish/core/alert" "HFish/core/alert"
"HFish/utils/conf" "HFish/utils/conf"
"HFish/core/pool" "HFish/core/pool"
"sync"
"github.com/panjf2000/ants"
) )
type HFishInfo struct { type HFishInfo struct {
@ -29,37 +27,16 @@ type HFishInfo struct {
time string time string
} }
var (
wg sync.WaitGroup
poolX *ants.Pool
wgUpdate sync.WaitGroup
poolUpdateX *ants.Pool
)
func init() {
wg, poolX = pool.New(10)
defer poolX.Release()
wgUpdate, poolUpdateX = pool.New(10)
defer poolUpdateX.Release()
}
// 通知模块 // 通知模块
func alertx(id string, model string, typex string, projectName string, agent string, ipx string, country string, region string, city string, infox string, timex string) { func alertx(id string, model string, typex string, projectName string, agent string, ipx string, country string, region string, city string, infox string, timex string) {
wg.Add(1) // 邮件通知
poolX.Submit(func() { alert.AlertMail(model, typex, agent, ipx, country, region, city, infox)
time.Sleep(time.Second * 2)
// 邮件通知 // WebHook
alert.AlertMail(model, typex, agent, ipx, country, region, city, infox, &wg) alert.AlertWebHook(id, model, typex, projectName, agent, ipx, country, region, city, infox, timex)
// WebHook // 大数据展示
alert.AlertWebHook(id, model, typex, projectName, agent, ipx, country, region, city, infox, timex, &wg) //alert.AlertDataWs(model, typex, projectName, agent, ipx, country, region, city, time)
// 大数据展示
//alert.AlertDataWs(model, typex, projectName, agent, ipx, country, region, city, time)
})
} }
// 上报 集群 状态 // 上报 集群 状态
@ -159,8 +136,6 @@ func insertInfo(typex string, projectName string, agent string, ipx string, coun
// 更新 // 更新
func updateInfoCore(id string, info string) { func updateInfoCore(id string, info string) {
time.Sleep(time.Second * 2)
try.Try(func() { try.Try(func() {
var sql string var sql string
@ -188,18 +163,21 @@ func updateInfoCore(id string, info string) {
if err != nil { if err != nil {
log.Pr("HFish", "127.0.0.1", "更新上钩信息失败", err) log.Pr("HFish", "127.0.0.1", "更新上钩信息失败", err)
} }
wgUpdate.Done()
}).Catch(func() { }).Catch(func() {
wgUpdate.Done()
}) })
} }
// 通用的更新 // 通用的更新
func updateInfo(id string, info string) { func updateInfo(id string, info string) {
wgUpdate, poolUpdateX := pool.New(10)
defer poolUpdateX.Release()
wgUpdate.Add(1) wgUpdate.Add(1)
poolUpdateX.Submit(func() { poolUpdateX.Submit(func() {
updateInfoCore(id, info) time.Sleep(time.Second * 2)
go updateInfoCore(id, info)
wgUpdate.Done()
}) })
} }
@ -253,12 +231,6 @@ func ReportSSH(ipx string, agent string, info string) int64 {
// 更新 SSH 操作 // 更新 SSH 操作
func ReportUpdateSSH(id string, info string) { func ReportUpdateSSH(id string, info string) {
defer func() {
if err := recover(); err != nil {
log.Pr("HFish", "127.0.0.1", "执行SSH更新失败", err)
}
}()
if (id != "0") { if (id != "0") {
go updateInfo(id, info) go updateInfo(id, info)
go alertx(id, "update", "SSH", "SSH蜜罐", "", "", "", "", "", info, time.Now().Format("2006-01-02 15:04:05")) go alertx(id, "update", "SSH", "SSH蜜罐", "", "", "", "", "", info, time.Now().Format("2006-01-02 15:04:05"))

Binary file not shown.

View File

@ -0,0 +1,12 @@
[HFish] ::1 - [2019-09-15 20:35:25] "POST /login HTTP/1.1 200 169.667µs "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" "
[GIN] 2019/09/15 - 20:35:25 | 200 | 404.526µs | ::1 | POST /login
[HFish] ::1 - [2019-09-15 20:35:28] "POST /login HTTP/1.1 200 133.633µs "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" "
[GIN] 2019/09/15 - 20:35:28 | 200 | 209.568µs | ::1 | POST /login
[HFish] ::1 - [2019-09-15 20:35:28] "GET /dashboard HTTP/1.1 200 4.270281ms "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" "
[GIN] 2019/09/15 - 20:35:28 | 200 | 4.306622ms | ::1 | GET /dashboard
[HFish] ::1 - [2019-09-15 20:35:28] "GET /static/css/style.css HTTP/1.1 304 283.146µs "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" "
[GIN] 2019/09/15 - 20:35:28 | 304 | 369.83µs | ::1 | GET /static/css/style.css
[HFish] ::1 - [2019-09-15 20:35:28] "GET /get/dashboard/data HTTP/1.1 200 1.417361ms "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" "
[GIN] 2019/09/15 - 20:35:28 | 200 | 1.46201ms | ::1 | GET /get/dashboard/data
[HFish] ::1 - [2019-09-15 20:35:28] "GET /get/dashboard/pie_data HTTP/1.1 200 636.382µs "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" "
[GIN] 2019/09/15 - 20:35:28 | 200 | 667.996µs | ::1 | GET /get/dashboard/pie_data

View File

@ -16,7 +16,7 @@ func main() {
} else if args[1] == "init" || args[1] == "--init" { } else if args[1] == "init" || args[1] == "--init" {
setting.Init() setting.Init()
} else if args[1] == "version" || args[1] == "--version" { } else if args[1] == "version" || args[1] == "--version" {
fmt.Println("v0.3.1") fmt.Println("v0.3.2")
} else if args[1] == "run" || args[1] == "--run" { } else if args[1] == "run" || args[1] == "--run" {
setting.Run() setting.Run()
} else { } else {

View File

@ -1,13 +1,4 @@
@charset "UTF-8"; @charset "UTF-8";
@import url("https://fonts.googleapis.com/css?family=Roboto:400,500,700,300");
/*!
* Bootstrap v4.0.0-alpha.2 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
@import url("https://fonts.googleapis.com/css?family=Roboto:400,500,700,300");
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
@import url("https://fonts.googleapis.com/css?family=Roboto:400,500,700,300");
html { html {
font-family: sans-serif; font-family: sans-serif;

View File

@ -335,7 +335,7 @@ func Help() {
{K || __ _______ __ {K || __ _______ __
| PP / // / __(_)__ / / | PP / // / __(_)__ / /
| || / _ / _// (_-</ _ \ | || / _ / _// (_-</ _ \
(__\\ /_//_/_/ /_/___/_//_/ v0.3.1 (__\\ /_//_/_/ /_/___/_//_/ v0.3.2
` `
fmt.Println(color.Yellow(logo)) fmt.Println(color.Yellow(logo))
fmt.Println(color.White(" A Safe and Active Attack Honeypot Fishing Framework System for Enterprises.")) fmt.Println(color.White(" A Safe and Active Attack Honeypot Fishing Framework System for Enterprises."))