0x01 前言:
A long long time ago,我就有搭建DnsLog平臺(tái)的想法了,但一直被懶惰所拖累。最近發(fā)現(xiàn)BP的Collaborator模塊實(shí)在是很難令人恭維,寫(xiě)的SSRF檢測(cè)插件已然變成fw,遂打算搭建自己的DnsLog平臺(tái)。
0x02 前期準(zhǔn)備:
- VPS:
建議申請(qǐng)海外的云服務(wù)器, 如果使用國(guó)內(nèi)的服務(wù)器搭建網(wǎng)站需要備案,流程比較復(fù)雜。
- 域名注冊(cè):
到NameSilo注冊(cè)一個(gè)高匿域名,選個(gè)便宜即可,花費(fèi)2美元左右
申請(qǐng)域名結(jié)束后,進(jìn)入域名管理,配置NameServer,指向CloudFlare。在CloudFlare上分別申請(qǐng)兩個(gè)DNS記錄,NS記錄代表子域名ns.xxxx.com的DNS服務(wù)器為log.xxxx.com,設(shè)置log.xxxx.com的A記錄指向我們DNS服務(wù)器所在的地址。
0x03 Hyuga:
Hyuga是國(guó)內(nèi)開(kāi)發(fā)者開(kāi)發(fā)的,有良好、簡(jiǎn)潔的WEB界面,支持DNS、HTTP、支持DNS重綁定、支持API,安裝過(guò)程也很簡(jiǎn)單,支持實(shí)時(shí)信息推送和HTTPS請(qǐng)求,能滿足大部分的需求。
編輯配置文件 config.toml ,修改dns 、github等,具體可以參考:https://github.com/ac0d3r/Hyuga/issues/32
[oob]
[oob.dns]
main = "ns.xxxx.com"
ip = "x.x.x.x"
ns = ["log.xxxx.com"]
[oob.jndi]
address = ":233"
limit = 1000
[web]
address = "localhost:8080"
[web.github]
client-id = "xxx"
client-secret = "xxxxxxxx"
注意:防火墻需要開(kāi)放53和8080端口
0x04 優(yōu)化修改:
使用過(guò)程中發(fā)現(xiàn)無(wú)法通過(guò)serverchan發(fā)送信息推送,填入的UserID和SendKey刷新頁(yè)面后發(fā)現(xiàn)置空了。一開(kāi)始到Serverchan的官網(wǎng)抓包去看,發(fā)現(xiàn)請(qǐng)求包和thirdparty/notify/provider/serverchan.go所定義的不同,官網(wǎng)的請(qǐng)求為簡(jiǎn)單Post請(qǐng)求且不需要UserID。修改后的代碼如下:
package provider
import (
"bytes"
"fmt"
"net/http"
)
const defaultServer = "sctapi.ftqq.com"
type ServerChan struct {
}
func NewServerChan() *ServerChan {
return &ServerChan{}
}
func (p *ServerChan) Send(userID, sendKey, subject, content string) error {
if len(sendKey) == 0 {
return fmt.Errorf("server chan userID or sendKey is empty")
}
url := fmt.Sprintf("https://%s/%s.send", defaultServer, sendKey)
data := fmt.Sprintf("title=%s&desp=%s", subject, content)
resp, err := http.Post(url, "application/x-www-form-urlencoded; charset=utf-8", bytes.NewBufferString(data))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("send server chan failed %w", fmt.Errorf("http status code: %d", resp.StatusCode))
}
return nil
}
針對(duì)填入的UserID和SendKey刷新頁(yè)面后發(fā)現(xiàn)置空的問(wèn)題:在代碼中的結(jié)構(gòu)體定義中,send_key參數(shù)應(yīng)該是通過(guò)server_chan字段傳遞的,而我們的請(qǐng)求體是serverchan,兩者不匹配,所以無(wú)法保存。
修改/internal/handler/restful_user.go文件:
重新編譯代碼:
apt install npm
npm install -g typescript
npm install -D vue-tsc
cd frontend/
npm run build
將frontend目錄下新生成的dist目錄復(fù)制到internal/handler目錄下,然后運(yùn)行程序:
go run main.go
最終實(shí)現(xiàn)效果: