Skip to content

Commit

Permalink
Hyuga Pro (#28)
Browse files Browse the repository at this point in the history
* clean

* Hyuga pro

* remove anylog

* 移除中间件redis,持久化采用leveldb

* oob DNS(rebind) && HTTP

* oob jndi

* 消息推送至websocket

* 更新:订阅全部主题

* eventbus移动至pkg

* 添加通知

* 添加用户API

* 完善用户信息

* 初始化前端

* 完善前端用户模块

* 请求日志记录

* 添加设置DNS Rebinding

* Update doc

* 更新查询API

* 更新githubOauth接口

* Update github action

* Update github action

* 修复服务停止

* Update github action

* Update docs
  • Loading branch information
ac0d3r authored May 5, 2023
1 parent 9e68c49 commit 4d81bd1
Show file tree
Hide file tree
Showing 90 changed files with 6,457 additions and 14,197 deletions.
14 changes: 0 additions & 14 deletions .dockerignore

This file was deleted.

90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release Hyuga

on:
push:
tags:
- v*
release:
types: [published]

permissions:
contents: read

jobs:
prepare:
name: Prepare release environment
runs-on: ubuntu-latest
steps:
- run: env

build-binary:
name: Build binary
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- os: windows
arch: amd64
output: hyuga-windows-amd64.exe
- os: darwin
arch: amd64
output: hyuga-darwin-amd64
- os: darwin
arch: arm64
output: hyuga-darwin-arm64
- os: linux
arch: amd64
output: hyuga-linux-amd64
- os: linux
arch: arm64
output: hyuga-linux-arm64
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install && npm run build
working-directory: frontend
- run: mv frontend/dist internal/handler/dist
- uses: actions/setup-go@v3
with:
go-version: 1.19
cache: true
- run: go build -trimpath -ldflags "-w -s -extldflags '-static' -X main.githash=`git rev-parse HEAD`" -o target/${{ matrix.output }} cmd/main.go
- uses: actions/upload-artifact@v2
with:
name: target
path: target/*

collect-release:
name: Collect and release
needs: [build-binary]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: target
path: target
- run: ls -al target && ls -R target/ && file target/
- uses: actions/upload-artifact@v3
with:
name: target-release
path: target/*

# release assets
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: target/*
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ dump.rdb
.DS_Store
node_modules
dist/
*.db
*.log

# tests
tests/log4jtest/target

Expand All @@ -34,7 +37,6 @@ pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
Expand Down
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "DebugServer",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/main.go",
// "console": "integratedTerminal",
},
]
}
31 changes: 0 additions & 31 deletions CHANGELOG.md

This file was deleted.

36 changes: 0 additions & 36 deletions DEPLOY.md

This file was deleted.

34 changes: 0 additions & 34 deletions Dockerfile

This file was deleted.

58 changes: 32 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,64 @@
<div align="center" >
<img src="./docs/hyuga.png" width="280" alt="Hyuga" />
<img src="./docs/hyuga.png" width="200" alt="Hyuga" />
</div>
<p align="center">
<a href="https://github.com/Buzz2d0/Hyuga">
<img alt="Hyuga" src="https://img.shields.io/badge/Hyuga-3.0.1-yellow"/>
<a href="https://github.com/ac0d3r/Hyuga">
<img alt="Hyuga" src="https://img.shields.io/badge/Hyuga-dev-yellow"/>
</a>
<img src="https://img.shields.io/badge/Language-Golang-blue" alt="Language" />
<a href="https://github.com/Buzz2d0/Hyuga/blob/master/LICENSE">
<img alt="License" src="https://img.shields.io/github/license/Buzz2d0/Hyuga"/>
<a href="https://github.com/ac0d3r/Hyuga/blob/master/LICENSE">
<img alt="License" src="https://img.shields.io/github/license/ac0d3r/Hyuga"/>
</a>
<a href="https://github.com/Buzz2d0/Hyuga/stargazers">
<img alt="stars" src="https://img.shields.io/github/stars/Buzz2d0/Hyuga"/>
<a href="https://github.com/ac0d3r/Hyuga/stargazers">
<img alt="stars" src="https://img.shields.io/github/stars/ac0d3r/Hyuga"/>
</a>
</p>

⚡️Hyuga 是一个用来检测带外(Out-of-Band)流量的监控工具。
Hyuga 是一个用来监控带外(Out-of-Band)流量的工具。🪤

---
## 🎉 项目简介

DEMO 主页:http://hyuga.icu
DEMO 主页:TODO

项目地址:https://github.com/Buzz2d0/Hyuga
项目地址:https://github.com/ac0d3r/Hyuga

## 📷 预览
<img width="1511" alt="image" src="https://user-images.githubusercontent.com/26270009/157201907-0c6d62b9-4232-457c-a7b4-9dcaee429bd1.png">
<img width="1511" alt="image" src="https://user-images.githubusercontent.com/26270009/236437388-a862b25f-e049-420d-aaf8-b06e4aa66ccc.png">

## 🎉 功能


## 🌀 oob
### 🌀 oob
- dns
- dns查询记录(query name, remote address)
- 支持 dns-rebinding [#🔗](https://github.com/Buzz2d0/Hyuga#-dns-rebinding)
- 支持 dns-rebinding [#🔗](#-dns-rebinding)
- http
- http 请求记录(url, method, remote address, raw request)
- ldap & rmi
- ldap&rmi 请求记录(protocol, remote address, path)
> thx: [浅谈Log4j2不借助dnslog的检测](https://4ra1n.love/post/I_AYmmK2J/)

## 👀 其他
- 部署参见 [DEPLOY.md](./DEPLOY.md)
- 📝 更新日志[CHANGELOG.md](./CHANGELOG.md)
### 🪃 实时推送
- 通过 websocket 将结果推送到前端。
- 支持第三方推送到Bark、Lark、钉钉、飞书、Sever酱。
- thx: https://github.com/moonD4rk/notifier

### 🔦 单文件部署
- github action 自动发布 [Releases](https://github.com/ac0d3r/Hyuga/releases)

### 🚀 查询 API
- `GET` - http://`<hyuga.io>`/api/record/list?type=`<dns|http>`&token=`<token>`&filter=`<filter>`
- `type`: 查询类型 `dns|http|jndi`
- `GET` - `http://{hyuga.io}/api/v2/record/all?token={token}&type={type}&filter={filter}`
- `type`: 查询类型 `dns|http|ldap|rmi`
- `token`: 域名 token
- `filter`: 过滤字符
- 支持重置 API Token

### 🪓 DNS Rebinding
查询 `r.xxx.hyuga.io` 时根据访问次数依次返回所设置的dns(无缓存时)。
<img width="250" alt="image" src="https://user-images.githubusercontent.com/26270009/236441871-60e51cf3-e0dc-4786-a6a8-869655b31a07.png">

**e.g.** ip 为 `1.1.1.1`;dns 设置如下:

<img width="420" alt="image" src="https://user-images.githubusercontent.com/26270009/157200281-06a3752b-5b48-45df-b0c4-864d7fc81b13.png">
## 👀 其他

### 🪓 DNS Rebinding
假设DNS Rebinding的域名为 `r.b34s.hyuga.io`, 公网IP为 `2.3.3.3`,dns的配置如下图:

<img width="420" alt="image" src="https://user-images.githubusercontent.com/26270009/236439602-09e1222f-09b5-4cee-b10b-d8e23b384464.png">

查询 `r.8q56.hyuga.io` 根据访问次数计算依次返回:`1.1.1.1` -> `127.0.0.1` -> `1.1.1.1`...
那么查询 `r.b34s.hyuga.io` 时根据访问次数依次返回所设置的dns(无缓存时):`2.3.3.3` -> `127.0.0.1` -> `2.3.3.3`...
45 changes: 45 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"flag"
"time"

"github.com/ac0d3r/hyuga/internal/app"
"github.com/ac0d3r/hyuga/internal/config"
"github.com/ac0d3r/hyuga/pkg/logger"
"github.com/sirupsen/logrus"
)

var (
buildstamp string = time.Now().Format("2006-01-02 15:04:05")
githash string = "dev"
)

func main() {
var (
configPath string
)

flag.StringVar(&configPath, "config", "../configs/config.toml", "hyuga config path")
flag.Parse()

cnf, err := config.Load(configPath)
if err != nil {
panic(err)
}

if err := logger.Init(cnf.Logger); err != nil {
panic(err)
}

logrus.Infof("hyuga-server build info, build-stamp:%s build-hash:%s", buildstamp, githash)

app, err := app.New(cnf)
if err != nil {
panic(err)
}

if err = app.Run(); err != nil {
panic(err)
}
}
Loading

0 comments on commit 4d81bd1

Please sign in to comment.