Commit Graph

7496 Commits

Author SHA1 Message Date
Mike Salvatore 51d5176986 UT: Improve MongoNodeRepository test coverage
Setting the MagicMock members to lambda's did not work as expected. A
look at the code coverage report revealed that not all branches were
covered. Setting them to new MagicMock objects with the correct return
type added coverage to branches that were previously skipped.
2022-09-14 15:58:35 -04:00
Mike Salvatore 4f29326da9
Merge pull request #2295 from guardicore/2180-mongo-event-repository
2180 mongo event repository
2022-09-14 15:49:13 -04:00
Kekoa Kaaikala 25c3552061 UT: Clarify mongo repository reset test 2022-09-14 19:35:37 +00:00
Kekoa Kaaikala 9ec91ec97a Island: Remove unneccessary call to list() 2022-09-14 19:35:05 +00:00
Kekoa Kaaikala cd84280e79 Island: Simplify event query and deserialization 2022-09-14 19:14:35 +00:00
Kekoa Kaaikala 8311fc79a9 Island: Add message to error on save 2022-09-14 18:43:52 +00:00
Kekoa Kaaikala 5f44204583 UT: Clean up mongo fixture 2022-09-14 18:38:56 +00:00
Kekoa Kaaikala 7e96c11204 Island: Add docstring to MongoEventRepository 2022-09-14 18:35:18 +00:00
Mike Salvatore 2155e9681e UT: Double sleep time to prevent false failures 2022-09-14 14:17:19 -04:00
Mike Salvatore 5742681b13 Island: Rename agent_event_subscribers -> agent_event_handlers 2022-09-14 13:58:12 -04:00
Mike Salvatore 03c49fe4da Island: Shorten subscription code 2022-09-14 13:55:13 -04:00
Mike Salvatore b3e9bbe05f Island: Subscribe save_stolen_credentials_to_repository() 2022-09-14 13:54:38 -04:00
Mike Salvatore 4db251dd7d Island: Add save_stolen_credentials_to_repository 2022-09-14 13:52:29 -04:00
Mike Salvatore d5979fae16 Island: Fix typo and grammar in save_event_to_event_repository() 2022-09-14 13:48:55 -04:00
Kekoa Kaaikala 5c762930bf Island: Search UUID by string value 2022-09-14 17:45:44 +00:00
Kekoa Kaaikala 89954223e8 Island: Match type based on __name__ 2022-09-14 17:45:44 +00:00
Kekoa Kaaikala ad5bba9e2f Island: Use EventSerializerRegistry 2022-09-14 17:45:44 +00:00
Kekoa Kaaikala f5e398c175 Island: Add MongoEventRepository 2022-09-14 17:45:41 +00:00
Mike Salvatore 0b5dd3832b
Merge pull request #2291 from guardicore/2180-save-event-to-repository
2180 save event to repository
2022-09-14 13:40:19 -04:00
Mike Salvatore 6f4c3d4669 Island: Register StubbedEventRepository in DIContainer 2022-09-14 13:36:55 -04:00
Mike Salvatore f5711e2fab Island: Add StubbedEventRepository
A placeholder until MongoEventRepository is implemented
2022-09-14 13:35:49 -04:00
Mike Salvatore 9fc91239f2 Agent: Use private module variable for ID caching
mypy complains about setting an attribute on the function object. Using
`global _id` accomplishes the same thing and doesn't upset mypy
2022-09-14 12:59:44 -04:00
Mike Salvatore 8faf8de4dd Agent: Use HardwareID as the return type for get_machine_id() 2022-09-14 12:57:40 -04:00
Mike Salvatore f7ab5c5dd8 Common: Use MachineID instead of int in AbstractAgentEvent.target 2022-09-14 12:54:49 -04:00
Mike Salvatore 1b2b316e1f Island: Move MachineID to common 2022-09-14 12:53:42 -04:00
Mike Salvatore 99b0f5bcd6
Merge pull request #2279 from guardicore/2177-agent-all-events-subscriber
Subscriber to send all Agent events to Island
2022-09-14 12:12:26 -04:00
Mike Salvatore d179a5563f UT: Add note about potentially slow or racey tests 2022-09-14 12:11:51 -04:00
Mike Salvatore 996225deef Agent: Fix line length 2022-09-14 12:09:42 -04:00
Mike Salvatore fbd5bb9a9e Agent: Rename _agent_events_to_island_sender 2022-09-14 12:08:45 -04:00
Mike Salvatore 9471db378f UT: Reduce sleep time from 0.05 to 0.01 in test_agent_event_forwarder 2022-09-14 12:07:36 -04:00
Ilija Lazoroski 83f1e4cc2a Island: Use agent_event_handlers on island setup 2022-09-14 17:19:28 +02:00
Ilija Lazoroski 5a836daaa7 Island: Add agent_event_handlers 2022-09-14 17:18:55 +02:00
Ilija Lazoroski 26fc6fd5b9 Island: Add save_event_to_event_repository subscriber 2022-09-14 17:17:32 +02:00
vakarisz b81f7ad69c Merge branch '2216-tcp-relay' into develop 2022-09-14 17:47:13 +03:00
Shreya Malviya 218363d40e UT: Reduce sleep time from 0.1 to 0.05 in test_agent_event_forwarder.py 2022-09-14 19:59:19 +05:30
Shreya Malviya 5c1613bc79 Agent: Add log statement when sending Agent events to Island 2022-09-14 19:54:36 +05:30
Shreya Malviya 7fed97530f UT: Use BatchingAgentEventForwarder instead of AgentEventsToIslandSender 2022-09-14 19:52:33 +05:30
Shreya Malviya c24fd9ddab Agent: Rename AgentEventsToIslandSender -> BatchingAgentEventForwarder 2022-09-14 19:52:10 +05:30
Shreya Malviya 83a828ada5 UT: Rename test_send_all_events_to_island.py -> test_agent_event_forwarder.py 2022-09-14 19:51:15 +05:30
Shreya Malviya 984ce2e8bc UT: Use agent_event_forwarder instead send_all_events_to_island in import 2022-09-14 19:50:33 +05:30
Shreya Malviya 04b1caeb4c Agent: Rename send_all_events_to_island.py -> agent_event_forwarder.py 2022-09-14 19:49:35 +05:30
Shreya Malviya 0775beda7a Agent: Rename SendAllAgentEventsToIsland -> AgentEventForwarder 2022-09-14 19:47:53 +05:30
Shreya Malviya 4eabf6e77b Agent: Use create_daemon_thread() instead of threading.Thread() in AgentEventsToIslandSender 2022-09-14 19:45:12 +05:30
vakarisz f3fd2fca8b Agent: Fix SSH exploiter to be able to exploit unknown OS
Previously if the agent couldn't detect the OS, agent failed with errors
2022-09-14 17:08:52 +03:00
Ilija Lazoroski bb0910371c Island: Refactor api/events to publish list of events
PR #2285
2022-09-14 09:48:16 -04:00
Mike Salvatore 2fe3a2ece3
Merge pull request #2287 from guardicore/2180-i-event-repository
Island: Add IEventRepository
2022-09-14 09:44:17 -04:00
Mike Salvatore c977d8c212 Island: Use TypeVar for IEventRepository.get_events_by_type() 2022-09-14 09:41:58 -04:00
Mike Salvatore 4bb914316f
Merge pull request #2283 from guardicore/2255-mongo-node-repository
2255 mongo node repository
2022-09-14 09:35:16 -04:00
Mike Salvatore f52f8eccd5 UT: Use sets for simpler sequence comparison 2022-09-14 09:19:56 -04:00
Mike Salvatore 1a8c285d8e UT: Use set.intersection() for simpler set comparison 2022-09-14 09:18:00 -04:00
Mike Salvatore c2437464c6 Island: Omit the mongo object ID from Agent query results 2022-09-14 09:10:06 -04:00
Ilija Lazoroski 17e9c00180 UT: Add another test for AgentEventsToIslandSender 2022-09-14 15:09:00 +02:00
Mike Salvatore fa8736e2fe Island: Omit the mongo object ID from Machine query results 2022-09-14 09:05:42 -04:00
Mike Salvatore 3fb1ddaa74 Island: Omit the mongo object ID from Node query results 2022-09-14 09:02:21 -04:00
Mike Salvatore 5821d71ade Island: Omit the mongo object ID from credentials query results 2022-09-14 08:59:09 -04:00
Ilija Lazoroski c54d1b89ab Island: Add IEventRepository 2022-09-14 13:26:27 +02:00
Shreya Malviya 97a9f2d156 UT: Fix import in test_send_all_events_to_island.py 2022-09-14 16:14:53 +05:30
Shreya Malviya c72d34b7ad Agent: Fix import in monkey.py 2022-09-14 16:12:39 +05:30
Mike Salvatore 1affc3fe5e Common: Add "raises" docstrings to IEventSerializer.deserialize() 2022-09-14 06:33:31 -04:00
Shreya Malviya bb8b4742af Agent: Implement event serializer logic for SendAllAgentEventsToIsland 2022-09-14 16:00:56 +05:30
Shreya Malviya aeda96db06 UT: Add test for AgentEventsToIslandSender 2022-09-14 15:45:40 +05:30
Shreya Malviya 37c4362b60 Agent: Add default argument and type hint in send_all_events_to_island.py 2022-09-14 15:43:38 +05:30
Ilija Lazoroski b129833e57 Island: Remove ITelemtryRepository 2022-09-14 06:13:29 -04:00
Shreya Malviya fe63b28ee1 Agent: Restructure SendAllAgentEventsToIsland and _AgentEventsToIslandSender 2022-09-14 14:31:55 +05:30
Shreya Malviya 404f6d954f Agent: Replace SendAllAgentEventsToIsland's __call__() with send_event() 2022-09-14 13:46:45 +05:30
Shreya Malviya 8256322a29 Agent: Rename _batch_and_send_events_thread -> _BatchAndSendEventsThread 2022-09-14 13:34:34 +05:30
Shreya Malviya 1ad13db758 Agent: Rename send_all_events_to_island -> SendAllAgentEventsToIsland 2022-09-14 13:33:34 +05:30
Shreya Malviya 5152b9a3cc Agent: Use threading.Event instead of flag in send_all_events_to_island.py 2022-09-14 12:29:07 +05:30
Shreya Malviya a561195508 Agent: Use `json` instead of `data` in POST request in send_all_events_to_island.py 2022-09-14 12:14:25 +05:30
Shreya Malviya 4381716e54 Agent: Remove unused variables in send_all_events_to_island.py 2022-09-14 12:14:25 +05:30
Shreya Malviya 39a7ae0964 Agent: Rename DEFAULT_TIME_PERIOD -> DEFAULT_TIME_PERIOD_SECONDS in send_all_events_to_island.py 2022-09-14 12:14:25 +05:30
Shreya Malviya 5ecc3e992a Agent: Remove send_all_events_to_island's dependency on pubsub 2022-09-14 12:14:25 +05:30
Shreya Malviya 83c7f10859 Agent: Simplify batching and sending logic in send_all_events_to_island.py 2022-09-14 12:14:25 +05:30
Shreya Malviya 1d60cb160b Agent: Clear event batches set and use correct variable name in send_all_events_to_island.py 2022-09-14 12:14:25 +05:30
Shreya Malviya 239b2e2550 Agent: Extract API URL to variable EVENTS_API_URL in send_all_events_to_island.py 2022-09-14 12:14:25 +05:30
Shreya Malviya 39f8bafd46 Agent: Add docstrings in send_all_events_to_island.py 2022-09-14 12:14:25 +05:30
Shreya Malviya de68f21fdf Agent: Subscribe `send_all_events_to_island` to all events 2022-09-14 12:14:25 +05:30
Shreya Malviya 1abf323b14 Agent: Add type annotation for `send_all_events_to_island._batch_and_send_events_thread._event_batch` 2022-09-14 12:14:25 +05:30
Shreya Malviya 8f4aefda74 Agent: Rename some variables in `send_all_events_to_island` 2022-09-14 12:14:25 +05:30
Shreya Malviya 6520fe2c90 Agent: Rename push_events_to_island.py -> send_all_events_to_island.py for consistency 2022-09-14 12:14:25 +05:30
Shreya Malviya 9475c86fba Agent: Rename `push_all_events_to_island` -> `send_all_events_to_island` for consistency 2022-09-14 12:14:25 +05:30
Shreya Malviya 5542f67ceb Agent: Finish implementing threading/batching in `push_all_events_to_island` 2022-09-14 12:14:25 +05:30
Shreya Malviya e51a717bdf Agent: Add a very crude outline of using a queue and threading in `push_all_events_to_island` 2022-09-14 12:14:25 +05:30
Shreya Malviya a06c6a622e Agent: Add log statements in class `push_all_events_to_island`'s `__call__()` 2022-09-14 12:14:25 +05:30
Shreya Malviya 1462e832b0 Agent: Add subscriber to push all events to the Island 2022-09-14 12:14:25 +05:30
Mike Salvatore cd6a46a304 Island: Add MongoNodeRepository 2022-09-13 20:43:24 -04:00
Mike Salvatore 76b51d25b9 Island: Use frozenset instead of tuple for communication types 2022-09-13 20:42:37 -04:00
Mike Salvatore 6cc8948ebf Island: Add INodeRepository.reset() 2022-09-13 19:09:55 -04:00
Mike Salvatore ed0e8c4870 Common: Add event type to serialized agent events 2022-09-13 17:15:52 -04:00
Mike Salvatore 03989e1964 Common: Add EVENT_TYPE_FIELD 2022-09-13 17:04:44 -04:00
Mike Salvatore d30dfd3396 Agent: Setup EventSerializerRegistry 2022-09-13 15:16:27 -04:00
Mike Salvatore ca23c94c8e Island: Setup EventSerializerRegistry 2022-09-13 15:12:07 -04:00
Mike Salvatore 0f0f50208d
Agent: Add missing "param" in docstring
Co-authored-by: Kekoa Kaaikala <kekoa.kaaikala@gmail.com>
2022-09-13 15:07:25 -04:00
Mike Salvatore 5905d3bf5b Common: Add register_common_agent_event_serializers() 2022-09-13 15:04:45 -04:00
Mike Salvatore ad01003480 Common: Rename i_event_serialize{,r}.py 2022-09-13 14:58:15 -04:00
Mike Salvatore 1c742c3f96
Merge pull request #2280 from guardicore/2179-credentialsstolenevent-pydantic
2179 credentialsstolenevent pydantic
2022-09-13 14:47:10 -04:00
Mike Salvatore 1503c3f0ba Common: Switch AbstractAgentEvent.source from int to AgentID 2022-09-13 13:25:47 -04:00
Mike Salvatore 80cd5a05a1 Common: Move AgentID definition to common 2022-09-13 13:25:45 -04:00
Mike Salvatore 1998d492eb Agent: Remove disused credential_collectors.credential_components pkg 2022-09-13 13:17:02 -04:00
Mike Salvatore 04d79a0a35 Agent: Add TCPPortSelector 2022-09-13 12:24:14 -04:00
Ilija Lazoroski 31f3c1a4d6 UT: Fix all unit tests that we creating events to use pydantic 2022-09-13 17:53:58 +02:00
Ilija Lazoroski 1799f1253c Common: Make AbstractAgentEvent to be a pydantic modell
In this way we are saying that every event needs to be a pydantic model
for which we may pay the price later on.
2022-09-13 17:45:48 +02:00
Ilija Lazoroski a68a765722 Common: Make CredentialsStolenEvent to be a class 2022-09-13 17:45:48 +02:00
Kekoa Kaaikala 1a96e9fd8d Common: Make CredentialsStolenEvent a pydantic model 2022-09-13 17:45:48 +02:00
Kekoa Kaaikala 78d5094f90 Common: Use int instead of UUID in AbstractAgentEvent 2022-09-13 17:45:48 +02:00
Kekoa Kaaikala 69063de627 Agent: Add note about unintentional disconnect 2022-09-13 15:38:19 +00:00
Kekoa Kaaikala 4ba4cb583a Agent: Add thread ID to SocketsPipe thread name 2022-09-13 15:32:15 +00:00
Mike Salvatore bde44f74f5
Merge pull request #2275 from guardicore/2179-implement-pydantic-event-serializer
2179 implement pydantic event serializer
2022-09-13 09:56:57 -04:00
Mike Salvatore 69e11d6b50 Common: Ignore mypy cyclical definition warning for JSONSerializable 2022-09-13 09:22:24 -04:00
Ilija Lazoroski d3a4f255f0 Common: Use isinstance in PydanticEventSerializer 2022-09-13 14:09:54 +02:00
Mike Salvatore 6c0b63aa29 Common: Don't hide AttributeError from the caller 2022-09-13 07:55:15 -04:00
Mike Salvatore 780595cf19 Common: Use `simplify=True` in PydanticEventSerializer 2022-09-13 07:53:30 -04:00
Mike Salvatore 34e843f7f3 Common: Make PydanticEventSerializer generic 2022-09-13 07:50:38 -04:00
Ilija Lazoroski 62ab6e5a77 Common: Add generic events to PydanticEventSerializer 2022-09-13 13:38:41 +02:00
Ilija Lazoroski 9e9160304c UT: Add unit tests for PydanticEventSerializer 2022-09-13 13:38:41 +02:00
Ilija Lazoroski 1755d72ae7 Common: Export PydanticEventSerializer from __init__ 2022-09-13 13:38:33 +02:00
Ilija Lazoroski e756e0dbc3 Common: Implement EventSerializer for pydantic objects 2022-09-13 13:38:26 +02:00
Mike Salvatore d58d8bb87b Island: Remove RepositoryService
Issue #2234
2022-09-13 07:26:13 -04:00
Mike Salvatore 7c86bfc182 Island: Rename _handle_*_events() -> _subscribe_*_events() 2022-09-13 07:24:25 -04:00
Ilija Lazoroski f944347644 UT: Test ResetAgentConfiguration endpoint 2022-09-13 11:41:08 +02:00
Mike Salvatore 4e49e59447 Island: Rename local event_queue -> island_event_queue
Disambiguate Island event queues from Agent event queues
2022-09-13 11:07:35 +02:00
Mike Salvatore 6d297dc201 Island: Subscribe legacy Database.reset_db to CLEAR_SIMULATION_DATA 2022-09-13 11:07:35 +02:00
Mike Salvatore 9479b56722 Island: Subscribe ICredentialsRepository to CLEAR_SIMULATION_DATA 2022-09-13 11:07:35 +02:00
Mike Salvatore 745027bf93 Island: Wrap island event handler setup in separate function 2022-09-13 11:07:35 +02:00
Mike Salvatore 7f29e0342d Island: Use interface instead of concrete in island_event_handlers 2022-09-13 11:07:35 +02:00
Mike Salvatore ba724db969 Island: Publish IslandEventTopic.CLEAR_SIMULATION_DATA from resource 2022-09-13 11:07:35 +02:00
Mike Salvatore 2c750acc7a Island: Return 204 No Content from ClearSimulationData POST 2022-09-13 11:07:35 +02:00
ilija-lazoroski e0fb651c69
Merge pull request #2276 from guardicore/2234-refactor-reset-agent-config
2234 refactor reset agent config
2022-09-13 10:55:47 +02:00
Ilija Lazoroski afa6c6b159 Island: Rename event_queue to island_event_queue 2022-09-13 10:44:52 +02:00
Ilija Lazoroski 2bfb85a652 UT: Add typehints to test_reset_agent_configuration 2022-09-13 09:33:48 +02:00
Ilija Lazoroski 599c753cf7 Island: Add docstrings to reset_agent_configuration event handler 2022-09-13 09:31:38 +02:00
Mike Salvatore 70978f9b30 Merge branch '2216-find-servers-concurrently' into 2216-fix-connection-issues 2022-09-12 16:49:07 -04:00
Kekoa Kaaikala 3dd2052dc5 Agent: Add debug logging to TCPRelay 2022-09-12 20:45:37 +00:00
Mike Salvatore c532cdec72 Agent: Detect closed socket in SocketsPipe
When a socket is closed, select.select() returns the socket in the
read_list. A closed socket can be detected by attempting to read from
it. If 0 data is read, then the socket is closed.

