WebGuard

package module
v0.0.0-...-d46eaa4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

README

WebGuard

WebGuard是根据风起师傅的RedGuard和mgeeky师傅的RedWarden结合出来的http请求过滤器go包,亦在帮助采用go编写C2 http监听器做流量过滤和规则匹配

  • 例子:
package main

import (
	"fmt"
	"github.com/sairson/WebGuard"
	"net/http"
)

func main() {
	guard := WebGuard.New("cfg.yml", true, handler)
	http.HandleFunc("/", guard.RunGuard())
	http.ListenAndServe(":8555", nil)
}

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Println("ok")
}
  • 满足用户定义规则

image

  • 不满足用户定义规则,跳转到用户定义的360.net网址

image

程序会根据用户在cfg.yml进行规则匹配,当http或https请求流量传入后,会走WebGuard的规则匹配,如果满足则放行继续走我们的handler控制函数,否则的话,会根据配置进行流量drop或者反代到指定域名。以扰乱溯源人员分析

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPIntoSlices

func IPIntoSlices(ip string) ([]string, error)

func IPIntoSlicesA

func IPIntoSlicesA(ip string) ([]string, error)

func IPIntoSlicesB

func IPIntoSlicesB(ip string) ([]string, error)

func LoopUpLocation

func LoopUpLocation(locations []string, ip string) bool

LoopUpLocation 查询地理位置是否合法

func NewProxy

func NewProxy(proxyURL string, dropType bool) (*httputil.ReverseProxy, error)

func WebGuardFilter

func WebGuardFilter(cfg *viper.Viper, req *http.Request) (bool, error)

WebGuardFilter 过滤器,判断规则是否可用 req 请求接收 rules 指定的规则配置路径

Types

type WebGuard

type WebGuard struct {
	// contains filtered or unexported fields
}

WebGuard web卫兵配置

func New

func New(cfg string, hotLoading bool, logger func(in ...interface{}), handler func(w http.ResponseWriter, r *http.Request)) *WebGuard

func (*WebGuard) RunGuard

func (g *WebGuard) RunGuard() func(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL