Commit Graph

5436 Commits

Author SHA1 Message Date
Mike Salvatore 8995eb5d2f Island: Add get_managed_instances() to AWSService 2022-05-09 10:09:17 -04:00
Mike Salvatore acabc835d4 Island: Add run_agent_on_managed_instances() to AWSService 2022-05-09 09:23:35 -04:00
Mike Salvatore 0f4b69a6f7 Island: Add stateful AWSService 2022-05-09 09:13:03 -04:00
Mike Salvatore e83848c8a4 Island: Add AWSInstance to the DIContainer 2022-05-09 08:54:35 -04:00
Mike Salvatore 7864f48e3c Common: Make AWSInstance.is_instance() return boolean 2022-05-09 07:39:05 -04:00
Mike Salvatore 7af03a83f6 Common: Simplify attribute assignment in AWSInstance 2022-05-09 06:44:21 -04:00
Shreya Malviya 28f60d51ff
Island: Use lock when creating an edge in the db
Fixes #1917
PR #1932
2022-05-09 06:28:11 -04:00
Mike Salvatore d861328fbf Common: Use relative import for aws_metadata module 2022-05-06 04:36:50 -04:00
Mike Salvatore 73e7e31a63 UT: Fix names in test_aws_metadata.py 2022-05-06 04:31:10 -04:00
Mike Salvatore 8d24b913df Common: Raise exception if AWS metadata requests fail 2022-05-06 04:22:17 -04:00
Mike Salvatore ca38235b8e Common: Set AWSInstance.is_instance to False if empty string 2022-05-06 04:07:40 -04:00
Mike Salvatore 09218ef3d3 UT: Add tests for AWSInstance 2022-05-06 04:07:16 -04:00
Mike Salvatore 10136a325c Common: Import AWSInstance in common/aws/__init__.py 2022-05-06 03:56:47 -04:00
Mike Salvatore 07f57a83ad Common: Refactor aws_metadata to improve readablility 2022-05-05 15:14:47 -04:00
Mike Salvatore d977d19d9f Common: Lazy-load AWSInstance 2022-05-05 15:01:37 -04:00
Mike Salvatore ab136284dc Common: Remove disused AWSInstance.get_account_id() 2022-05-05 11:39:49 -04:00
Mike Salvatore 64f9bcacb5 Common: Rename AwsInstance -> AWSInstance 2022-05-05 11:29:08 -04:00
Mike Salvatore 17db25b00b Agent: Log MSSQL error when authentication fails 2022-05-03 13:58:13 -04:00
Mike Salvatore 2d685ef44a Agent: Log agent's GUID 2022-05-03 13:58:13 -04:00
Mike Salvatore 0fce4e88a5 Agent: Drop CREDENTIALS_POLL_PERIOD_SEC from 30 to 10 2022-05-03 13:58:13 -04:00
Ilija Lazoroski 86c6a55097 Island, UT: Fix file_utils paths 2022-05-03 10:45:12 -04:00
Mike Salvatore 3a98fdbf52 UT: Use MappingProxyType for defaults in get_test_aws_instance() 2022-05-02 09:50:56 -04:00
Mike Salvatore a466e97cb0 Island: Move AwsCmdRunner to monkey_island/cc/server_utils/ 2022-05-02 09:28:41 -04:00
Mike Salvatore ceebdea3a9 Island: Use aws_service.get_account_id() in AWSExporter 2022-05-02 09:21:02 -04:00
Mike Salvatore 56ea170808 Island: Add get_account_id() to aws_service 2022-05-02 09:20:41 -04:00
Mike Salvatore ae83c2e3e0 Island: Relocate aws_service from common to monkey_island 2022-05-02 09:16:59 -04:00
Mike Salvatore 2714617797 Agent: Use AwsInstance instead of aws_service 2022-05-02 09:10:37 -04:00
vakarisz e89589762e Common: Rever singleton from WeakValueDictionary to simple dictionary 2022-05-02 15:55:12 +03:00
vakarisz f3a5a7090b Agent, Island, Common: Refactor AwsService from class to package
This also changes AwsInstance from singleton and instead the aws_service package is used as one
2022-05-02 15:55:12 +03:00
vakarisz 7b2ff1e159 Common: Remove CloudInstance since aws is the only cloud supported
This change simplifies the codebase by removing unnecessary inheritance and nested directory structure
2022-05-02 15:55:12 +03:00
vakarisz c5a126ff13 UT: Fix AWS instance unit tests 2022-05-02 15:55:12 +03:00
vakarisz e51b760af0 Common: Improve singleton to use WeakValueDictionary 2022-05-02 15:55:12 +03:00
Mike Salvatore 797482a172 Common: Replace protected attributes with read-only properties 2022-05-02 15:55:12 +03:00
vakarisz b58d847e22 Island: Refactor lock to event in remote_run_aws.py 2022-05-02 15:55:12 +03:00
vakarisz fead7f602e Island, Common: Change AwsInstance properties to private, add getter 2022-05-02 15:55:12 +03:00
vakarisz f63bc77df0 Common: Fix aws_instance.py formatting 2022-05-02 15:55:12 +03:00
vakarisz 8535118e4f Island: Add locks to remote_run_aws.py
Locks will avoid the situation where is_running_on_aws is called before this service finished initializing
2022-05-02 15:55:12 +03:00
vakarisz d3c1ff89e9 Island: Run AWS services on separate threads
AWS related services call AWS metadata service which might take a long time to timeout, that's why they are ran on a separate thread
2022-05-02 15:55:11 +03:00
vakarisz 0e1ffb4051 Common: Change AwsInstance to be a Singleton 2022-05-02 15:55:11 +03:00
vakarisz 65eb9b171b Island, Common: Move singleton to code_utils.py in common
Singleton is a common pattern, potentially usable in the Agent so it belongs in common
2022-05-02 15:55:11 +03:00
Ilija Lazoroski 0a145be25d Build: Change BUILD file to include commit hash on dev builds
Issue #1553
2022-04-29 10:52:52 -04:00
Mike Salvatore f65e009db6 Agent: Add comment about slow SMB transfer speeds 2022-04-29 06:58:48 -04:00
Mike Salvatore c4edec80a6
Common: Fix typo touples -> tuples
Co-authored-by: ilija-lazoroski <ilija.la@live.com>
2022-04-27 19:08:37 -04:00
Mike Salvatore 13ca4b6f8c Island: Add comment about seemingly duplicate endpoints 2022-04-27 13:19:16 -04:00
Mike Salvatore 3a5d28cc59 Island: Decouple FileUpload service from FilePond 2022-04-27 13:06:20 -04:00
Mike Salvatore 1476efa383 Island: Change unsafe -> untrusted in log message 2022-04-27 12:44:58 -04:00
Mike Salvatore 08cd631c95 Island: Make PBA_*_FILENAME_PATH tuples 2022-04-27 09:52:02 -04:00
Mike Salvatore 97300376ef
Merge pull request #1915 from guardicore/1904-service-resource-dependency-injection
1904 service resource dependency injection
2022-04-27 09:44:34 -04:00
dependabot[bot] 840f16a634 Bump twisted from 22.2.0 to 22.4.0 in /monkey/infection_monkey
Bumps [twisted](https://github.com/twisted/twisted) from 22.2.0 to 22.4.0.
- [Release notes](https://github.com/twisted/twisted/releases)
- [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst)
- [Commits](https://github.com/twisted/twisted/compare/twisted-22.2.0...twisted-22.4.0)

---
updated-dependencies:
- dependency-name: twisted
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-27 09:33:35 -04:00
Mike Salvatore 3bf0695a66 Island: Add comment/documentation about delete_file()'s idempotence 2022-04-27 09:27:54 -04:00
Mike Salvatore 1e9627470c Common: Check that injected types are subtypes of interfaces 2022-04-27 09:18:55 -04:00
Mike Salvatore 77753aca3f Island: Rename _initialize_globals() -> _initialize_di_container() 2022-04-27 09:07:27 -04:00
Mike Salvatore e8e879091d Island: Add logging to DirectoryFileStorageService 2022-04-26 19:54:12 -04:00
Mike Salvatore 4ddcd5e9a8 Island: Raise FileRetrievalError in DirectoryFileStorageService 2022-04-26 19:49:57 -04:00
Mike Salvatore a0b4dc1bcb Island: Ignore exception in delete_file() if file not found 2022-04-26 19:36:50 -04:00
Mike Salvatore 8f7215034d Island: Add paranoid check to avoid directory traversal attacks 2022-04-26 19:26:27 -04:00
Mike Salvatore 92349d8f8e UT: Remove collection warnings for TestClass{4,5} 2022-04-26 19:21:02 -04:00
Mike Salvatore 54d34d1816 Island: Rename FlaskResourceManager -> FlaskDIWrapper 2022-04-26 19:19:24 -04:00
Mike Salvatore 98033c96c0 UT: Remove unnecessary monkeypatch fixtures from test_pba_file_upload.py 2022-04-26 13:50:22 -04:00
Mike Salvatore fefdd9f024 UT: Remove mocking of private method in test_pba_file_upload.py 2022-04-26 13:49:17 -04:00
Mike Salvatore 55c4f68902 Island: Rename file_type -> target_os in FileUpload resource 2022-04-26 13:41:16 -04:00
Mike Salvatore 1d938e58f8 Island: Prefix private functions with "_" in FileUpload resource 2022-04-26 13:39:21 -04:00
Mike Salvatore e296cd5225 UT: Refactor PBA resource upload/download tests to use DI 2022-04-26 12:58:22 -04:00
Ilija Lazoroski 30e27b4e9a Zoo: Add timeout to zerologon bb test
* Fix log message in smb tools
2022-04-26 11:40:48 -04:00
Mike Salvatore d084b00367 Island: Use DIContainer to construct custom PBA resources 2022-04-26 02:36:17 -04:00
Mike Salvatore 8c3477a000 Common: Raise TypeError if DIContainer.register() called with instance 2022-04-26 02:35:00 -04:00
Mike Salvatore 9b52f3f21b Island: Add missing type hint to LocalMonkeyRunService constructor 2022-04-26 02:19:55 -04:00
Mike Salvatore 3d931b11f9 Island: Fix incorrect type hint in AuthenticationService 2022-04-26 02:18:43 -04:00
Mike Salvatore c16705241a Common: Use a more precise, custom UnregisteredTypeError in DIContainer 2022-04-26 01:42:17 -04:00
Mike Salvatore 7382407be0 Common: Add DIContainer.resolve_dependencies() 2022-04-26 01:37:41 -04:00
Mike Salvatore e78bffb414 Common: Add note about varargs and kwargs to resolve() docstring 2022-04-26 01:27:17 -04:00
Mike Salvatore 7a62434364 Common: Resolve registered instances and types directly 2022-04-26 01:21:36 -04:00
Mike Salvatore 435b619a5d Common: Add recursive resolution to DIContainer 2022-04-25 15:56:59 -04:00
Mike Salvatore 379a71d8e2 Common: Add DIContainer 2022-04-25 14:46:26 -04:00
Mike Salvatore cd8fa699b0 Common: Move get_all_regular_files_in_directory() to utils.file_utils 2022-04-25 12:32:59 -04:00
Mike Salvatore 2f4ffad3f6 Island: Skip directories in DirectoryFileStorageService.delete_all_files 2022-04-25 12:15:57 -04:00
Mike Salvatore a487aa4058 Island: Modify PostBreachFilesService to wrap IFileStorageService 2022-04-25 12:06:23 -04:00
Mike Salvatore d157bf7a40 Island: Use IFileStorageService in FileUpload resource 2022-04-25 12:06:21 -04:00
Mike Salvatore d1e18e9dbd Island: Use IFileStorageService in PBAFileDownload resource 2022-04-25 10:57:17 -04:00
Mike Salvatore c03a5aac4b Island: Pass the data directory to init_app_resources() 2022-04-25 10:26:32 -04:00
Mike Salvatore 6cfdcaaec7 UT: Change flask_client() fixture from session- to function-scoped 2022-04-25 10:23:37 -04:00
Mike Salvatore 88df935c77 Island: Add DirectoryFileStorageService 2022-04-25 09:39:16 -04:00
Mike Salvatore 80a305ea81 Island: Add IFileStorageService 2022-04-25 09:39:16 -04:00
Mike Salvatore 3c1e25b88c UT: Move Linux directory permissions check to a utility function 2022-04-25 09:39:16 -04:00
VakarisZ b9efc2d552
Merge pull request #1909 from guardicore/957-island-reset-improvements
957 island reset improvements
2022-04-22 10:48:28 +03:00
vakarisz 193bcdbf58 UI: Change the contents of running monkeys warning on reset modal
This change makes the warning more actionable
2022-04-22 10:45:03 +03:00
Mike Salvatore 2ba94fde7d Island: Remove disused remote_port_check service 2022-04-21 14:24:34 -04:00
Ilija Lazoroski 53b405a115 Island: Fix automatic jumping in telemetry feed
Fixes #1850
2022-04-21 13:42:08 -04:00
Mike Salvatore a6603c64d6 UT: Add test_all_keys_if_credentials_empty() test 2022-04-21 12:21:33 -04:00
vakarisz 75034f37f6 UI: Replace startOverPage with an improved Island reset modal
New modal allows to save clicks, explains the situation better, offers to export the config and allows deleting agent data without deleting config
2022-04-21 17:41:24 +03:00
vakarisz 551439dcc2 Island: Add endpoint to delete agent data
This endpoint allows to delete the data gathered by agents without resetting config related databases
2022-04-21 17:38:10 +03:00
vakarisz fb2f85ba24 Island: Add collection name properties to config and mode models
Collection name properties are useful for queries related to these specific collections
2022-04-21 17:36:41 +03:00
Shreya Malviya e06e855a48 Island: Check if machine responded before processing scan telemetry
Fixes part of #1850
2022-04-21 08:09:54 -04:00
Shreya Malviya bb238de037 UI: Fix current line number in telemetry overview window 2022-04-21 16:14:58 +05:30
Mike Salvatore 53d1c55bba Agent: Refactor InfectionMonkey._build_windows_delete_command()
* Replace references to "monkey" with "agent"
* Improve comments
2022-04-20 12:27:08 -04:00
Mike Salvatore 6d51f17f29 Agent: Improve whitespace and formatting in _self_delete_windows() 2022-04-20 12:27:08 -04:00
Ilija Lazoroski 838848bc3a Agent: Move delay delete commands to monkey.py 2022-04-20 12:27:08 -04:00
Mike Salvatore c2e01eaea7 Agent: Refactor InfectionMonkey._self_delete() 2022-04-20 12:27:08 -04:00
Ilija Lazoroski f2527b4d89 Agent: Change windows removal command 2022-04-20 12:26:48 -04:00
Mike Salvatore 4f5711b2ba Agent: Fix USERNAME_PREFIX imports 2022-04-20 11:46:50 -04:00
vakarisz a335f30c68 Agent: Move username const to model
This const is used by PBA and mimikatz collectors as describes the username prefix for users created by IM
2022-04-20 17:10:59 +03:00
Shreya Malviya 3561573a6b Agent: Check username of Mimikatz gathered creds
before adding to the config since we don't want to add users created by the Monkey
2022-04-20 18:18:23 +05:30
Shreya Malviya 2bcdb72555 Agent: Extract const USERNAME_PREFIX to a common file 2022-04-20 17:41:57 +05:30
Shreya Malviya e91087f9fe UI: Fix padding for telemetry overview line counter 2022-04-20 07:29:43 -04:00
Ilija Lazoroski d69ce734f1 Island: Fix immediate threats indentation 2022-04-20 12:36:58 +03:00
dependabot[bot] f49b46af7e Bump async from 2.6.3 to 2.6.4 in /monkey/monkey_island/cc/ui
Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-20 12:36:04 +03:00
Ilija Lazoroski adea9cc2a7 Common: Fix error logging for wait_commands
* Add Timer TODO
2022-04-19 14:00:14 +02:00
Mike Salvatore 587331dbdb
Merge pull request #1893 from guardicore/1888-rename-monkey-endpoint
1888 rename monkey endpoint
2022-04-19 07:37:31 -04:00
vakarisz 9f7f3c2498 UI: Rename "StartOverModal" to "ResetIslandModal" 2022-04-19 13:14:18 +03:00
vakarisz 91059a57ba UI: Rename "Start over" to "Reset" 2022-04-19 12:58:25 +03:00
Ilija Lazoroski ab24bf0d72 Island: Remove bitness functionality from RemoteRunAws service 2022-04-19 11:27:20 +02:00
Shreya Malviya 704cc8cca3 Agent: Remove kerberos cred type from pypykatz handler 2022-04-19 12:03:58 +03:00
Mike Salvatore 825fe33885
Merge pull request #1895 from guardicore/1889-remove-client-monkey-endpoint
Remove "/api/client-monkey" endpoint
2022-04-18 10:23:09 -04:00
Shreya Malviya 7b53008ce8 UI: Add logs' download buttons to Island node in the map
Fixes #1894
2022-04-18 10:22:16 -04:00
Ilija Lazoroski 9d22185064 Island: Remove "/api/client-monkey" endpoint 2022-04-18 14:48:53 +02:00
Ilija Lazoroski 3597e08628 Agent: Rename api/monkey endpoint to api/agent 2022-04-18 13:53:15 +02:00
Ilija Lazoroski c0da5b7103 Island: Rename api/monkey endpoint to api/agent 2022-04-18 13:53:15 +02:00
Mike Salvatore e9895a04f5
Merge pull request #1892 from guardicore/1888-fix-endpoint-urls
Fix endpoints urls
2022-04-15 09:55:26 -04:00
Mike Salvatore 65e28e987b Agent: Use MEDIUM_REQUEST_TIMEOUT for contacting the island
This will drop something like 30 seconds off of our tunneling test.
Generally speaking, 5 seconds seems like enough time for a simple HTTP
request to make a round trip within a local network. If we see issues in
practice, we can make this value configurable at runtime.
2022-04-15 09:48:48 -04:00
Mike Salvatore cbcb0dd1c1 Agent: Increase exploit threads from 4 to 6 2022-04-15 09:48:47 -04:00
Ilija Lazoroski 52ee31e326 Agent: Rename api/monkey_control to api/monkey-control 2022-04-15 13:17:26 +02:00
Ilija Lazoroski d2cc056a55 Island, BB: Rename api/monkey_control to api/monkey-control 2022-04-15 13:16:56 +02:00
Ilija Lazoroski 09c944d52b Island: Rename netmap/nodeStates to netmap/node-states 2022-04-15 12:45:47 +02:00
Ilija Lazoroski 1535832279 Island, BB: Rename clear_caches endpoint to clear-caches 2022-04-15 12:36:12 +02:00
Ilija Lazoroski 64fc9f2269 Island: Rename fileUpload endpoint to file-upload 2022-04-15 12:24:04 +02:00
Mike Salvatore d971627be7 UT: Update custom pbas options in automated_master_config.json 2022-04-14 13:58:44 -04:00
Mike Salvatore 16e887a94a Merge pull request #1887 from guardicore/agent-refactor 2022-04-14 12:20:43 -04:00
vakarisz c25dbba558 BB: Add missing tqdm package 2022-04-13 16:37:13 +03:00
Ilija Lazoroski b6bc631d23 UI: Remove caching from webpack
Every build needs to start on clean on production.
2022-04-12 17:25:04 +02:00
Ilija Lazoroski 5bed5b7d7c UI: Update the loaders to the latest version 2022-04-12 17:25:04 +02:00
Ilija Lazoroski fd2dc2245c UI: Use eval-source-map instead of eval devtool 2022-04-12 17:25:04 +02:00
Ilija Lazoroski 00dc772953 UI: Use thread-loader and caching to improve build time
* source-map `devtool` is decided based on prod/development
 on production we are using `source-map`, otherwise `eval`
* babel-loader uses CacheDirectory to store compiled version
* exclude node_modules from type script checker
* use fork-ts-checker-webpack-plugin for ts-loader
* use speed-measure-webpack-plugin to measure time loading od dev
2022-04-12 17:25:04 +02:00
Mike Salvatore 13b7e470db Agent: Set timeout to None for custom PBA 2022-04-11 06:36:27 -04:00
Mike Salvatore b99178832a Common: Remove disused T1216_PBA_FILE_DOWNLOAD_PATH constant 2022-04-11 06:36:27 -04:00
Mike Salvatore b1c125f420 Island: Remove disused T1216 file download endpoint 2022-04-11 06:36:25 -04:00
Mike Salvatore e849a7599a Agent: Remove T1216_random_executable.exe from agent binary on Linux
The signed-script proxy PBA only runs on Windows, so there's no need to
include the 1.1MB executable in the Linux agent.
2022-04-11 06:35:56 -04:00
Mike Salvatore ad0cb20e35 Agent: Package T1216_random_executable.exe with the agent
Packaging the T1216_random_executable.exe binary with the agent removes
coupling between the island's API and a specific post-breach action.
2022-04-11 06:35:56 -04:00
Ilija Lazoroski a0993cdfcb Agent, UT: Remove WebLogic exploiter 2022-04-11 11:58:24 +02:00
Ilija Lazoroski c10b5c9e79 Island: Remove WebLogic exploiter 2022-04-11 11:58:24 +02:00
Ilija Lazoroski 59aec706b2 UI: Add output to the wget manual run command 2022-04-10 09:47:05 -04:00
Mike Salvatore 1f5bb7efaf Merge pull request #1876 from guardicore/1869-remove-drupal
Remove Drupal exploiter
2022-04-10 09:45:24 -04:00
Mike Salvatore 727f19ecf6
Merge pull request #1873 from guardicore/1869-remove-struts2-exploit
Remove Struts2 exploiter
2022-04-10 09:39:37 -04:00
VakarisZ f9a6d13f3a
Merge pull request #1859 from guardicore/1826-catch-exceptions-todos
Resolve catching exceptions TODOs
2022-04-08 13:40:31 +03:00
Ilija Lazoroski 9d09117e7b Agent, UT: Remove Struts2 exploiter 2022-04-08 12:18:16 +02:00
Ilija Lazoroski 84ab94acc1 Island: Remove Struts2 exploiter 2022-04-08 12:17:26 +02:00
vakarisz e1b52428d1 UT: Add some tests for exception handling 2022-04-08 12:00:06 +03:00
Shreya Malviya 909ac6d9c6 UT: Remove Drupal exploiter references 2022-04-08 13:47:25 +05:30
Shreya Malviya ffbf0f440e UI: Remove Drupal exploiter references 2022-04-08 13:43:27 +05:30
Shreya Malviya 7eddee251e Island: Remove Drupal exploiter references 2022-04-08 13:43:21 +05:30
Shreya Malviya 6052ca8fcc Agent: Remove DrupalExploiter and related code 2022-04-08 13:41:23 +05:30