netexec

package
v1.33.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdNetexec = &cobra.Command{
	Use:   "netexec",
	Short: "Creates HTTP(S), UDP, and (optionally) SCTP servers with various endpoints",
	Long: `Starts a HTTP(S) server on given port with the following endpoints:

- /: Returns the request's timestamp.
- /clientip: Returns the request's IP address.
- /header: Returns the request's header value corresponding to the key provided or the entire 
  header marshalled as json, if no form value (key) is provided.
  ("/header?key=X-Forwarded-For" or /header)
- /dial: Creates a given number of requests to the given host and port using the given protocol,
  and returns a JSON with the fields "responses" (successful request responses) and "errors" (
  failed request responses). Returns "200 OK" status code if the last request succeeded,
  "417 Expectation Failed" if it did not, or "400 Bad Request" if any of the endpoint's parameters
  is invalid. The endpoint's parameters are:
  - "host": The host that will be dialed.
  - "port": The port that will be dialed.
  - "request": The HTTP endpoint or data to be sent through UDP. If not specified, it will result
    in a "400 Bad Request" status code being returned.
  - "protocol": The protocol which will be used when making the request. Default value: "http".
    Acceptable values: "http", "udp", "sctp".
  - "tries": The number of times the request will be performed. Default value: "1".
- "/echo": Returns the given "msg" ("/echo?msg=echoed_msg"), with the optional status "code".
- "/exit": Closes the server with the given code and graceful shutdown. The endpoint's parameters
	are:
	- "code": The exit code for the process. Default value: 0. Allows an integer [0-127].
	- "timeout": The amount of time to wait for connections to close before shutting down.
		Acceptable values are golang durations. If 0 the process will exit immediately without
		shutdown.
	- "wait": The amount of time to wait before starting shutdown. Acceptable values are
	  golang durations. If 0 the process will start shutdown immediately.
- "/healthz": Returns "200 OK" if the server is healthy, "412 Status Precondition Failed"
  otherwise. The server is considered not ready if the UDP server did not start yet or
  it exited.
- "/readyz": Returns "200 OK" if the server is ready to receive traffic, "412 Status Precondition Failed", if the
  server is not yet ready to receive traffic, but may be ready later, and "503" if the server is shutting down.
  When a sig-term is observed, the /readyz will report 503, but healthz will report 200 to indicate that the
  server is healthy (don't kill it), but the it should not be sent traffic (remove from endpoints).
- "/hostname": Returns the server's hostname.
- "/hostName": Returns the server's hostname.
- "/redirect": Returns a redirect response to the given "location", with the optional status "code"
  ("/redirect?location=/echo%3Fmsg=foobar&code=307").
- "/shell": Executes the given "shellCommand" or "cmd" ("/shell?cmd=some-command") and
  returns a JSON containing the fields "output" (command's output) and "error" (command's
  error message). Returns "200 OK" if the command succeeded, "417 Expectation Failed" if not.
- "/shutdown": Closes the server with the exit code 0.
- "/upload": Accepts a file to be uploaded, writing it in the "/uploads" folder on the host.
  Returns a JSON with the fields "output" (containing the file's name on the server) and
  "error" containing any potential server side errors.

If "--tls-cert-file" is added (ideally in conjunction with "--tls-private-key-file", the HTTP server
will be upgraded to HTTPS. The image has default, "localhost"-based cert/privkey files at
"/localhost.crt" and "/localhost.key" (see: "porter" subcommand)

If "--http-override" is set, the HTTP(S) server will always serve the override path & options,
ignoring the request URL.

It will also start a UDP server on the indicated UDP port and addresses that responds to the following commands:

- "hostname": Returns the server's hostname
- "echo <msg>": Returns the given <msg>
- "clientip": Returns the request's IP address

The UDP server can be disabled by setting --udp-port to -1.

Additionally, if (and only if) --sctp-port is passed, it will start an SCTP server on that port,
responding to the same commands as the UDP server.
`,
	Args: cobra.MaximumNArgs(0),
	Run:  main,
}

CmdNetexec is used by agnhost Cobra.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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