See below for more details:
> If a socket is in the output readable list, you can be
  as-close-to-certain-as-we-ever-get-in-this-business that a recv on
  that socket will return something.
https://docs.python.org/3/howto/sockets.html#non-blocking-sockets
https://stackoverflow.com/questions/17386487/python-detect-when-a-socket-disconnects-for-any-reason
https://stackoverflow.com/questions/17705239/is-there-a-way-to-detect-that-tcp-socket-has-been-closed-by-the-remote-peer-wit
2022-09-12 16:35:36 -04:00
Mike Salvatore fe954bb659 Agent: Call pipe.start(), not run()
run() blocks, start() starts the run method on a different thread.
2022-09-12 16:31:03 -04:00
Mike Salvatore 9002c47d56 Agent: Add a timeout on TCPPipeSpawner dest socket 2022-09-12 16:29:19 -04:00
Mike Salvatore 77c97062eb Agent: Wrap relay stop logic in a method 2022-09-12 14:53:19 -04:00
Mike Salvatore 27cb2009fc Agent: Let relay run indefinitely if user hasn't forced a stop 2022-09-12 14:46:42 -04:00
Mike Salvatore ea47fc326a Island: Remove extra newline from server_setup.py 2022-09-12 14:15:08 -04:00
Mike Salvatore 0e112cc31a Island: Wire up event handlers before starting the island server
_start_island_server() blocks, so event handlers need to be
wired/subscribed before the server starts.
2022-09-12 14:12:30 -04:00
Mike Salvatore ecab1be70e Island: Change IslandEventTopic definition from dynamic to static
My code completion tool doesn't play well with dynamically defined
Enums.
2022-09-12 13:35:47 -04:00
Mike Salvatore 8b49554cb5 Island: Add island_event_handlers package 2022-09-12 12:00:05 -04:00
Mike Salvatore 3e67f5696c Island: Move setup_island_event_handlers to monkey_island.cc.setup 2022-09-12 11:56:34 -04:00
Mike Salvatore ad3dd6ba36 Island: Move network_utils from services/ -> server_utils/ 2022-09-12 11:52:53 -04:00
Mike Salvatore 285e6aaa35 Island: Remove disused local_ips() functions 2022-09-12 11:48:36 -04:00
Mike Salvatore 4bc9f735be Island: Rename setup_island_event_{subscribers,handlers} 2022-09-12 11:25:58 -04:00
Mike Salvatore fd7a00a225 Island: Rename subscribe_to_topics() -> setup_island_event_subscribers() 2022-09-12 11:20:17 -04:00
vakaris_zilius c2c2993ff7 Agent: Fix a bug(peeking socket consumes data)
sock.recv takes two parameters instead of one
2022-09-12 15:01:21 +00:00
Mike Salvatore a01785838d Agent: Pass keep_tunnel_open timeout as new_client_timeout 2022-09-12 10:24:26 -04:00
Mike Salvatore 67893b7825 Agent: Find/check island servers concurrently 2022-09-12 10:16:54 -04:00
Mike Salvatore a9edbb2874 Agent: Add ThreadSafeIterator 2022-09-12 10:16:51 -04:00
Ilija Lazoroski 0ca13eb93d Island: Add subscribe_to_topics on server setup 2022-09-12 15:59:58 +02:00
Ilija Lazoroski b834bfe7f7 Island: Publish RESET_AGENT_CONFIGURATION from endpoint 2022-09-12 15:22:09 +02:00
Mike Salvatore 191ee1a5f9 Agent: Change order of spawn pipe and add relay user
If we were unsuccessful in starting the pipe, we don't want to sit
around and wait for a relay user to connect.
2022-09-12 08:12:17 -04:00
vakarisz 7ff61423dc Agent: Log uncaught errors in tcp_connection_handler.py thread
If there's an uncaught error in the thread, the error won't propagate to the caller and we wouldn't know what went wrong from the logs. This fixes things and all uncaught errors get logged
2022-09-12 12:02:34 +00:00
Kekoa Kaaikala 9ff92d2128 Agent: Fix ident not available in constructor 2022-09-12 11:59:22 +00:00
Kekoa Kaaikala 756bfe488b Agent: Provide address as string to connect() 2022-09-12 11:59:22 +00:00
Ilija Lazoroski f9b1c5ebd2 Island: Export reset_agent_configuration from __init__ 2022-09-12 13:21:52 +02:00
Ilija Lazoroski e50b034324 Island: Create callable reset_agent_configuration class 2022-09-12 13:21:44 +02:00
Mike Salvatore bc769ee6b8 Common: Define del_key() in terms of MutableMapping.pop() 2022-09-11 22:59:58 -04:00
vakarisz 46152c0cd2 Island, Agent: Update pydantic to 1.10
Without this update SecretStr is of an unhashable type
2022-09-09 17:04:47 +03:00
Ilija Lazoroski a4b6e2157b Agent: Cast cmd_island_port to int 2022-09-09 14:28:14 +02:00
Ilija Lazoroski 2b4b462c1a Agent: Relock Pipfile 2022-09-09 08:23:00 -04:00
Ilija Lazoroski 867a3a83e7 Agent: Use get_plaintext in SSHExploiter login with password 2022-09-09 08:22:56 -04:00
Ilija Lazoroski 6171b66282 Agent: Fix SSHCollector to publish list of Credentials
Previously it was publish list of lists of Credentials
2022-09-09 08:22:53 -04:00
Kekoa Kaaikala 093e2c79dc Agent: Add relay to servers list for exploited hosts 2022-09-09 08:19:56 -04:00
Mike Salvatore 20649b5e3c Merge pull request #2263 from guardicore/2216-remove-unused-code
2216 remove unused code
2022-09-09 08:19:56 -04:00
Mike Salvatore 0246f6b981 Agent: Convert _cmd_island_port to int in one place 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala 4a2297b097 Island: Remove TunnelTelem 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala 3516fa1fec Agent: Fix: Pass port as int 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala cb45cd8873 Agent: Remove TunnelTelem 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala d335c4081a Agent: Fix TCPRelay missing _interrupted member 2022-09-09 08:19:56 -04:00
Shreya Malviya 7530a89152 Agent: Remove usage of proxies 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala 6051cfa29a Agent: Fix log call exhausting iterator 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala 1c805184fe Agent: Remove unused proxy classes 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala d7cabc2f5e Agent: Get rid of default_tunnel 2022-09-09 08:19:56 -04:00
Mike Salvatore 1d58ce36e7 Agent: Use a finally clause to ensure singleton is always unlocked 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala dcb77d6285 Agent: Remove MonkeyTunnel 2022-09-09 08:19:56 -04:00
Kekoa Kaaikala 6c2cab9950 Agent: Disconnect from upstream relay 2022-09-09 08:19:41 -04:00
Kekoa Kaaikala baeb0c9460 Agent: Add function to disconnect from relay 2022-09-09 08:18:17 -04:00
Mike Salvatore 5366bba389 Merge branch '2216-modify-controlclient-find-server' into 2216-tcp-relay
PR #2250
2022-09-09 08:18:14 -04:00
Mike Salvatore f3ff4176b2 Merge pull request #2251 from guardicore/2216-use-tcprelay-in-agent
2216 use tcprelay in agent
2022-09-09 08:13:02 -04:00
Shreya Malviya e1759a7906 UT: Simplify parametrize logic in test_find_server() 2022-09-09 08:13:02 -04:00
Mike Salvatore 9f5aa5a055 Agent: Drop DEFAULT_DISCONNECT_TIMEOUT to 2 minutes
Agents should be sending data back to the island very frequently. 2
minutes should be plenty.

