mirror of
https://gitee.com/lauix/HFish
synced 2025-05-11 04:18:02 +08:00
~ 上钩列表支持批量删除 ~ 上钩列表长度展示 ~ 上钩列表支持集群筛选 ~ 集群页面支持删除 ~ 改用 IPIP 本地库获取地理信息 ~ 支持 WebHook Api 通知 ~ 提供获取上钩列表 API ~ WEB,暗网蜜罐 API 移到各种服务上,抛开 Admin ~ 修复暗网蜜罐使用问题 ~ 修复集群取 IP 错误问题 ~ SSH 高交互支持
75 lines
1.6 KiB
Go
75 lines
1.6 KiB
Go
package api
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"HFish/core/report"
|
|
"net/http"
|
|
"HFish/error"
|
|
"HFish/utils/conf"
|
|
"HFish/core/dbUtil"
|
|
"HFish/core/rpc/client"
|
|
"HFish/utils/is"
|
|
)
|
|
|
|
// 上报WEB蜜罐
|
|
func ReportWeb(c *gin.Context) {
|
|
name := c.PostForm("name")
|
|
info := c.PostForm("info")
|
|
secKey := c.PostForm("sec_key")
|
|
ip := c.ClientIP()
|
|
|
|
apiSecKey := conf.Get("api", "sec_key")
|
|
|
|
if secKey != apiSecKey {
|
|
c.JSON(http.StatusOK, error.ErrFailApiKey())
|
|
} else {
|
|
|
|
// 判断是否为 RPC 客户端
|
|
if is.Rpc() {
|
|
go client.ReportResult("WEB", name, ip, info, "0")
|
|
} else {
|
|
go report.ReportWeb(name, "本机", ip, info)
|
|
}
|
|
|
|
c.JSON(http.StatusOK, error.ErrSuccessNull())
|
|
}
|
|
}
|
|
|
|
// 上报暗网蜜罐
|
|
func ReportDeepWeb(c *gin.Context) {
|
|
name := c.PostForm("name")
|
|
info := c.PostForm("info")
|
|
secKey := c.PostForm("sec_key")
|
|
ip := c.ClientIP()
|
|
|
|
apiSecKey := conf.Get("api", "sec_key")
|
|
|
|
if secKey != apiSecKey {
|
|
c.JSON(http.StatusOK, error.ErrFailApiKey())
|
|
} else {
|
|
|
|
// 判断是否为 RPC 客户端
|
|
if is.Rpc() {
|
|
go client.ReportResult("DEEP", name, ip, info, "0")
|
|
} else {
|
|
go report.ReportDeepWeb(name, "本机", ip, info)
|
|
}
|
|
|
|
c.JSON(http.StatusOK, error.ErrSuccessNull())
|
|
}
|
|
}
|
|
|
|
// 获取记录黑客IP
|
|
func GetIpList(c *gin.Context) {
|
|
sql := `select ip from hfish_info GROUP BY ip;`
|
|
result := dbUtil.Query(sql)
|
|
c.JSON(http.StatusOK, error.ErrSuccess(result))
|
|
}
|
|
|
|
// 获取记录黑客IP
|
|
func GetFishInfo(c *gin.Context) {
|
|
sql := `select * from hfish_info ORDER BY id desc`
|
|
result := dbUtil.Query(sql)
|
|
c.JSON(http.StatusOK, error.ErrSuccess(result))
|
|
}
|