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)
| 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 |
| 107 | func 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 |
| 121 | func parseHex(str []string) ([]byte, error) { |
no test coverage detected