-
Notifications
You must be signed in to change notification settings - Fork 128
/
Supernova.go
158 lines (124 loc) · 5.12 KB
/
Supernova.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package main
import (
"Supernova/Packages/Arguments"
"Supernova/Packages/Colors"
"Supernova/Packages/Converters"
"Supernova/Packages/Manager"
"Supernova/Packages/Utils"
"fmt"
"log"
"os"
"strconv"
"strings"
"time"
)
// main function
func main() {
// Declare variables
var template string
var encryptedShellcode []byte
var shellcode []byte
// Call function named PrintAscii
Arguments.PrintAscii()
// Call function named CheckGoVersion
Utils.CheckGoVersion()
// Parsing command line flags
options := Arguments.Options()
// Call function named ArgumentLength
Arguments.ArgumentLength(options.Version)
// Call function named ArgumentEmpty
Arguments.ArgumentEmpty(options.InputFile, 1)
// Call function named ShellcodeSizeValidation
fileSizeFlag := Arguments.ShellcodeSizeValidation(options.InputFile)
// If fileSizeFlag is true
if fileSizeFlag {
// Call function named ArgumentEmpty
Arguments.ArgumentEmpty(options.OutFile, 3)
}
// Call function named ArgumentEmpty
Arguments.ArgumentEmpty(options.Language, 2)
// Call function ValidateArgument
foundLanguage := Arguments.ValidateArgument("lang", options.Language, []string{"Nim", "Rust", "C", "CSharp", "Go", "Python", "PowerShell", "Perl", "VBA", "Ruby", "Java", "Raw"})
if options.Encryption == "" && options.Obfuscation == "" {
logger := log.New(os.Stderr, "[!] ", 0)
logger.Fatal("Please choose either the Encryption option (-enc) or the Obfuscation option (-obf) to proceed, or select both.\n\n")
}
// if Encryption option is enable
if options.Encryption != "" {
// Call function named ValidateArgument
Arguments.ValidateArgument("enc", options.Encryption, []string{"ROT", "XOR", "RC4", "AES", "CHACHA20"})
}
// Obfuscation option is enable
if options.Obfuscation != "" {
// Call function named ValidateArgument
Arguments.ValidateArgument("obf", options.Obfuscation, []string{"IPV4", "IPV6", "MAC", "UUID"})
}
// Call function name ConvertShellcode2String
rawShellcode, err := Converters.ConvertShellcode2String(options.InputFile)
if err != nil {
fmt.Println("[!] Error:", err)
return
}
// Call function named ConvertShellcode2Hex
convertedShellcode, payloadLength := Converters.ConvertShellcode2Hex(rawShellcode, foundLanguage)
// Convert the integer to a string
payloadLengthString := strconv.Itoa(payloadLength)
// Print payload size and chosen language
fmt.Printf("[+] Payload size: %s bytes\n\n[+] Converted payload to %s language\n\n", Colors.BoldCyan(payloadLengthString), strings.ToUpper(foundLanguage))
// if Debug true
if options.Debug {
switch fileSizeFlag {
case true:
fmt.Printf("[!] The size of the original shellcode exceeds the maximum display limit.\n\n[!] Supernova cannot display it on the screen.\n\n")
default:
// if language is raw
if foundLanguage == "raw" {
fmt.Printf("[!] The original shellcode is displayed in raw format represented as hexadecimal on the terminal.\n\n")
}
// Call function named ConvertShellcode2Template
template := Converters.ConvertShellcode2Template(convertedShellcode, foundLanguage, payloadLength, options.Variable)
// Print original template
fmt.Printf("[+] The original payload:\n\n%s\n\n", template)
}
}
// Encryption option is enable
if options.Encryption != "" {
// Record the start time
encryptionStartTime := time.Now()
// Call function named EncryptionManager
template, encryptedShellcode = Manager.EncryptionManager(options.Key, options.Encryption, options.Obfuscation, options.Debug, options.Variable, rawShellcode, foundLanguage, fileSizeFlag)
// Record the end time
encryptionEndTime := time.Now()
// Calculate the duration
encryptionDuration := encryptionEndTime.Sub(encryptionStartTime)
fmt.Printf("[+] Payload encryption with %s completed successfully! (Completed in %s)\n\n", strings.ToUpper(options.Encryption), encryptionDuration)
}
// Obfuscation option is enables
if options.Obfuscation != "" {
// Record the start time
encryptionStartTime := time.Now()
// if fileSizeFlag is enabled
if fileSizeFlag {
fmt.Printf("[!] Please be patient as Supernova processes your request.\n\n")
}
// Encryption option is enable
if options.Encryption != "" {
// Set as shellcode the encryptedShellcode (byte)
shellcode = encryptedShellcode
// Call function named ObfuscationManager
template = Manager.ObfuscationManager(shellcode, strings.ToLower(options.Obfuscation), foundLanguage, options.Variable, fileSizeFlag)
} else {
// Convert raw shellcode to bytes
shellcode = []byte(rawShellcode)
// Call function named ObfuscationManager
template = Manager.ObfuscationManager(shellcode, strings.ToLower(options.Obfuscation), foundLanguage, options.Variable, fileSizeFlag)
}
// Record the end time
encryptionEndTime := time.Now()
// Calculate the duration
encryptionDuration := encryptionEndTime.Sub(encryptionStartTime)
fmt.Printf("[+] Payload obfuscation as %s completed successfully! (Completed in %s)\n\n", strings.ToUpper(options.Obfuscation), encryptionDuration)
}
// Call function named OutputManager
Manager.OutputManager(options.OutFile, foundLanguage, template, options.Encryption, options.Obfuscation)
}