Empire icon indicating copy to clipboard operation
Empire copied to clipboard

corrected "selected" field assignment in InteractMenu.py

Open tamasbakos opened this issue 2 years ago • 1 comments

The "selected" field in the InteractMenu was not assigned correctly before. I changed it to assign the agent_name to the "selected" field, similarly as in other menus. Without this correction if you rename an agent, interact with its new name, and issue the "shell" command, the client will crash because it will try to find the agent in "state.agents" by session ID, even though it should search by name. Exception that occurs in this case without my correction:

(Empire: web05) > shell Traceback (most recent call last): File "/home/tamas/repos/Empire/empire.py", line 26, in client.start(args) File "/home/tamas/repos/Empire/empire/client/client.py", line 508, in start empire.main() File "/home/tamas/repos/Empire/empire/client/client.py", line 261, in main self.parse_command_line(text, cmd_line) File "/home/tamas/repos/Empire/empire/client/client.py", line 363, in parse_command_line menu_state.push( File "/home/tamas/repos/Empire/empire/client/src/MenuState.py", line 22, in push if menu.on_enter(**kwargs): ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tamas/repos/Empire/empire/client/src/menus/ShellMenu.py", line 31, in on_enter self.use(kwargs["selected"]) File "/home/tamas/repos/Empire/empire/client/src/menus/ShellMenu.py", line 50, in use self.session_id = state.agents[self.selected]["session_id"] ~~~~~~~~~~~~^^^^^^^^^^^^^^^ KeyError: 'F7EZCSH9'

tamasbakos avatar Nov 07 '23 20:11 tamasbakos

Thanks. works for me.

Probably would be better (but more work to fix) to have the state key be the session_id and just use name for display interaction purposes, but I'm fine with this soution.

Can you run the linting? Looks like its failing there. poetry run black . https://github.com/BC-SECURITY/Empire/blob/main/.github/CONTRIBUTING.md#code-formatting-and-linting

vinnybod avatar Nov 14 '23 05:11 vinnybod