From 11f09906d0da36420c7039897c848d46453988c2 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 10 Aug 2023 07:17:43 -0400 Subject: [PATCH 1/2] Cryptojacker: Fix content type of getblocktemplate request --- .../src/bitcoin_mining_network_traffic_simulator.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/monkey/agent_plugins/payloads/cryptojacker/src/bitcoin_mining_network_traffic_simulator.py b/monkey/agent_plugins/payloads/cryptojacker/src/bitcoin_mining_network_traffic_simulator.py index 26ff8edba38..1a132ca608a 100644 --- a/monkey/agent_plugins/payloads/cryptojacker/src/bitcoin_mining_network_traffic_simulator.py +++ b/monkey/agent_plugins/payloads/cryptojacker/src/bitcoin_mining_network_traffic_simulator.py @@ -1,4 +1,5 @@ import base64 +import json import logging import random import time @@ -49,7 +50,10 @@ def _build_headers(): password = "bitcoin-password" auth = base64.encodebytes((user + ":" + password).encode()).decode().strip() - return {"Authorization": f"Basic {auth}"} + return { + "Authorization": f"Basic {auth}", + "Content-Type": "application/x-www-form-urlencoded", + } def start(self): logger.info("Starting Bitcoin mining network traffic simulator") @@ -59,7 +63,9 @@ def start(self): def send_bitcoin_mining_request(self): url = f"http://{self._island_server_address}/" failure_warning_msg = f"Failed to establish a connection with {url}" - body = BitcoinMiningNetworkTrafficSimulator._build_getblocktemplate_request_body() + body = json.dumps( + BitcoinMiningNetworkTrafficSimulator._build_getblocktemplate_request_body() + ).encode() logger.info(f"Sending Bitcoin mining request to {url}") @@ -67,7 +73,7 @@ def send_bitcoin_mining_request(self): try: requests.post( url, - json=body, + data=body, headers=self._headers, timeout=MEDIUM_REQUEST_TIMEOUT, ) From e7712118e3d835d8c4872a9b9ad9dd4cc57e88db Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 10 Aug 2023 07:52:35 -0400 Subject: [PATCH 2/2] Cryptojacker: Fix Accept-Encoding header in getblocktemplate request --- .../cryptojacker/src/bitcoin_mining_network_traffic_simulator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/monkey/agent_plugins/payloads/cryptojacker/src/bitcoin_mining_network_traffic_simulator.py b/monkey/agent_plugins/payloads/cryptojacker/src/bitcoin_mining_network_traffic_simulator.py index 1a132ca608a..01d17e77744 100644 --- a/monkey/agent_plugins/payloads/cryptojacker/src/bitcoin_mining_network_traffic_simulator.py +++ b/monkey/agent_plugins/payloads/cryptojacker/src/bitcoin_mining_network_traffic_simulator.py @@ -51,6 +51,7 @@ def _build_headers(): auth = base64.encodebytes((user + ":" + password).encode()).decode().strip() return { + "Accept-Encoding": "identity", "Authorization": f"Basic {auth}", "Content-Type": "application/x-www-form-urlencoded", }