Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn user about improper flag usage. #1169

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion client/command/alias/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,17 @@ func runAliasCommand(ctx *grumble.Context, con *console.SliverConsoleClient) {
// Groupping the two conditions together could crash the client since ctx.Flags.Type panics
// if the flag is not registered.
if aliasManifest.IsAssembly {
if !ctx.Flags.Bool("in-process") {
inProcess := ctx.Flags.Bool("in-process")
runtime := ctx.Flags.String("runtime")
amsiBypass := ctx.Flags.Bool("amsi-bypass")
etwBypass := ctx.Flags.Bool("etw-bypass")
if !inProcess {
msgStr = " Arguments are limited to 256 characters when using the default fork/exec model for .NET assemblies.\nConsider using the --in-process flag to execute .NET assemblies in-process and work around this limitation.\n"
}
if !inProcess && (runtime != "" || etwBypass || amsiBypass) {
con.PrintErrorf("The --runtime, --etw-bypass, and --amsi-bypass flags can only be used with the --in-process flag\n")
return
}
} else if !aliasManifest.IsReflective {
msgStr = " Arguments are limited to 256 characters when using the default fork/exec model for non-reflective PE payloads.\n"
}
Expand Down
5 changes: 5 additions & 0 deletions client/command/exec/execute-assembly.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func ExecuteAssemblyCmd(ctx *grumble.Context, con *console.SliverConsoleClient)
etwBypass := ctx.Flags.Bool("etw-bypass")
amsiBypass := ctx.Flags.Bool("amsi-bypass")

if !inProcess && (runtime != "" || etwBypass || amsiBypass) {
con.PrintErrorf("The --runtime, --etw-bypass, and --amsi-bypass flags can only be used with the --in-process flag\n")
return
}

assemblyArgsStr := strings.Join(assemblyArgs, " ")
assemblyArgsStr = strings.TrimSpace(assemblyArgsStr)
if len(assemblyArgsStr) > 256 && !inProcess {
Expand Down