diff --git a/README.md b/README.md index 6a379af..5801b13 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,18 @@ GenerateKey() ([]byte, error) GenerateIV() ([]byte, error) generate a 16 byte secure IV +EncryptBytes(message []byte, key []byte) ([]byte, error) + encrypt a []byte using given key + +EncryptString(s string, key []byte) ([]byte, error) + return encrypted string using given key + +DecryptBytes(message []byte, key []byte) ([]byte, error) + decrypt []byte with given key + +DecryptString(s string, key []byte) (string, error) + return a decrypted string using given key + RandomInt(min int, max int) (int, error) return a random int between min and max @@ -266,6 +278,11 @@ GetCurrentProcArch() string ## Injection Functions ## Scanning Functions +``` +IsHostUp(host string) (bool, error) + ping a given ip + returns true if host is up +``` ## Evasion Functions diff --git a/encryption.go b/encryption.go index bb9fb1d..4174572 100644 --- a/encryption.go +++ b/encryption.go @@ -71,17 +71,39 @@ func EncryptBytes(message []byte, key []byte) ([]byte, error) { } // return encrypted string using given key -func EncryptString(s string, key []byte) (string, error) { - c, err := EncryptBytes([]byte(s), key) +func EncryptString(s string, key []byte) ([]byte, error) { + return EncryptBytes([]byte(s), key) +} + +// decrypt []byte with given key +func DecryptBytes(message []byte, key []byte) ([]byte, error) { + iv := message[0:16] + cText := message[16:] + + cipherBlock, err := aes.NewCipher(key) if err != nil { - return "", err + return nil, err } - return string(c), nil + c := cipher.NewCBCDecrypter(cipherBlock, iv) + d := make([]byte, len(cText)) + c.CryptBlocks(d, cText) + + lenBytes := d[0:4] + len := binary.LittleEndian.Uint32(lenBytes) + d = d[4:] + return d[:len], nil } -// decrypt []byte with given key -func Decrypt +// return a decrypted string using given key +func DecryptString(s string, key []byte) (string, error) { + d, err := DecryptBytes([]byte(s), key) + if err != nil { + return "", err + } + + return string(d), nil +} // return a random int between min and max func RandomInt(min int, max int) (int, error) { diff --git a/scanning.go b/scanning.go index 0639b74..714e38a 100644 --- a/scanning.go +++ b/scanning.go @@ -6,11 +6,11 @@ import ( // ping a given ip // returns true if host is up -func IsHostUp(ip string) (bool, error) { +func IsHostUp(host string) (bool, error) { var isUp bool // new pinger - pinger, err := ping.NewPinger(ip) + pinger, err := ping.NewPinger(host) if err != nil { return false, err }