Skip to content

Commit 5aeb633

Browse files
authored
Merge pull request #763 from BC-SECURITY/release/5.12.0
v5.12.0 into main
2 parents 54ce418 + b459a47 commit 5aeb633

File tree

7 files changed

+54
-98
lines changed

7 files changed

+54
-98
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
## [Unreleased]
1616

17+
## [5.12.0] - 2024-12-14
18+
19+
- Reduce the check-in tests that were adding an unncessary amount of time to the CI
20+
- Allow Python 3.13 to be used
21+
- Fix python install
1722
- Support Empire for system-wide deployment (@D3vil0p3r)
1823
- Paths specified in config.yaml where user does not have write permission will be fallback to ~/.empire directory and config.yaml updated as well (@D3vil0p3r)
1924
- Invoke-Obfuscation is no longer copied to /usr/local/share
@@ -948,7 +953,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
948953
- Updated shellcoderdi to newest version (@Cx01N)
949954
- Added a Nim launcher (@Hubbl3)
950955

951-
[Unreleased]: https://github.com/BC-SECURITY/Empire-Sponsors/compare/v5.11.7...HEAD
956+
[Unreleased]: https://github.com/BC-SECURITY/Empire-Sponsors/compare/v5.12.0...HEAD
957+
958+
[5.12.0]: https://github.com/BC-SECURITY/Empire-Sponsors/compare/v5.11.7...v5.12.0
952959

953960
[5.11.7]: https://github.com/BC-SECURITY/Empire-Sponsors/compare/v5.11.6...v5.11.7
954961

empire/server/common/empire.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
from . import agents, credentials, listeners, stagers
4040

41-
VERSION = "5.11.7 BC Security Fork"
41+
VERSION = "5.12.0 BC Security Fork"
4242

4343
log = logging.getLogger(__name__)
4444

empire/test/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
import os
32
import shutil
43
import sys
@@ -57,7 +56,8 @@ def client():
5756

5857
# fix for pycharm debugger
5958
# https://stackoverflow.com/a/77926544/5849681
60-
yield TestClient(app, backend_options={"loop_factory": asyncio.new_event_loop})
59+
# yield TestClient(app, backend_options={"loop_factory": asyncio.new_event_loop})
60+
yield TestClient(app)
6161

6262
from empire.server.server import main
6363

empire/test/test_agent_checkins_api.py

Lines changed: 14 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import asyncio
22
import logging
3-
import time
4-
from contextlib import contextmanager
53
from datetime import datetime, timedelta, timezone
64

75
import pytest
@@ -10,12 +8,6 @@
108
log = logging.getLogger(__name__)
119

1210

13-
@contextmanager
14-
def timer():
15-
start = time.perf_counter()
16-
yield lambda: time.perf_counter() - start
17-
18-
1911
@pytest.fixture(scope="function")
2012
def agents(session_local, host, models):
2113
agent_ids = []
@@ -67,9 +59,9 @@ async def _create_checkins(session_local, models, agent_ids):
6759
)
6860

6961

70-
agent_count = 10
71-
time_delta = 5 # 17280 checkins per agent per day
72-
days_back = 7
62+
agent_count = 2
63+
time_delta = 20 # 4320 checkins per agent per day
64+
days_back = 3
7365
end_time = datetime(2023, 1, 8, tzinfo=timezone.utc)
7466
start_time = end_time - timedelta(days=days_back)
7567

@@ -88,51 +80,6 @@ async def _create_checkin(session_local, models, agent_id):
8880
db_2.add_all(checkins)
8981

9082

91-
@pytest.mark.slow
92-
def test_database_performance_checkins(models, host, agents, session_local):
93-
# logging.basicConfig()
94-
# logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
95-
# logging.getLogger("sqlalchemy.engine").propagate = True
96-
# print(query.statement.compile(compile_kwargs={"literal_binds": True}))
97-
98-
with session_local() as db:
99-
asyncio.run(_create_checkins(session_local, models, agents))
100-
101-
with timer() as t:
102-
checkins = db.query(models.AgentCheckIn).count()
103-
assert checkins >= (agent_count * 17280 * days_back)
104-
log.info(f"Time to query {checkins} checkins count: {t():0.4f} seconds")
105-
106-
with timer() as t:
107-
agents = db.query(models.Agent).count()
108-
assert agents >= agent_count
109-
log.info(f"Time to query {agents} agents count: {t():0.4f} seconds")
110-
assert t() < 1
111-
112-
with timer() as t:
113-
query = db.query(models.Agent)
114-
query.all()
115-
log.info(f"Time to query {agents} agents: {t():0.4f} seconds")
116-
assert t() < 1
117-
118-
with timer() as t:
119-
query = db.query(models.AgentCheckIn).limit(50000)
120-
query.all()
121-
log.info(f"Time to query {checkins} checkins: {t():0.4f} seconds")
122-
assert t() < 6 # noqa: PLR2004
123-
124-
agents = db.query(models.Agent).all()
125-
126-
with timer() as t:
127-
for a in agents:
128-
name = a.name
129-
lastseen_time = a.lastseen_time
130-
stale = a.stale
131-
log.info(f"{name} - {lastseen_time} - {stale}")
132-
log.info(f"Time to query {agents} agents' dynamic fields: {t():0.4f} seconds")
133-
assert t() < 0.1 * agent_count
134-
135-
13683
def test_get_agent_checkins_agent_not_found(client, admin_auth_header):
13784
response = client.get("/api/v2/agents/XYZ123/checkins", headers=admin_auth_header)
13885