Consider adding a heartbeat and reducing this timeout further.
2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 0398b31ece Agent: Use set in get_free_tcp_port() 2022-09-09 08:13:02 -04:00
Shreya Malviya fac179bbda UT: Simplify test logic in test_find_server() 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 33da121465 Agent: Use 'relay_port' for relay local port 2022-09-09 08:13:02 -04:00
Shreya Malviya 45d1cc78c1 UT: Use requests_mock in test_find_server 2022-09-09 08:13:02 -04:00
Mike Salvatore 5a83401a02 Agent: Add RelayUserHandler._remove_expired_users() 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala b74c42ff07 Agent: Add join timeout for the relay thread 2022-09-09 08:13:02 -04:00
Shreya Malviya 451d2d0694 UT: Use RELAY_CONTROL_MESSAGE_REMOVE_FROM_WAITLIST in place of RELAY_CONTROL_MESSAGE 2022-09-09 08:13:02 -04:00
Mike Salvatore e2736a9273 Agent: Lock RelayUserHandler.has_*_users() 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 33aac19831 Agent: Try well-known ports before other ports 2022-09-09 08:13:02 -04:00
Shreya Malviya aa1c31efb2 Agent: Rename RELAY_CONTROL_MESSAGE -> RELAY_CONTROL_MESSAGE_REMOVE_FROM_WAITLIST 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 90dcb0a91e Agent: Wait for relay users to disconnect 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 4c795343d0 Agent: Fix maximum_depth_reached() 2022-09-09 08:13:02 -04:00
Shreya Malviya cb4af415c1 Agent: Rename _open_socket_to_server -> _send_remove_from_waitlist_control_message_to_relay 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 526139bef1 Agent: Remove connect() 2022-09-09 08:13:02 -04:00
Shreya Malviya 7661027c6c Agent: Don't catch TimeoutError in _open_socket_to_server() since OSError is already being caught 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 28f555498f Agent: No need to check relay existence 2022-09-09 08:13:02 -04:00
Shreya Malviya 6bfe6bc79d Common: Rename SendControlRelayMessageThread -> SendRemoveFromWaitlistControlMessageToRelaysThread 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala aac0bfe90b Agent: Use addres_to_ip_port in connect() 2022-09-09 08:13:02 -04:00
Shreya Malviya 78d32053a2 Agent: Rename send_relay_control_message -> send_remove_from_waitlist_control_message_to_relays 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala f212425842 Agent: Pass server list to connect() 2022-09-09 08:13:02 -04:00
Shreya Malviya f436bf7b8c Agent: Remove irrelevant comment from InfectionMonkey._get_server() 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala bbdc378a0d Agent: Hand TCPRelay build it's own dependencies 2022-09-09 08:13:02 -04:00
Shreya Malviya fb1554840a Agent: Fix log message in InfectionMonkey._get_server() 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 5c7c54e450 Agent: Use timeout in build_tcprelay_deps() 2022-09-09 08:13:02 -04:00
Ilija Lazoroski 6ee15e22b8 Agent: Rework call of find_server in monkey.py 2022-09-09 08:13:02 -04:00
Ilija Lazoroski b89ba06fd1 UT: Rename test_find_server__no_available_relays to test_find_server 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala 2fd99318ba Agent: Replace MonkeyTunnel with TCPRelay 2022-09-09 08:13:02 -04:00
Ilija Lazoroski 20172230f1 Agent: Rework send_control_relay_message a bit 2022-09-09 08:13:02 -04:00
Kekoa Kaaikala a0f566ef49 Agent: Add network utilities for connections 2022-09-09 08:13:02 -04:00
Ilija Lazoroski 60f9aa6a4e Agent: Rework relay.utils.find_server a bit 2022-09-09 08:13:02 -04:00
Ilija Lazoroski e539495545 Agent: Find server and send control relay message to all other servers 2022-09-09 08:13:02 -04:00
Ilija Lazoroski 65226d5a9c UT: Move test_find_server under network.relay.utils 2022-09-09 08:13:02 -04:00
Ilija Lazoroski bb2b4aaf6c Agent: Separate responsibilites in network.relay.utils.find_server 2022-09-09 08:13:02 -04:00
Shreya Malviya c6c6cf1e79 Agent: Add TODO about variable naming in `InfectionMonkey` 2022-09-09 08:13:02 -04:00
Shreya Malviya 94dc8cf377 Agent: Use `find_servers` to pass valid server to `ControlClient` 2022-09-09 08:13:02 -04:00
Shreya Malviya 18659b654f Agent: Return server to connect to or None from `find_server` 2022-09-09 08:13:02 -04:00
Ilija Lazoroski 789d6b8441 Agent: Move ControlClient.find_server in network/relay/utls.py 2022-09-09 08:13:02 -04:00
Ilija Lazoroski 178b296f75 Agent: Use iterator in ControlClient.find_server 2022-09-09 08:13:02 -04:00
Ilija Lazoroski 02a919123b Agent: Remove thread join in find_server 2022-09-09 08:13:02 -04:00
Shreya Malviya cd91b3e42a UT: Rename RequestsGetArgument -> MockRequestsGetResponsePerServerArgument 2022-09-09 08:13:02 -04:00
Shreya Malviya 0239a1be6b UT: Simplify test logic in test_control_find_server__control_message_sent_to_necessary_relays 2022-09-09 08:13:02 -04:00
Shreya Malviya 47f838cf9f UT: Rename test_control_find_server_socket -> test_control_find_server__control_message_sent_to_necessary_relays 2022-09-09 08:13:02 -04:00
Shreya Malviya f847757a9a UT: Rename test_control_find_server_any_exception -> test_control_find_server__no_available_relays 2022-09-09 08:13:02 -04:00
Shreya Malviya a39917d9aa UT: Fix test_control_find_server_socket to check call parameters 2022-09-09 08:13:02 -04:00
Ilija Lazoroski 804bd4eadb Agent: Modify find_server to accept list of servers 2022-09-09 08:13:02 -04:00
Ilija Lazoroski ac058c7788 Agent: Add TODO to rework address_to_ip_port to use list of servers 2022-09-09 08:13:02 -04:00
Mike Salvatore 4bff110f35 Merge branch '2216-add-tcprelay' into tcp-relay
PR #2231
2022-09-09 08:12:50 -04:00
Ilija Lazoroski 4fca8ccf5d UT: Fix credentials passed to exploiter test 2022-09-09 08:07:24 -04:00
Ilija Lazoroski f93125f671 Agent: Pass servers when running exploits in Puppet 2022-09-09 08:07:24 -04:00
Ilija Lazoroski c51217507a Agent: Pass servers to exploit_host in ExploiterWrapper.Inner 2022-09-09 08:07:24 -04:00
Ilija Lazoroski 8fc0d52b8b Agent: Pass list of servers in HostExploiter.exploit_host 2022-09-09 08:07:24 -04:00
Ilija Lazoroski b2f0b54d37 Agent: Add list of server when propagating 2022-09-09 08:07:24 -04:00
Ilija Lazoroski f104f31dcd Agent: Pass list of servers to Exploiter.exploit_hosts 2022-09-09 08:07:24 -04:00
Ilija Lazoroski 8b2107d197 Agent: Accept list of servers in AutomatedMaster 2022-09-09 08:07:24 -04:00
Ilija Lazoroski a79b579cdc Agent: Construct AutomatedMaster with list of servers 2022-09-09 08:07:24 -04:00
Ilija Lazoroski e6b0e43580 UT: Fix Powershell unit tests to accept list of servers 2022-09-09 08:07:24 -04:00
Ilija Lazoroski 42de7140f3 Agent: Modify exploiters to use list of servers 2022-09-09 08:07:24 -04:00
Ilija Lazoroski 95ea5e481e Agent: Accept list of servers in HostExploiter 2022-09-09 08:07:24 -04:00
Ilija Lazoroski e4d49f5a12 Agent: Add servers list to ExploiterWrapper 2022-09-09 08:07:24 -04:00
Ilija Lazoroski 067d50f3c4 Agent: Modify agent build command line to accept list of servers 2022-09-09 08:07:24 -04:00
Ilija Lazoroski ddc4f4d836 Agent: Remove tunnel from aget build command functions 2022-09-09 08:07:24 -04:00
Ilija Lazoroski 4ad2c35c94 UT: Remove tunnel from build_monkey_commandline 2022-09-09 08:07:24 -04:00
Ilija Lazoroski e842c45e42 Agent: Add list of servers to dropper 2022-09-09 08:07:24 -04:00
Ilija Lazoroski 33f20c7da0 Agent: Remove tunnel argument from dropper 2022-09-09 08:07:24 -04:00
Mike Salvatore 1776b3b0b7 Agent: Modify exception message when server connection fails 2022-09-09 08:07:24 -04:00
Ilija Lazoroski ba187ed830 Agent: Modify command line arguments to accept list of servers
Removes tunnel argument
2022-09-09 08:07:24 -04:00