File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
33import (
44 "encoding/hex"
55 "fmt"
6+ "io/ioutil"
67 "os"
78
89 shellcode "github.com/brimstone/go-shellcode"
@@ -16,13 +17,19 @@ import (
1617func main () {
1718
1819 if len (os .Args ) != 2 {
19- fmt .Printf ("Must have shellcode\n " )
20+ fmt .Printf ("Must have shellcode of file \n " )
2021 os .Exit (1 )
2122 }
22- sc , err := hex .DecodeString (os .Args [1 ])
23- if err != nil {
24- fmt .Printf ("Error decoding arg 1: %s\n " , err )
25- os .Exit (1 )
23+
24+ // First, try to read the arg as a file
25+ sc , err := ioutil .ReadFile (os .Args [1 ])
26+ if os .IsNotExist (err ) {
27+ // If that fails, try to interpret the arg as hex encoded
28+ sc , err = hex .DecodeString (os .Args [1 ])
29+ if err != nil {
30+ fmt .Printf ("Error decoding arg 1: %s\n " , err )
31+ os .Exit (1 )
32+ }
2633 }
2734
2835 shellcode .Run (sc )
You can’t perform that action at this time.
0 commit comments