File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
3
3
import (
4
4
"encoding/hex"
5
5
"fmt"
6
+ "io/ioutil"
6
7
"os"
7
8
8
9
shellcode "github.com/brimstone/go-shellcode"
@@ -16,13 +17,19 @@ import (
16
17
func main () {
17
18
18
19
if len (os .Args ) != 2 {
19
- fmt .Printf ("Must have shellcode\n " )
20
+ fmt .Printf ("Must have shellcode of file \n " )
20
21
os .Exit (1 )
21
22
}
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
+ }
26
33
}
27
34
28
35
shellcode .Run (sc )
You can’t perform that action at this time.
0 commit comments