Skip to content

Commit 0632beb

Browse files
committed
chore: Pre-merge tasks completed
Oops, I missed the import for PlatformError :p
1 parent 1f6c820 commit 0632beb

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

docs/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#
1313
import os
1414
import sys
15-
sys.path.insert(0, os.path.abspath('../..'))
15+
16+
sys.path.insert(0, os.path.abspath("../.."))
1617

1718

1819
# -- Project information -----------------------------------------------------

pwncat/commands/upload.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pwncat
1515
from pwncat.util import console, copyfileobj, human_readable_size, human_readable_delta
1616
from pwncat.commands import Complete, Parameter, CommandDefinition
17+
from pwncat.platform import PlatformError
1718

1819

1920
class Command(CommandDefinition):
@@ -77,5 +78,10 @@ def run(self, manager: "pwncat.manager.Manager", args):
7778
f"uploaded [cyan]{human_readable_size(length)}[/cyan] "
7879
f"in [green]{human_readable_delta(elapsed)}[/green]"
7980
)
80-
except (FileNotFoundError, PermissionError, IsADirectoryError, PlatformError) as exc:
81+
except (
82+
FileNotFoundError,
83+
PermissionError,
84+
IsADirectoryError,
85+
PlatformError,
86+
) as exc:
8187
self.parser.error(str(exc))

pwncat/modules/linux/implant/authorized_key.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def install(self, session: "pwncat.manager.Session", user, key):
9393
yield Status("verifying user permissions")
9494
current_user = session.current_user()
9595
if user != "__pwncat_current__" and current_user.id != 0:
96-
raise ModuleFailed("only [blue]root[/blue] can install implants for other users")
96+
raise ModuleFailed(
97+
"only [blue]root[/blue] can install implants for other users"
98+
)
9799

98100
if not os.path.isfile(key):
99101
raise ModuleFailed(f"private key [bleu]{key}[/blue] does not exist")

tests/conftest.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
from io import StringIO
99

1010
import pytest
11-
from pwncat.channel import ChannelError
1211
from Crypto.PublicKey import RSA
1312

13+
from pwncat.channel import ChannelError
14+
1415
PLATFORM_MAP = {"ubuntu": "linux", "centos": "linux", "windows": "windows"}
1516

1617

@@ -37,13 +38,13 @@ def connection_details_for(name):
3738

3839
@pytest.fixture(params=["ubuntu", "centos"])
3940
def linux_details(request):
40-
""" Get available connection details for linux hosts """
41+
"""Get available connection details for linux hosts"""
4142
return connection_details_for(request.param)
4243

4344

4445
@pytest.fixture(params=["windows"])
4546
def windows_details(request):
46-
""" Get available connection details for windows hosts """
47+
"""Get available connection details for windows hosts"""
4748
return connection_details_for(request.param)
4849

4950

@@ -84,18 +85,18 @@ def session_for(request):
8485

8586
@pytest.fixture(params=["windows", "ubuntu", "centos"])
8687
def session(request):
87-
""" Start a session with any platform """
88+
"""Start a session with any platform"""
8889
yield from session_for(request)
8990

9091

9192
@pytest.fixture(params=["windows"])
9293
def windows(request):
93-
""" Start a windows session """
94+
"""Start a windows session"""
9495
yield from session_for(request)
9596

9697

9798
@pytest.fixture(params=["ubuntu", "centos"])
9899
def linux(request):
99-
""" Start a linux session """
100+
"""Start a linux session"""
100101

101102
yield from session_for(request)

tests/test_session.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import pytest
4+
45
from pwncat.modules import IncorrectPlatformError
56

67

@@ -13,13 +14,13 @@ def test_session_iter_users(session):
1314

1415

1516
def test_session_find_user_name(session):
16-
""" Test that locating a user by name works """
17+
"""Test that locating a user by name works"""
1718

1819
assert session.find_user(name="john") is not None
1920

2021

2122
def test_session_find_user_uid(linux):
22-
""" Test locating a user by their UID (for linux only) """
23+
"""Test locating a user by their UID (for linux only)"""
2324

2425
user = linux.find_user(uid=0)
2526

@@ -28,7 +29,7 @@ def test_session_find_user_uid(linux):
2829

2930

3031
def test_session_find_user_sid(windows):
31-
""" Test locating a user by their SID (for windows only) """
32+
"""Test locating a user by their SID (for windows only)"""
3233

3334
# This is the SID of the Administrator in the windows servercore image...
3435
# This will only work from the testing container, but I've decided that's fine.
@@ -39,30 +40,30 @@ def test_session_find_user_sid(windows):
3940

4041

4142
def test_session_find_module(session):
42-
""" Test that locating modules works """
43+
"""Test that locating modules works"""
4344

4445
assert len(list(session.find_module("enumerate.*"))) > 0
4546
assert len(list(session.find_module("enumerate.user"))) == 1
4647
assert len(list(session.find_module("module_does_not_exist"))) == 0
4748

4849

4950
def test_session_run_module(session):
50-
""" Test running a module within a session """
51+
"""Test running a module within a session"""
5152

5253
# We should be able to enumerate a hostname
5354
facts = session.run("enumerate", types=["system.hostname"])
5455
assert len(facts) > 0
5556

5657

5758
def test_session_wrong_platform_linux(linux):
58-
""" Test that windows modules don't run in linux """
59+
"""Test that windows modules don't run in linux"""
5960

6061
with pytest.raises(IncorrectPlatformError):
6162
linux.run("windows.enumerate.user")
6263

6364

6465
def test_session_wrong_platform_windows(windows):
65-
""" Test that linux modules don't run on windows """
66+
"""Test that linux modules don't run on windows"""
6667

6768
with pytest.raises(IncorrectPlatformError):
6869
windows.run("linux.enumerate.user")

0 commit comments

Comments
 (0)