Nmap scan nmap -A -Pn -oN nmap.txt 10.10.10.198 TCP 8080 is found Gym management software This is the main page of the gym management web application On the contact page it shows the Gym Management Software 1.0. Gym Management Software vulnerability By searching the web there is a vulnerability of Gym Management software version 1.0 … Continue reading hackthebox – Buff
Author: cyruslab
python – Generating RSA key pairs with pycryptodome module
Thank you for the creator of pycryptodome module, this module has made RSA key pair easy. This recipe presents a function for generating private and public key pair. from Crypto.PublicKey import RSA # pycryptodome def rsa_key_gen(bits=2048, privatekey_path=RSA_PRIVATE_KEY, pubkey_path=RSA_PUBLIC_KEY): private_key = RSA.generate(bits) with open(privatekey_path, "wb") as privkey_file: privkey_file.write(private_key.export_key()) with open(pubkey_path, "wb") as pubkey_file: pubkey_file.write(private_key.publickey().export_key())
Golang – Writing a command line program with urfave/cli package
The code recipe is modified from this video made by tutorialedge.net, this recipe does these: Help interface. To find out ipv4 address from fqdn: cli --host http://www.google.com ip Resolve FQDN to IPv4 addresses. To find out cname from given host: cli --host google.com cname Get the cname from given host. To find out mx records … Continue reading Golang – Writing a command line program with urfave/cli package
Golang – Encode Json data
This recipe demonstrates how to use struct to encode to json data. The struct type and its attributes have to be exportable in order for json encoding. The json data uses the attributes of struct type as keys if there is no customize key name defined. package main import ( "encoding/json" "fmt" "log" ) // … Continue reading Golang – Encode Json data
Golang – Find absolute path of a file.
This recipe finds the absolute path of the specified filename, the problem with this code is that it returns the first match and hence only useful if the filename is unique. package main import ( "fmt" "log" "os" "path/filepath" ) var absPath string // global variable to store absolute path of filename. func findFileAbsPath(basepath, filename … Continue reading Golang – Find absolute path of a file.
Golang – Check if IPv4 is valid and resolve FQDN
This recipe demonstrates if string is a valid IPv4, and also to resolve a FQDN to IP address. This recipe uses os.Args to get the second argument as FQDN and call net.ResolveIPAddr() function to do a FQDN resolution to IP address. package main import ( "fmt" "log" "net" "os" ) func isIPv4Addr(ip string) bool { … Continue reading Golang – Check if IPv4 is valid and resolve FQDN
Golang – Write sentence to file
This recipe demonstrates how to use flag to build a command line program, how to convert string slice to string and how to write sentence to file specified by user. Usage example: writefile -f test.txt hi this is a test. package main import ( "flag" "io" "log" "os" "strings" ) func convertSliceToString(s []string) string { … Continue reading Golang – Write sentence to file
Golang – Download files from website
This recipe downloads all kinds of files from website, but there is no progress tracking, only download the file. package main import ( "io" "log" "net/http" "os" ) func downloadFile(filepath, url string) error { resp, err := http.Get(url) if err != nil { return err } defer resp.Body.Close() f, err := os.Create(filepath) if err != … Continue reading Golang – Download files from website
Golang – Template
In python I can use Jinja2 template module to parse variables to Cisco command template, in Golang there is text/template which is similar to Jinja2 template engine for python. This recipe gives an example on how to parse variables into a text template. The types within the struct have to be exported in order for … Continue reading Golang – Template
Golang – Obfuscate password input
This recipe shows how to obfuscate the password when user is typing the password. package p1 import ( "fmt" "log" "os" "golang.org/x/crypto/ssh/terminal" ) func getPassword() string { fmt.Println("\nPassword: ") // https://godoc.org/golang.org/x/crypto/ssh/terminal#ReadPassword // terminal.ReadPassword accepts file descriptor as argument, returns byte slice and error. passwd, e := terminal.ReadPassword(int(os.Stdin.Fd())) if e != nil { log.Fatal(e) } // … Continue reading Golang – Obfuscate password input