utils

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Mega = 1 << 20
)

Variables

This section is empty.

Functions

func ArgvFromCommandLine added in v1.5.0

func ArgvFromCommandLine(cl string) (argv []string, err error)

ArgvFromCommandLine returns an argv slice given a command line provided in argument

func CountFiles added in v1.5.0

func CountFiles(directory string) (cnt int)

CountFiles counts files in a directory

func EnableDNSLogs

func EnableDNSLogs() error

EnableDNSLogs through wevutil command line

func FlushDNSCache

func FlushDNSCache() error

FlushDNSCache executes windows command to flush the DNS cache

func GzipFile added in v1.5.0

func GzipFile(path string) (err error)

GzipFile compresses a file to gzip and deletes the original file

func HTTPGet

func HTTPGet(client *http.Client, url, outPath string) (err error)

HTTPGet helper function to issue a simple HTTP GET method

func IsPipePath added in v1.5.0

func IsPipePath(path string) bool

IsPipePath checks whether the argument path is a pipe

func JSON added in v1.5.0

func JSON(i interface{}) string

JSON returns a JSON string out of i

func PrettyJSON added in v1.5.0

func PrettyJSON(i interface{}) string

PrettyJSON returns a JSON pretty string out of i

func ReadFileString added in v1.5.0

func ReadFileString(path string) (string, error)

ReadFileString reads bytes from a file

func RegQuery added in v1.6.0

func RegQuery(key, value string) (string, error)

RegQuery issues a reg query command to dump registry

func Round added in v1.5.0

func Round(f float64, precision int) float64

Round float f to precision

func SvcFromPid added in v1.6.0

func SvcFromPid(pid int32) string

SvcFromPid returns the list of services hosted by a given PID interesting to know what service is hosted by svchost

func Unzip

func Unzip(zipfile, dest string) (err error)

Unzip helper function to unzip a file to a destination folder source code from : https://stackoverflow.com/questions/20357223/easy-way-to-unzip-file-with-golang

func Utf16ToUtf8 added in v1.7.0

func Utf16ToUtf8(b []byte) ([]byte, error)

Utf16ToUtf8 converts a utf16 encoded byte slice to utf8 byte slice it returns error if there is any decoding / encoding issue Inspired by: https://gist.github.com/bradleypeabody/185b1d7ed6c0c2ab6cec#file-gistfile1-go

Types

type ByteSlice added in v1.5.0

type ByteSlice []byte

func (ByteSlice) Len added in v1.5.0

func (b ByteSlice) Len() int

func (ByteSlice) Less added in v1.5.0

func (b ByteSlice) Less(i, j int) bool

func (ByteSlice) Swap added in v1.5.0

func (b ByteSlice) Swap(i, j int)

type WindowsLogger

type WindowsLogger struct {
	Channel string
	Source  string
	// contains filtered or unexported fields
}

WindowsLogger structure definition

func NewWindowsLogger

func NewWindowsLogger(channel, source string) (wl *WindowsLogger, err error)

NewWindowsLogger creates a new WindowsLogger structure

func (*WindowsLogger) Close

func (w *WindowsLogger) Close() error

Close closes the logger in a clean fashion

func (*WindowsLogger) Log

func (w *WindowsLogger) Log(eventid int, entrytype, message string)

Log logs a message through powershell Write-EventLog

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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