Skip to content

Commit

Permalink
Merge pull request hacklcx#33 from hacklcx/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sanjinhub authored Sep 15, 2019
2 parents 29402a8 + a0b2ba5 commit 65f1b10
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 79 deletions.
10 changes: 7 additions & 3 deletions admin/fish.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,13 @@ <h6 class="modal-title" id="myModalLabel">上钩信息</h6>
_h += ' <td class="td"><span class="ipinfo">本机地址</span></td>';
} else if (data.result[i].country == "局域网") {
_h += ' <td class="td"><span class="ipinfo">局域网</span></td>';
}
else {
_h += ' <td class="td"><span class="ipinfo">' + data.result[i].country + ' ' + data.result[i].region + ' ' + data.result[i].city + '</span></td>';
} 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>';
} 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>';
Expand Down
6 changes: 6 additions & 0 deletions admin/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<div class="tab-content">
<div class="tab-pane fade in active" id="home-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="item-info">
<small class="text-muted">2019-09-09</small>
Expand Down
4 changes: 2 additions & 2 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ name = Server # 状态1 服务端 名称 状

[admin] # RPC 状态为2 集群客户端的时候 admin 可以删掉
addr = 0.0.0.0:9001 # 管理后台启动地址
account = admin # 登录账号
password = admin # 登录密码
account = admin # 登录账号,不能带 #
password = admin # 登录密码,不能带 #
db_type = sqlite # sqlite or mysql
db_max_open = 50 # 最大连接池,0 表示无限制
db_max_idle = 50 # 最大空闲数,0 表示无限制
Expand Down
11 changes: 2 additions & 9 deletions core/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import (
"HFish/view/data"
"github.com/gin-gonic/gin"
"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() {
// 只有新加入才会发送邮件通知
Expand Down Expand Up @@ -56,14 +55,11 @@ func AlertMail(model string, typex string, agent string, ipx string, country str
send.SendMail(config[4:], "[HFish]提醒你,"+typex+"有鱼上钩!", text, config)
}
}

wg.Done()
}).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 通知
try.Try(func() {
result, err := dbUtil.DB().Table("hfish_setting").Fields("status", "info").Where("type", "=", "webHook").First()
Expand Down Expand Up @@ -110,10 +106,7 @@ func AlertWebHook(id string, model string, typex string, projectName string, age
defer resp.Body.Close()
//defer request.Body.Close()
}

wg.Done()
}).Catch(func() {
wg.Done()
})
}

Expand Down
15 changes: 2 additions & 13 deletions core/protocol/ftp/graval/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"HFish/core/report"
"HFish/utils/is"
"HFish/core/rpc/client"
"sync"
"github.com/panjf2000/ants"
"HFish/core/pool"
)

Expand Down Expand Up @@ -332,19 +330,10 @@ func (cmd commandPass) RequireAuth() bool {
return false
}

// 加入线程池

var (
wg sync.WaitGroup
poolX *ants.Pool
)

func init() {
wg, poolX = pool.New(10)
func (cmd commandPass) Execute(conn *ftpConn, param string) {
wg, poolX := pool.New(10)
defer poolX.Release()
}

func (cmd commandPass) Execute(conn *ftpConn, param string) {
wg.Add(1)
poolX.Submit(func() {

Expand Down
54 changes: 13 additions & 41 deletions core/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"HFish/core/alert"
"HFish/utils/conf"
"HFish/core/pool"
"sync"
"github.com/panjf2000/ants"
)

type HFishInfo struct {
Expand All @@ -29,37 +27,16 @@ type HFishInfo struct {
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) {
wg.Add(1)
poolX.Submit(func() {
time.Sleep(time.Second * 2)

// 邮件通知
alert.AlertMail(model, typex, agent, ipx, country, region, city, infox, &wg)
// 邮件通知
alert.AlertMail(model, typex, agent, ipx, country, region, city, infox)

// WebHook
alert.AlertWebHook(id, model, typex, projectName, agent, ipx, country, region, city, infox, timex, &wg)
// WebHook
alert.AlertWebHook(id, model, typex, projectName, agent, ipx, country, region, city, infox, timex)

// 大数据展示
//alert.AlertDataWs(model, typex, projectName, agent, ipx, country, region, city, time)
})
// 大数据展示
//alert.AlertDataWs(model, typex, projectName, agent, ipx, country, region, city, time)
}

// 上报 集群 状态
Expand Down Expand Up @@ -159,8 +136,6 @@ func insertInfo(typex string, projectName string, agent string, ipx string, coun

// 更新
func updateInfoCore(id string, info string) {
time.Sleep(time.Second * 2)

try.Try(func() {
var sql string

Expand Down Expand Up @@ -188,18 +163,21 @@ func updateInfoCore(id string, info string) {
if err != nil {
log.Pr("HFish", "127.0.0.1", "更新上钩信息失败", err)
}

wgUpdate.Done()
}).Catch(func() {
wgUpdate.Done()
})
}

// 通用的更新
func updateInfo(id string, info string) {
wgUpdate, poolUpdateX := pool.New(10)

defer poolUpdateX.Release()

wgUpdate.Add(1)
poolUpdateX.Submit(func() {
updateInfoCore(id, info)
time.Sleep(time.Second * 2)
go updateInfoCore(id, info)
wgUpdate.Done()
})
}

Expand Down Expand Up @@ -253,12 +231,6 @@ func ReportSSH(ipx string, agent string, info string) int64 {

// 更新 SSH 操作
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") {
go updateInfo(id, info)
go alertx(id, "update", "SSH", "SSH蜜罐", "", "", "", "", "", info, time.Now().Format("2006-01-02 15:04:05"))
Expand Down
Binary file modified db/hfish.db
Binary file not shown.
12 changes: 12 additions & 0 deletions logs/hfish.log
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
} else if args[1] == "init" || args[1] == "--init" {
setting.Init()
} 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" {
setting.Run()
} else {
Expand Down
9 changes: 0 additions & 9 deletions static/css/style.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
@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 {
font-family: sans-serif;
Expand Down
2 changes: 1 addition & 1 deletion utils/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func Help() {
{K || __ _______ __
| PP / // / __(_)__ / /
| || / _ / _// (_-</ _ \
(__\\ /_//_/_/ /_/___/_//_/ v0.3.1
(__\\ /_//_/_/ /_/___/_//_/ v0.3.2
`
fmt.Println(color.Yellow(logo))
fmt.Println(color.White(" A Safe and Active Attack Honeypot Fishing Framework System for Enterprises."))
Expand Down

0 comments on commit 65f1b10

Please sign in to comment.