@@ -153,7 +100,7 @@ def test_get_agent_checkins_with_limit_and_page(
153100
checkin_count = 10
154101
assert response.status_code == status.HTTP_200_OK
155102
assert len(response.json()["records"]) == checkin_count
156-
assert response.json()["total"] > days_back * 17280
103+
assert response.json()["total"] > days_back * 4320
157104
assert response.json()["page"] == 1
158105

159106
page1 = response.json()["records"]
@@ -166,7 +113,7 @@ def test_get_agent_checkins_with_limit_and_page(
166113
page_count = 2
167114
assert response.status_code == status.HTTP_200_OK
168115
assert len(response.json()["records"]) == checkin_count
169-
assert response.json()["total"] > days_back * 17280
116+
assert response.json()["total"] > days_back * 4320
170117
assert response.json()["page"] == page_count
171118

172119
page2 = response.json()["records"]
@@ -178,18 +125,17 @@ def test_get_agent_checkins_with_limit_and_page(
178125
def test_get_agent_checkins_multiple_agents(
179126
client, admin_auth_header, agents, session_local, models
180127
):
181-
with_checkins = agents[:3]
182-
asyncio.run(_create_checkins(session_local, models, with_checkins))
128+
asyncio.run(_create_checkins(session_local, models, agents))
183129

184130
response = client.get(
185131
"/api/v2/agents/checkins",
186132
headers=admin_auth_header,
187-
params={"agents": with_checkins[:2], "limit": 400000},
133+
params={"agents": agents, "limit": 400000},
188134
)
189135

190136
assert response.status_code == status.HTTP_200_OK
191-
assert len(response.json()["records"]) == days_back * 17280 * 2
192-
assert {r["agent_id"] for r in response.json()["records"]} == set(with_checkins[:2])
137+
assert len(response.json()["records"]) == days_back * 4320 * agent_count
138+
assert {r["agent_id"] for r in response.json()["records"]} == set(agents)
193139

194140

195141
@pytest.mark.slow
@@ -199,7 +145,7 @@ def test_agent_checkins_aggregate(
199145
if empire_config.database.use == "sqlite":
200146
pytest.skip("sqlite not supported for checkin aggregation")
201147

202-
asyncio.run(_create_checkins(session_local, models, agents[:3]))
148+
asyncio.run(_create_checkins(session_local, models, agents))
203149

204150
response = client.get(
205151
"/api/v2/agents/checkins/aggregate",
@@ -209,7 +155,7 @@ def test_agent_checkins_aggregate(
209155
assert response.status_code == status.HTTP_200_OK
210156
assert response.elapsed.total_seconds() < 5 # noqa: PLR2004
211157
assert response.json()["bucket_size"] == "day"
212-
assert response.json()["records"][1]["count"] == 17280 * 3
158+
assert response.json()["records"][1]["count"] == 4320 * agent_count
213159

214160
response = client.get(
215161
"/api/v2/agents/checkins/aggregate",
@@ -220,7 +166,7 @@ def test_agent_checkins_aggregate(
220166
assert response.status_code == status.HTTP_200_OK
221167
assert response.elapsed.total_seconds() < 5 # noqa: PLR2004
222168
assert response.json()["bucket_size"] == "hour"
223-
assert response.json()["records"][1]["count"] == 720 * 3
169+
assert response.json()["records"][1]["count"] == 180 * agent_count
224170

225171
response = client.get(
226172
"/api/v2/agents/checkins/aggregate",
@@ -231,7 +177,7 @@ def test_agent_checkins_aggregate(
231177
assert response.status_code == status.HTTP_200_OK
232178
assert response.elapsed.total_seconds() < 5 # noqa: PLR2004
233179
assert response.json()["bucket_size"] == "minute"
234-
assert response.json()["records"][1]["count"] == 12 * 3
180+
assert response.json()["records"][1]["count"] == 3 * agent_count
235181

236182
response = client.get(
237183
"/api/v2/agents/checkins/aggregate",
@@ -246,7 +192,7 @@ def test_agent_checkins_aggregate(
246192
assert response.status_code == status.HTTP_200_OK
247193
assert response.elapsed.total_seconds() < 5 # noqa: PLR2004
248194
assert response.json()["bucket_size"] == "second"
249-
assert response.json()["records"][1]["count"] == 1 * 3
195+
assert response.json()["records"][1]["count"] == 1 * agent_count
250196

251197
# Test start date and end date
252198
response = client.get(

poetry.lock

Lines changed: 26 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "empire-bc-security-fork"
3-
version = "5.11.7"
3+
version = "5.12.0"
44
description = ""
55
authors = ["BC Security <info@bc-security.org>"]
66
readme = "README.md"
@@ -13,7 +13,7 @@ packages = [
1313
]
1414

1515
[tool.poetry.dependencies]
16-
python = ">=3.10,<3.13"
16+
python = ">=3.10,<3.14"
1717
urllib3 = "^2.2.0"
1818
requests = "^2.31.0"
1919
iptools = "^0.7.0"

setup/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ if ! command_exists pyenv; then
292292
apt-get -y install build-essential gdb lcov pkg-config \
293293
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
294294
libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
295-
lzma lzma-dev tk-dev uuid-dev zlib1g-dev
295+
lzma tk-dev uuid-dev zlib1g-dev
296296
297297
pyenv install 3.12.6
298298
fi

0 commit comments

Comments
 (0)