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

Unable to add arguments to extensions #1493

Closed
plackyhacker opened this issue Dec 6, 2023 · 5 comments
Closed

Unable to add arguments to extensions #1493

plackyhacker opened this issue Dec 6, 2023 · 5 comments
Labels
enhancement New feature or request v1.6.x

Comments

@plackyhacker
Copy link

Describe the bug
When I add arguments to an extension the client crashes and displays the following error:

panic: missing arg value: arg 'arguments' not registered

To Reproduce
Steps to reproduce the behavior:

Using the following .json file:

{
    "name": "SliverGetSystem",
    "command_name": "get-system",
    "version": "0.0.1",
    "extension_author": "plackyhacker",
    "original_author": "plackyhacker",
    "repo_url": "",
    "help": "Uses the SCM to get system on a local or remote host. Needs admin privileges.",
    "entrypoint": "Execute",
    "files": [
        {
            "os": "windows",
            "arch": "386",
            "path": "SliverGetSystem.x86.dll"
        },
        {
            "os": "windows",
            "arch": "amd64",
            "path": "SliverGetSystem.x64.dll"
        }
    ],
    "arguments": [
        {"name": "target", "type": "string", "desc": "The target.", "optional": false},
        {"name": "service", "type": "string", "desc": "The target service.", "optional": false},
        {"name": "payload", "type": "string", "desc": "The payload to execute.", "optional": false}
    ]
}
  1. extensions install ./Payloads/SliverGetSystem
  2. reload the client
  3. use {guid}
  4. get-system localhost service name "my payload"

Expected behavior
I would expect the extension to be loaded and executed on the target beacon.

Desktop (please complete the following information):

  • OS: Linux parrot
  • Version 6.1.0-1
@rkervella
Copy link
Member

rkervella commented Dec 6, 2023

This is poorly documented at the moment, but extensions other than BOFs don't support typed arguments. Arguments are passed as a single string to the extension, and it's up to the extension code to parse it. You can check this example for reference.
This is planned for v1.6.

@rkervella rkervella added enhancement New feature or request v1.6.x labels Dec 6, 2023
@plackyhacker
Copy link
Author

Thanks for the quick response. The example given only uses numbers as args.

In my extension I am parsing the arg string myself but I noticed that ' and " characters seem to be taken out. If I pass:

get-system arg1 arg2 "arg3 with some spaces in it"

What I get on the input argsBuffer is:

arg1 arg2 arg3 with some spaces in it

This breaks the arguments down from the intended 3 to 8. Is there something I should be aware of when passing a string as arguments? I am using C to code the extension.

Thanks in advance.

@plackyhacker
Copy link
Author

I should clarify, I have now removed the arguments from the json file.

@rkervella
Copy link
Member

That's because the arguments are first interpreted as a string slice and then merged into a single string with strings.Join() with space as a delimiter:

extArgs := strings.Join(ctx.Args.StringList("arguments"), " ")

This is one of the shortcomings we have with extensions right now that will be solved in 1.6 once we merge #1424.
You could try something like this:

get-system arg1 arg2 '"arg3 with some spaces in it"'

@plackyhacker
Copy link
Author

plackyhacker commented Dec 6, 2023

Brilliant, thanks for the information. I can work around this now I know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v1.6.x
Projects
None yet
Development

No branches or pull requests

2 participants