55 "Supernova/Packages/Converters"
66 "fmt"
77 "log"
8- "math/rand"
98 "os"
109 "strings"
1110)
@@ -58,12 +57,14 @@ func EnsureSegmentLength(segment string, desiredLength int) (string, int, []stri
5857 if len (segment ) < desiredLength {
5958 // Append random hex values until the segment reaches the desired length
6059 for len (segment ) < desiredLength {
61- randomHex := fmt .Sprintf ("%02X" , rand .Intn (240 )+ 16 )
60+ //randomHex := fmt.Sprintf("%02X", rand.Intn(240)+16)
61+ randomHex := "90"
6262 segment += strings .ToLower (randomHex )
6363 randomHexValues = append (randomHexValues , randomHex )
6464 totalRandomHexAdded ++
6565 }
6666 }
67+
6768 return segment , totalRandomHexAdded , randomHexValues
6869}
6970
@@ -166,7 +167,8 @@ func MacObfuscation(shellcode string) (string, int, []string) {
166167 if len (group ) < 6 {
167168 // Generate and append random hex values to the group
168169 for j := len (group ); j < 6 ; j ++ {
169- randomHex := fmt .Sprintf ("%02X" , rand .Intn (240 )+ 16 )
170+ //randomHex := fmt.Sprintf("%02X", rand.Intn(240)+16)
171+ randomHex := "90"
170172 group = append (group , strings .ToLower (randomHex ))
171173 randomHexValues = append (randomHexValues , randomHex )
172174 randomHexCount ++
@@ -201,7 +203,8 @@ func IPv6Obfuscation(shellcode string) ([]string, int, []string) {
201203
202204 // Generate random hexadecimal values and append them to the shellcode
203205 for i := 0 ; i < remaining ; i = i + 2 {
204- randomHex := fmt .Sprintf ("%X" , rand .Intn (240 )+ 16 )
206+ //randomHex := fmt.Sprintf("%X", rand.Intn(240)+16)
207+ randomHex := "90"
205208 shellcode += strings .ToLower (randomHex )
206209 randomHexValues = append (randomHexValues , randomHex )
207210 randomHexCount ++
@@ -233,15 +236,10 @@ func IPv6Obfuscation(shellcode string) ([]string, int, []string) {
233236}
234237
235238// IPv4Obfuscation function
236- func IPv4Obfuscation (shellcode string ) string {
239+ func IPv4Obfuscation (shellcode string ) ( string , int , [] string ) {
237240 // Arrays to store added numbers and their hexadecimal representations
238- var addedNumbers []int
239241 var hexRepresentations []string
240-
241- // Variables eclaration
242- var pronous string = "it"
243- var pronousNum string = "number"
244- var result string
242+ var addedNumbers []int
245243
246244 // Split the original string into chunks of four digits
247245 chunks := strings .Fields (shellcode )
@@ -267,18 +265,15 @@ func IPv4Obfuscation(shellcode string) string {
267265
268266 // Loop until the length of chunkResult is equal to 4
269267 for len (chunkResult ) < 4 {
270- // Generate a random decimal from 0 to 255
271- randomNumber := rand .Intn (256 )
272-
273- // Convert decimal to hexadecimal
274- randomHex := fmt .Sprintf ("0x%X" , randomNumber )
268+ //randomHex := fmt.Sprintf("0x%X", randomNumber)
269+ randomNumber := 90
275270
276271 // Convert the random number to a string
277272 randomString := fmt .Sprintf ("%d" , randomNumber )
278273
279274 // Add the random number and its hexadecimal representation to arrays
280275 addedNumbers = append (addedNumbers , randomNumber )
281- hexRepresentations = append (hexRepresentations , randomHex )
276+ hexRepresentations = append (hexRepresentations , randomString )
282277
283278 // Add the random string to the slice
284279 chunkResult = append (chunkResult , randomString )
@@ -287,45 +282,12 @@ func IPv4Obfuscation(shellcode string) string {
287282 // Print the message with the count of added numbers and their details
288283 count := len (addedNumbers )
289284
290- // if count more than one
291- if count > 1 {
292- pronousNum = "numbers"
293- }
294-
295- if count > 0 {
296- fmt .Printf ("[+] Configure payload length evenly for IPv4 obfuscation by adding %d random %s:\n \n " , count , pronousNum )
297-
298- // Iterate over each element and build the result string
299- for i , num := range addedNumbers {
300- hexRep := hexRepresentations [i ]
301-
302- // Append the formatted string to the result
303- if i < count - 1 {
304- result += fmt .Sprintf (Colors .BoldRed ("%d " ), num )
305- result += fmt .Sprintf ("=> byte(%s)" , Colors .BoldMagneta (strings .ToLower (hexRep )))
306- result += ", "
307- } else {
308- result += fmt .Sprintf (Colors .BoldRed ("%d " ), num )
309- result += fmt .Sprintf ("=> byte(%s)" , Colors .BoldMagneta (strings .ToLower (hexRep )))
310- }
311- }
312-
313- fmt .Print (" " + result + "\n \n " )
314-
315- // if generated numbers are more than one
316- if count > 1 {
317- pronous = "them"
318- }
319-
320- fmt .Printf ("[!] Be sure to remove %s during the implementation process!\n \n " , pronous )
321- }
322-
323285 // Join the last remaining elements into a string with dots
324286 configResult := strings .Join (chunkResult , "." )
325287
326288 shellcodeProperty += "\" " + configResult + "\" "
327289
328- return shellcodeProperty
290+ return shellcodeProperty , count , hexRepresentations
329291}
330292
331293// DetectObfuscation function
@@ -347,7 +309,19 @@ func DetectObfuscation(obfuscation string, shellcode []string) string {
347309 shellcodeStr := Converters .ShellcodeDecimalArray2String (shellcodeDecArray )
348310
349311 // Call function named IPv4Obfuscation
350- obfuscatedShellcodeString = IPv4Obfuscation (shellcodeStr )
312+ obfuscatedShellcodeString , randomHexCount , randomHexValues := IPv4Obfuscation (shellcodeStr )
313+
314+ // if count more than zero
315+ if randomHexCount > 0 {
316+ // if count more than one
317+ if randomHexCount > 1 {
318+ pronousChar = "bytes"
319+ pronous = "them"
320+ }
321+
322+ // Call function named CustomPayloadMessage
323+ CustomPayloadMessage (obfuscation , randomHexCount , randomHexValues , pronous , pronousChar )
324+ }
351325
352326 return obfuscatedShellcodeString
353327 case "ipv6" :
@@ -429,7 +403,7 @@ func CustomPayloadMessage(obfuscation string, randomHexCount int, randomHexValue
429403 // Declare variables
430404 var hexString string
431405
432- fmt .Printf ("[+] Configure payload length evenly for %s obfuscation by adding %d random %s:\n \n " , obfuscation , randomHexCount , pronousChar )
406+ fmt .Printf ("[+] Configure payload length evenly for %s obfuscation by adding %d NOP %s:\n \n " , strings . ToUpper ( obfuscation ) , randomHexCount , pronousChar )
433407
434408 // Iterate over each character
435409 for i , char := range randomHexValues {
@@ -444,6 +418,5 @@ func CustomPayloadMessage(obfuscation string, randomHexCount int, randomHexValue
444418
445419 fmt .Print (" " + hexString + "\n \n " )
446420
447- fmt .Printf ("[!] Be sure to remove %s during the implementation process!\n \n " , pronous )
448-
421+ //fmt.Printf("[!] Be sure to remove %s during the implementation process!\n\n", pronous)
449422}
0 commit comments