Skip to content

Commit 8a5e9c8

Browse files
committed
Merge branch '3411-cryptominer-skeleton' into develop
Issue #3411 PR #3555
2 parents e1dabb5 + 221d312 commit 8a5e9c8

File tree

6 files changed

+191
-0
lines changed

6 files changed

+191
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
psutil = "*"
8+
9+
[dev-packages]
10+
11+
[requires]
12+
python_version = "3.11"

monkey/agent_plugins/payloads/cryptojacker/Pipfile.lock

+41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"properties": {
3+
"duration": {
4+
"title": "Duration",
5+
"type": "number",
6+
"description": "The duration (in seconds) for which the cryptojacking simulation should run on each machine",
7+
"default": 300,
8+
"minimum": 0
9+
},
10+
"cpu_utilization": {
11+
"title": "CPU utilization",
12+
"type": "integer",
13+
"description": "The percentage of CPU to use on a machine",
14+
"default": 80,
15+
"minimum": 0,
16+
"maximum": 100
17+
},
18+
"memory_utilization": {
19+
"title": "Memory utilization",
20+
"type": "integer",
21+
"description": "The percentage of memory to use on a machine",
22+
"default": 20,
23+
"minimum": 0,
24+
"maximum": 100
25+
},
26+
"simulate_bitcoin_mining_network_traffic": {
27+
"title": "Simulate Bitcoin mining network traffic",
28+
"type": "boolean",
29+
"description": "If enabled, the Agent will periodically send requests used in Bitcoin mining over the network.",
30+
"default": false
31+
}
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Cryptojacker
2+
plugin_type: Payload
3+
supported_operating_systems:
4+
- linux
5+
- windows
6+
target_operating_systems:
7+
- linux
8+
- windows
9+
title: Cryptojacker
10+
version: 1.0.0
11+
description: >-
12+
Simulates a cryptojacker running on your network using a set of configurable behaviors.
13+
14+
To simulate cryptojacking, you'll need to configure a time limit for the simulation,
15+
and how much CPU and memory to utilize on each infected machine. You can also instruct
16+
the Agent to send a request over the network with data that is commonly identified by
17+
security solutions as cryptomining activity.
18+
safe: true
19+
link_to_documentation: https://techdocs.akamai.com/infection-monkey/docs/cryptojacker
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pydantic import Field, conint
2+
3+
from common.base_models import InfectionMonkeyBaseModel
4+
5+
6+
class CryptojackerOptions(InfectionMonkeyBaseModel):
7+
duration: float = Field(
8+
title="Duration",
9+
description="The duration (in seconds) for which the cryptojacking simulation should run"
10+
" on each machine",
11+
default=300, # 5 minutes
12+
ge=0,
13+
)
14+
cpu_utilization: conint(ge=0, le=100) = Field( # type: ignore[valid-type]
15+
title="CPU utilization",
16+
description="The percentage of CPU to use on a machine",
17+
default=80,
18+
)
19+
memory_utilization: conint(ge=0, le=100) = Field( # type: ignore[valid-type]
20+
title="Memory utilization",
21+
description="The percentage of memory to use on a machine",
22+
default=20,
23+
)
24+
simulate_bitcoin_mining_network_traffic: bool = Field(
25+
title="Simulate Bitcoin mining network traffic",
26+
default=False,
27+
description="If enabled, the Agent will periodically send requests used in Bitcoin mining"
28+
" over the network.",
29+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import pytest
2+
from agent_plugins.payloads.cryptojacker.src.cryptojacker_options import CryptojackerOptions
3+
4+
CRYPTOJACKER_OPTIONS_DICT = {
5+
"duration": 100,
6+
"cpu_utilization": 50,
7+
"memory_utilization": 30,
8+
"simulate_bitcoin_mining_network_traffic": True,
9+
}
10+
11+
CRYPTOJACKER_OPTIONS_OBJECT = CryptojackerOptions(
12+
duration=100,
13+
cpu_utilization=50,
14+
memory_utilization=30,
15+
simulate_bitcoin_mining_network_traffic=True,
16+
)
17+
18+
19+
def test_cryptojacker_options__serialization():
20+
assert CRYPTOJACKER_OPTIONS_OBJECT.dict(simplify=True) == CRYPTOJACKER_OPTIONS_DICT
21+
22+
23+
def test_cryptojacker_options__full_serialization():
24+
assert (
25+
CryptojackerOptions(**CRYPTOJACKER_OPTIONS_OBJECT.dict(simplify=True))
26+
== CRYPTOJACKER_OPTIONS_OBJECT
27+
)
28+
29+
30+
def test_cryptojacker_options__deserialization():
31+
assert CryptojackerOptions(**CRYPTOJACKER_OPTIONS_DICT) == CRYPTOJACKER_OPTIONS_OBJECT
32+
33+
34+
def test_cryptojacker_options__default():
35+
cryptojacker_options = CryptojackerOptions()
36+
37+
assert cryptojacker_options.duration == 300
38+
assert cryptojacker_options.cpu_utilization == 80
39+
assert cryptojacker_options.memory_utilization == 20
40+
assert cryptojacker_options.simulate_bitcoin_mining_network_traffic is False
41+
42+
43+
def test_cryptojacker_options__invalid_duration():
44+
with pytest.raises(ValueError):
45+
CryptojackerOptions(duration=-123)
46+
47+
48+
@pytest.mark.parametrize("cpu_utilization", ["-1", "101"])
49+
def test_cryptojacker_options__invalid_cpu_utilization(cpu_utilization: int):
50+
with pytest.raises(ValueError):
51+
CryptojackerOptions(cpu_utilization=cpu_utilization)
52+
53+
54+
@pytest.mark.parametrize("memory_utilization", ["-1", "101"])
55+
def test_cryptojacker_options__invalid_memory_utilization(memory_utilization: int):
56+
with pytest.raises(ValueError):
57+
CryptojackerOptions(memory_utilization=memory_utilization)

0 commit comments

Comments
 (0)