u2semi

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 9 Imported by: 0

README

U2semi

A web server running as a honeypot handling any requests.

Usage

NAME:
   U2semi - A honeypot working as a HTTP server

USAGE:
   U2semi [global options] command [command options] [arguments...]

COMMANDS:
   server, s   Start HTTP server
   version, v  Show version
   help, h     Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help (default: false)

Configuration

Custom header

You can add some items on response header like below.

web:
   headers:
      - key: Server
        value: Apache/2.4.2 (Unix) PHP/4.2.2
Custom content (json)
web:
   contents:
      /greet:
         body: 'Hello world'
      /ping:
         body: '{"message":"pong"}'
Custom content (directory)

This setting is given priority over json above.

web:
   content_directory: ./content/ # directory path which has files to return as response
   directory_listing_template: ./template/directory_listing.html # html template for directory listing

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf struct {
	Repo RepoConf `yaml:"repo"`
	Web  WebConf  `yaml:"web"`
}

func LoadConf added in v0.3.0

func LoadConf(path string) (*Conf, error)

type DirListPageTemplate

type DirListPageTemplate struct {
	ParentDir string
	Dir       string
	Files     []string
}
type Header struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

type RepoConf

type RepoConf struct {
	DSN string `yaml:"dsn"`
}

type Request

type Request struct {
	Method  string
	URL     string
	Proto   string
	Headers map[string]string
	Body    string
	IPFrom  string
	IPTo    string
}

type RequestRepository

type RequestRepository interface {
	Save(req *Request) error

	Migrate() error
}

type RootController

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

func NewRootController

func NewRootController(repo RequestRepository, conf *WebConf) *RootController

func (*RootController) HandlerAny

func (c *RootController) HandlerAny(w http.ResponseWriter, r *http.Request)

type WebConf

type WebConf struct {
	Port            int                    `yaml:"port"`
	Headers         []*Header              `yaml:"headers"`
	ContentDir      string                 `yaml:"content_directory"`
	DirListTemplate string                 `yaml:"directory_listing_template"`
	Contents        map[string]*WebContent `yaml:"contents"`
}

type WebContent

type WebContent struct {
	Body string `yaml:"body"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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