Skip to content

Commit

Permalink
Added Encryption Functions; Updated README; Change Ping -> IsHostUp
Browse files Browse the repository at this point in the history
  • Loading branch information
deranged0tter committed Jan 29, 2024
1 parent 62e7f43 commit 77e8a9b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
34 changes: 28 additions & 6 deletions encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions scanning.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 77e8a9b

Please sign in to comment.