2

In a Python Metasploit module that I'm developing, I am trying to use CMD as one of the options:

'options': { 'RHOST': {'type': 'address', 'description': 'Target address', 'required': True, 'default': None}, 'RPORT': {'type': 'port', 'description': 'Target port', 'required': True, 'default': 80}, 'CMD': {'type': 'string', 'description': 'Command to execute', 'required': True, 'default': 'whoami'} } 

However, when I print the args, CMD isn't set to the default value:

Args: {'RPORT': '9999', 'VERBOSE': 'false', 'THREADS': '1', 'ShowProgress': 'true', 'ShowProgressPercent':'10', 'UNPARSED_RHOSTS': '0.0.0.0', 'RHOSTNAME': '', 'RHOSTS': '0.0.0.0', 'WORKSPACE': '', 'RHOST': '0.0.0.0', 'rhost': '0.0.0.0'} 

And when I try to use set CMD whoami, I get the error Unknown datastore option: CMD.. What am I doing wrong? Am I only allowed to use certain names for my options?

I can see in modules/auxiliary/admin/sap/cve_2020_6207_solman_rce.rb that COMMAND is used as a datastore option, so I tried that as well and ran into the same issue as with CMD.

4
  • RPORT isn't the default. And you have 3 rhost fields. I think there is more wrong here than just the one field.
    – schroeder
    CommentedFeb 16, 2023 at 9:57
  • I set RPORT to that value, and for RHOST there are two set, one all caps and one lowercase, with a third being RHOSTS. Not sure why, but AFAICT those shouldn't affect functionality if I don't reference them. @schroeder any ideas what might be going wrong or how to fix it?CommentedFeb 16, 2023 at 13:01
  • I don't think you're done with troubleshooting. First figure out if your added code is actually being called.
    – schroeder
    CommentedFeb 16, 2023 at 14:51
  • It is being called, that's how I was able to print the argsCommentedFeb 16, 2023 at 20:12

1 Answer 1

2

In my case, the issue was the type of module created. My module that I wanted to use CMD / COMMAND for was in auxiliary/admin/http, which seems to not support that argument. When I moved the module to auxiliary/scanner/http, it started working like a charm!

For anyone else encountering this issue, also be sure that your module file is set to be executable with chmod +x.

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.