MCPcopy
hub / github.com/Ne0nd0g/merlin / ParseShellcode

Function ParseShellcode

pkg/modules/shellcode/shellcode.go:107–118  ·  view source on GitHub ↗

ParseShellcode determines if the inputs is a file and/or what format the shellcode is in (hex, binary, CSharp) Input string can be a file path or shellcode itself

(shellcode string)

Source from the content-addressed store, hash-verified

105// ParseShellcode determines if the inputs is a file and/or what format the shellcode is in (hex, binary, CSharp)
106// Input string can be a file path or shellcode itself
107func ParseShellcode(shellcode string) ([]byte, error) {
108 // Check if shellcode argument is a file path
109 f, errF := os.Stat(shellcode)
110 // If it is, check to see if it using what format it is using?
111 if errF != nil {
112 return parseHex([]string{shellcode})
113 }
114 if f.IsDir() {
115 return nil, fmt.Errorf("a directory was provided instead of a file: %s", shellcode)
116 }
117 return parseShellcodeFile(shellcode)
118}
119
120// parseHex evaluates a string array to determine its format and returns a byte array of the hex
121func parseHex(str []string) ([]byte, error) {

Callers 1

ParseFunction · 0.92

Calls 2

parseHexFunction · 0.85
parseShellcodeFileFunction · 0.85

Tested by

no test coverage detected