Skip to content

Fix KeyError catches on unsafe key accesses with RPC calls #95

@wrinklykong

Description

@wrinklykong

Risky direct Key accesses on results of rpc calls are preformed throughout msfrpc.py and should be changed to .get() to avoid uncaught KeyErrors being thrown.

Examples:

return self.rpc.call(MsfRpcMethod.DbWorkspaces)['workspaces']

https://github.com/DanMcInerney/pymetasploit3/blob/9776da55b0abacfa843a32204f3972ec7d9b3de7/pymetasploit3/msfrpc.py#L1691C16-L1691C16

I suggest doing something like:
val = <rpc_call>.get('<keyname>') if not val: raise Exception

or just surrounded them with a KeyError catch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions