DNSLOG平台 golang 一键启动版

Overview

DNSLog-Platform-Golang

相信DNSLog平台已经是安全从业者的标配。而公开的DNSLOG平台域名早已进入流量监控设备的规则库。同时也有隐私问题值得关注。于是撸了(凑了)一个一键搭建Dnslog平台的golang版本。可以使用其一键搭建自己的Dnslog平台。由于是作者的第一个golang程序,难免会有一些小问题。不过 他真的是一键!

部署

  1. 选择你喜欢的方式下载本目录下的main.go文件

    不多说。

  2. 决定是否开放公网访问?

    倒数第几行中的http.ListenAndServe("localhost:8000", nil) ,这样写的话只能通过localhost进行访问,墙裂建议不要修改,而后通过中间件反向代理后对外开放,方便做访问控制、日志管理等。如果想直接对外开放的话可以修改为:http.ListenAndServe(":8000", nil)

  3. 域名准备

    做好NS指向即可。不会检查请看后文

  4. 尝试运行

    go get github.com/miekg/dns 获取需要的库。go run main.go yourdomain 可先在shell前台运行,看功能是否正常使用与检查数据存放目录是否成功创建。如果没问题的话 直接 nohup go run main.go yourdomain &

    (第一次运行需要到github拖miekg/dns库,所以需要你的服务器能上github)

使用

直接web访问进行使用。或者使用api接口。只有两个URI,

  1. /new_gen

    生成随机的八位字符,组合到domain中并返回。当然也可以本地生成,没做限制,无所谓。

  2. /八位字符

    第一步生成的八位字符可以直接访问,可以获取到相关的DNS解析记录。返回为null或者正常数据的JSON形式。

PS:当然,你也可以通过 go build 打包成可执行文件进行跨平台或者离线运行。这都依赖于go的特性。

可定义的配置项

  1. 临时数据存放目录

    localdir, _ := os.Getwd()
    tmplogdir = localdir + "/dnslog/" //DNS日志存放目录,可自行更改。
  2. html页面

    HelloHandler方法中的res变量

  3. 子域名长度

    数据接口判断了访问路径是否为9,是才会尝试读取文件中储存的记录。

    if len(r.URL.Path) == 9 {
    		w.Header().Set("Content-Type", "application/json")
    		res = GetDnslog(r.URL.Path)

    new_gen接口返回的随机key长度为8

    key := randSeq(8)

    写入文件时判断了子域名长度是否为8

    if len(idkey) == 8 {

检查NS指向是否成功?

可以通过linux下命令行工具host -t ns sub.youdomain.com来确认NS服务器。也可以通过在线工具:https://myssl.com/dns_check.html (选择NS类型)

其他

感谢高学长给予的大力帮助:https://github.com/netchiso

You might also like...
Type-safe Prometheus metrics builder library for golang

gotoprom A Prometheus metrics builder gotoprom offers an easy to use declarative API with type-safe labels for building and using Prometheus metrics.

Simple licensing library for golang.

license-key A simple licensing library in Golang, that generates license files containing arbitrary data. Note that this implementation is quite basic

Some utilities for Persian language in Go (Golang)

persian Some utilities for Persian language in Go (Golang). Installation go get github.com/mavihq/persian API .ToPersianDigits Converts all English d

A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Installation go get github.com/Wing924

A golang URL Shortener

url-shortener A golang URL Shortener with mysql support. Using Bijective conversion between natural numbers (IDs) and short strings Installation Using

:guardsman: A teeny tiny and somewhat opinionated generator for your next golang project

A Yeoman Golang Generator We are very sorry Gophers, but other names for the generator where taken, so we choose go-lang. But we have gocreate as an a

Flow-based and dataflow programming library for Go (golang)
Flow-based and dataflow programming library for Go (golang)

GoFlow - Dataflow and Flow-based programming library for Go (golang) Status of this branch (WIP) Warning: you are currently on v1 branch of GoFlow. v1

a Go (Golang) MusicBrainz WS2 client library - work in progress
a Go (Golang) MusicBrainz WS2 client library - work in progress

gomusicbrainz a Go (Golang) MusicBrainz WS2 client library - a work in progress. Current state Currently GoMusicBrainz provides methods to perform sea

Consistent hashing with bounded loads in Golang

consistent This library provides a consistent hashing function which simultaneously achieves both uniformity and consistency. For detailed information

Releases(v0.3)
Owner
榆木
请相信你的指尖拥有改变世界的力量
榆木
Belajar Golang Install Golang

Golang belajar Golang Install Golang = download di https://golang.org/dl/ = pilih yg Zip = extract file zipnya = buka foldernya - copy folder go = pas

Arif Fadilah 1 Nov 15, 2021
Golang-module-references - A reference for how to setup a Golang project with modules - Task Management + Math Examples

Golang Module Project The purpose of this project is to act as a reference for setting up future Golang projects using modules. This project has a mat

Bob Bass 0 Jan 2, 2022
Golang-echo-sample - Make an out-of-the-box backend based on golang-echo

Golang-echo-sample - Make an out-of-the-box backend based on golang-echo

Haitwang 0 Dec 31, 2021
Minimalistic, pluggable Golang evloop/timer handler with dependency-injection

Anagent Minimalistic, pluggable Golang evloop/timer handler with dependency-injection - based on codegangsta/inject - go-macaron/inject and chuckpresl

Ettore Di Giacinto 15 Sep 27, 2022
GoLang Library for Browser Capabilities Project

Browser Capabilities GoLang Project PHP has get_browser() function which tells what the user's browser is capable of. You can check original documenta

Maksim N. 43 Sep 27, 2022
Golang counters for readers/writers

Datacounter Golang counters for readers/writers. Examples ReaderCounter buf := bytes.Buffer{} buf.Write(data) counter := datacounter.NewReaderCounter(

Artem Andreenko 44 Oct 9, 2022
Golang beautify data display for Humans

Golang beautify data display for Humans English 简体中文 Install # Stable version go get -u -v gopkg.in/ffmt.v1 # Latest version go get -u -v github.com/

ffmt 283 Dec 1, 2022
a generic object pool for golang

Go Commons Pool The Go Commons Pool is a generic object pool for Golang, direct rewrite from Apache Commons Pool. Features Support custom PooledObject

jolestar 1.1k Dec 1, 2022
Resiliency patterns for golang

go-resiliency Resiliency patterns for golang. Based in part on Hystrix, Semian, and others. Currently implemented patterns include: circuit-breaker (i

Evan Huus 1.6k Dec 8, 2022
psutil for golang

gopsutil: psutil for golang This is a port of psutil (https://github.com/giampaolo/psutil). The challenge is porting all psutil functions on some arch

shirou 8.5k Dec 1, 2022