Skip to content

Commit

Permalink
Integrated sgn with generate shellcode
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch-- committed Aug 24, 2022
1 parent 68e9dcc commit f0405a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion client/command/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,12 +636,34 @@ func compile(config *clientpb.ImplantConfig, save string, con *console.SliverCon
return nil, errors.New("no file data")
}

fileData := generated.File.Data
if config.IsShellcode {
confirm := false
survey.AskOne(&survey.Confirm{Message: "Encode shellcode with shikata ga nai?"}, &confirm)
if confirm {
con.PrintInfof("Encoding shellcode with shikata ga nai ... ")
resp, err := con.Rpc.ShellcodeEncoder(context.Background(), &clientpb.ShellcodeEncodeReq{
Encoder: clientpb.ShellcodeEncoder_SHIKATA_GA_NAI,
Architecture: config.GOARCH,
Iterations: 1,
BadChars: []byte{},
Data: fileData,
})
if err != nil {
con.PrintErrorf("%s\n", err)
} else {
con.Printf("success!\n")
fileData = resp.GetData()
}
}
}

saveTo, err := saveLocation(save, generated.File.Name)
if err != nil {
return nil, err
}

err = ioutil.WriteFile(saveTo, generated.File.Data, 0700)
err = ioutil.WriteFile(saveTo, fileData, 0700)
if err != nil {
con.PrintErrorf("Failed to write to: %s\n", saveTo)
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion server/sgn/sgn.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func EncodeShellcode(shellcode []byte, arch string, iterations int, badChars []b
config := SGNConfig{
AppDir: assets.GetRootAppDir(),

Architecture: arch,
Architecture: strings.ToLower(arch),
Iterations: iterations,
MaxObfuscation: 20,
Safe: false,
Expand Down

0 comments on commit f0405a3

Please sign in to comment.