Skip to content

Commit

Permalink
🎉 Initial commint
Browse files Browse the repository at this point in the history
  • Loading branch information
yutianqaq committed Feb 3, 2024
0 parents commit cf1920d
Show file tree
Hide file tree
Showing 28 changed files with 3,334 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
dist/
24 changes: 24 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
builds:
- binary: Supernova
main: ./Supernova.go
flags:
- -trimpath
ldflags:
- -s -w
goos:
- linux
- windows
- darwin
goarch:
- amd64
- 386

archives:
- id: tgz
format: tar.gz
format_overrides:
- goos: windows
format: zip
name_template: "Supernova_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
files:
- none*
86 changes: 86 additions & 0 deletions Arguments/Arguments.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package Arguments

import (
"flag"
"fmt"
"log"
"os"
"strings"
)

// ArgumentLength function
func ArgumentLength(versionFlag bool) {
logger := log.New(os.Stderr, "[!] ", 0)
// if no arguments print help menu
if len(os.Args) == 1 {
fmt.Println("Usage of Suprenova.exe:")
flag.PrintDefaults()
os.Exit(0)
// If arguments are more than 2
} else if len(os.Args) > 2 {
// if versionFlag is enabled
if versionFlag != false {
logger.Fatal("You cannot use the -version flag in conjunction with other arguments.")
}
}
}

// ShowVersion function
func ShowVersion(version string, versionFlag bool) {
// if arguments are 2
if len(os.Args) == 2 {
// if versionFlag is enabled
if versionFlag != false {
fmt.Printf("[+] Current version: " + version + "\n\n")
os.Exit(0)
} else {
fmt.Println("Usage of Suprenova.exe:")
flag.PrintDefaults()
os.Exit(0)
}
}
}

// ArgumentEmpty function
func ArgumentEmpty(statement string, option int) {
if statement == "" {
logger := log.New(os.Stderr, "[!] ", 0)
switch option {
case 1:
logger.Fatal("Please provide a path to a file containing raw 64-bit shellcode.")
case 2:
logger.Fatal("Please provide a valid value for the programming language (e.g., C++, CSharp, Rust, Nim).")
case 3:
logger.Fatal("Please provide a valid value for the encryption (e.g., ROT, XOR, RC4, AES).")
default:
logger.Fatal("Invalid option specified for ArgumentEmpty function.")
}
}
}

// ValidateArgument function
func ValidateArgument(argName string, argValue string, validValues []string) string {
for _, valid := range validValues {
if strings.ToLower(argValue) == strings.ToLower(valid) {
valid = strings.ToLower(valid)
return valid
}
}
fmt.Printf("[!] Invalid value '%s' for argument '%s'. Valid values are: %v\n", argValue, argName, validValues)
os.Exit(1)
return ""
}

// ValidateKeySize function
func ValidateKeySize(key int, encryption string) {
logger := log.New(os.Stderr, "[!] ", 0)
if key <= 0 {
logger.Fatal("Please provide a valid key value for the size...\n")
}

if encryption == "aes" {
if key > 1 {
logger.Fatal("The AES cipher does not require a separate 'key' argument. It employs a standard key length of 32-byte. Please remove it...\n")
}
}
}
104 changes: 104 additions & 0 deletions Converters/Converters.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package Converters

import (
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"strings"
)

// ConvertShellcode2Hex
func ConvertShellcode2Hex(shellcode string, language string) (string, int) {
// Convert raw shellcode to hexadecimal
hexShellcode := hex.EncodeToString([]byte(shellcode))

// Split hex shellcode into individual hex values
hexValues := strings.Split(hexShellcode, "")

formattedHexShellcode := ""

// Format and add "0x" in front of each pair of hex characters
for i := 0; i < len(hexValues); i += 2 {
formattedHexShellcode += "0x" + hexValues[i] + hexValues[i+1]
if i < len(hexValues)-2 {
formattedHexShellcode += ", "
}
}

// Calculate shellcode size in bytes
shellcodeSize := len(shellcode)

return formattedHexShellcode, shellcodeSize
}

// ConvertShellcode2Template function
func ConvertShellcode2Template(shellcode string, language string, length int, variable string) string {
switch language {
case "c":
template := fmt.Sprintf(`unsigned char %s[] = "%s";`, variable, shellcode)
return template
case "csharp":
template := fmt.Sprintf(`byte[] %s = new byte[%d] {%s};`, variable, length, shellcode)
return template
case "nim":
template := fmt.Sprintf(`var %s: array[%d, byte] = [byte %s]`, variable, length, shellcode)
return template
case "rust":
template := fmt.Sprintf(`let %s: [u8; %d] = [%s];`, variable, length, shellcode)
return template
case "go":
template := fmt.Sprintf(`%s := []byte{%s}`, variable, shellcode)
return template
default:
fmt.Println("[!] Unsupported programming language:", language)
os.Exit(1)
return ""
}
}

// ConvertShellcode2String function
func ConvertShellcode2String(shellcodePath string) (string, error) {
// Read the contents of the file into a byte slice
fileContent, err := ioutil.ReadFile(shellcodePath)
if err != nil {
return "", err
}

// Convert the byte slice to a string
rawShellcode := strings.TrimSpace(string(fileContent))

return rawShellcode, nil
}

// FormatKeysToHex function
func FormatKeysToHex(byteArray []byte) string {
var hexBytes []string
for _, byteVal := range byteArray[:len(byteArray)-1] {
hexBytes = append(hexBytes, fmt.Sprintf("0x%02x", byteVal))
}
hexBytes = append(hexBytes, fmt.Sprintf("0x%02x", byteArray[len(byteArray)-1]))

return strings.Join(hexBytes, ", ")
}

// FormatShellcode function
func FormatShellcode(encryptedShellcode []byte) string {
var formattedShellcode []string
for _, b := range encryptedShellcode {
formattedShellcode = append(formattedShellcode, fmt.Sprintf("0x%02x", b))
}

shellcodeFormatted := strings.Join(formattedShellcode, ", ")

return shellcodeFormatted
}

// AddValues2Template function
func AddValues2Template(operatingSystem string, template string) string {
if strings.ToLower(operatingSystem) == "linux" {
template = "#include <Windows.h>" + template
}

return template
}
Loading

0 comments on commit cf1920d

Please sign in to comment.