routersploit, python3Packages.threat9-test-bed: fixes (#499454)

This commit is contained in:
Michael Daniels
2026-03-21 02:23:07 +00:00
committed by GitHub
3 changed files with 59 additions and 18 deletions
+39 -18
View File
@@ -1,36 +1,35 @@
{
lib,
stdenv,
fetchFromGitHub,
python3,
}:
let
version = "3.4.7";
in
python3.pkgs.buildPythonApplication {
python3.pkgs.buildPythonApplication (finalAttrs: {
pname = "routersploit";
inherit version;
version = "3.4.7";
pyproject = true;
src = fetchFromGitHub {
owner = "threat9";
repo = "routersploit";
tag = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-10NBSY/mYjOWoz2XCJ1UvXUIYUW4csRJHHtDlWMO420=";
};
build-system = with python3.pkgs; [ setuptools ];
dependencies = with python3.pkgs; [
paramiko
pycryptodome
pysnmp
requests
setuptools
];
# Tests are out-dated and support for newer pysnmp is not implemented yet
doCheck = false;
dependencies =
with python3.pkgs;
[
paramiko
pycryptodome
pysnmp
requests
setuptools
]
++ lib.optionals (pythonAtLeast "3.13") [
standard-telnetlib
];
nativeCheckInputs = with python3.pkgs; [
pytest-xdist
@@ -51,9 +50,31 @@ python3.pkgs.buildPythonApplication {
"tests/test_module_info.py"
];
disabledTests = [
# AttributeError: module 'paramiko' has no attribute 'DSSKey'.
"test_exploit_empty_response"
"test_exploit_error_response"
"test_exploit_not_found_response"
"test_exploit_redirect_response"
"test_exploit_trash_response"
# Runs substantially slower, making this test flaky
"test_exploit_timeout_response"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# port conflict when running simultaneous builds
"test_http_scenario_service_empty_response"
"test_http_scenario_service_error"
"test_http_scenario_service_found"
"test_http_scenario_service_not_found"
"test_http_scenario_service_redirect"
"test_http_scenario_service_trash"
];
meta = {
description = "Exploitation Framework for Embedded Devices";
homepage = "https://github.com/threat9/routersploit";
changelog = "https://github.com/threat9/routersploit/releases/tag/${finalAttrs.src.tag}";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
fab
@@ -61,4 +82,4 @@ python3.pkgs.buildPythonApplication {
];
mainProgram = "rsf";
};
}
})
@@ -0,0 +1,18 @@
diff --git a/threat9_test_bed/telnet_service/telnet_server.py b/threat9_test_bed/telnet_service/telnet_server.py
index 7d29e8f..77f5e48 100644
--- a/threat9_test_bed/telnet_service/telnet_server.py
+++ b/threat9_test_bed/telnet_service/telnet_server.py
@@ -6,8 +6,11 @@ logger = logging.getLogger(__name__)
class TelnetServer:
def __init__(self, host: str, port: int, protocol):
- self.loop = asyncio.get_event_loop()
-
+ try:
+ self.loop = asyncio.get_running_loop()
+ except RuntimeError:
+ self.loop = asyncio.new_event_loop()
+ asyncio.set_event_loop(self.loop)
coro = self.loop.create_server(protocol, host, port)
self.server = self.loop.run_until_complete(coro)
@@ -26,6 +26,8 @@ buildPythonPackage rec {
hash = "sha256-0YSjMf2gDdrvkDaT77iwfCkiDDXKHnZyI8d7JmBSuCg=";
};
patches = [ ./asyncio-loop.patch ];
build-system = [ setuptools-scm ];
dependencies = [