guardicore / monkey

Infection Monkey - An open-source adversary emulation platform
https://www.guardicore.com/infectionmonkey/
GNU General Public License v3.0
6.55k stars 763 forks source link

Support different windows system languages #3432

Open VakarisZ opened 1 year ago

VakarisZ commented 1 year ago

Is your feature request related to a problem? Please describe. If the system language on windows is not English some CMD commands will fail. This happens due to the agent parsing the command line output as if it was English. Various other bugs will happen when trying to read non-english text, for example (monkey v2.2.0, French system language):

2023-06-16 16:21:08,127 [7516:MainThread:ERROR] main._run_agent.174: Exception thrown from monkey's start function. More info: 'utf-8' codec can't decode byte 0x8a in position 7: invalid start byte
Traceback (most recent call last):
  File "infection_monkey\main.py", line 172, in _run_agent
  File "infection_monkey\monkey.py", line 295, in start
  File "infection_monkey\monkey.py", line 334, in _setup
  File "infection_monkey\network\firewall.py", line 60, in is_enabled
    for line in out.decode().splitlines():
                ^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 7: invalid start byte
2023-06-16 16:21:08,128 [7516:MainThread:INFO] monkey.cleanup.503: Agent cleanup started
2023-06-16 16:21:08,223 [7516:MainThread:ERROR] monkey.cleanup.534: An error occurred while cleaning up the monkey agent: 'utf-8' codec can't decode byte 0x8a in position 7: invalid start byte
Traceback (most recent call last):
  File "infection_monkey\monkey.py", line 512, in cleanup
  File "infection_monkey\network\firewall.py", line 60, in is_enabled
    for line in out.decode().splitlines():
                ^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 7: invalid start byte

Describe the solution you'd like

Use more robust decoders and parse response values by position to support more different system languages for windows

Describe alternatives you've considered

Bratox commented 1 year ago

Here is a solution to solve this issue when you don't want to change your system language Go to Settings and Time & Language image Language image Administrative language settings image Click on Change system locale image And check Beta : Use Unicode UTF-8... image This should help you to make Infection Monkey work in your non English System