Skip to content

Commit 01be51b

Browse files
authored
Merge pull request #7 from p0dalirius/Fix-kerberos-authentication-using-IP-instead-of-FQDN
[bugfix] Fixed kerberos authentication, fixes #6
2 parents 3617c19 + c5b9be4 commit 01be51b

File tree

6 files changed

+49
-14
lines changed

6 files changed

+49
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "sharehound"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
description = "A Python script to generate a bloodhound opengraph of the rights of shares on a remote Windows machine."
55
readme = "README.md"
66
requires-python = ">=3.11"

setup.py

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

1515
setuptools.setup(
1616
name="sharehound",
17-
version="1.0.1" ,
17+
version="1.0.2" ,
1818
description="A Python script to generate a bloodhound opengraph of the rights of shares on a remote Windows machine.",
1919
url="https://github.com/p0dalirius/ShareHound",
2020
author="Podalirius",

sharehound/__main__.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,27 @@ def parseArgs():
252252
type=str,
253253
help="LM:NT hashes to pass the hash for this user.",
254254
)
255+
group_targets_source.add_argument(
256+
"-ak",
257+
"--auth-key",
258+
default=None,
259+
type=str,
260+
help="Kerberos key to use for authentication.",
261+
)
262+
group_targets_source.add_argument(
263+
"-k",
264+
"--use-kerberos",
265+
default=False,
266+
action="store_true",
267+
help="Use Kerberos for authentication (default: False)",
268+
)
269+
group_targets_source.add_argument(
270+
"-kh",
271+
"--kdc-host",
272+
default=None,
273+
type=str,
274+
help="KDC host to use for Kerberos authentication (default: None)",
275+
)
255276
group_targets_source.add_argument(
256277
"--ldaps", default=False, action="store_true", help="Use LDAPS (default: False)"
257278
)
@@ -289,7 +310,7 @@ def parseArgs():
289310
):
290311
parser.print_help()
291312
print(
292-
"\n[!] Option --auth-dc-ip is required when using --auth-user, --auth-password, --auth-hashes, --auth-domain"
313+
"\n[!] Option --auth-dc-ip is required when using --auth-domain/--auth-user/--auth-password/--auth-hashes/--auth-key/--use-kerberos/"
293314
)
294315
sys.exit(0)
295316

sharehound/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# Author : Remi Gascou (@podalirius_)
55
# Date created : 12 Aug 2025
66

7-
__version__ = "1.0.1"
7+
__version__ = "1.0.2"

sharehound/core/SMBSession.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class SMBSession(object):
7373
config: Config
7474
logger: Logger
7575
host: str
76+
remote_name: str
7677
port: int
7778
timeout: int
7879
advertisedName: Optional[str]
@@ -97,6 +98,7 @@ def __init__(
9798
port,
9899
timeout,
99100
credentials,
101+
remote_name=None,
100102
advertisedName=None,
101103
config=None,
102104
logger=None,
@@ -108,6 +110,7 @@ def __init__(
108110

109111
# Target server
110112
self.host = host
113+
self.remote_name = remote_name or host
111114
# Target port (by default on 445)
112115
self.port = port
113116
# Timeout (default 3 seconds)
@@ -165,7 +168,7 @@ def init_smb_session(self) -> bool:
165168
result, error = is_port_open(self.host, self.port, self.timeout)
166169
if result:
167170
self.smbClient = SMBConnection(
168-
remoteName=self.host,
171+
remoteName=self.remote_name,
169172
remoteHost=self.host,
170173
myName=self.advertisedName,
171174
sess_port=int(self.port),

sharehound/worker.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ def __init__(self, max_connections_per_host: int = 8):
4343
self._lock = Lock()
4444

4545
def get_connection(
46-
self, host: str, options: argparse.Namespace, config: Config, logger: Logger
46+
self,
47+
host: str,
48+
remote_name: str,
49+
options: argparse.Namespace,
50+
config: Config,
51+
logger: Logger,
4752
) -> Optional[SMBSession]:
4853
"""Get an available connection for the host, creating one if needed."""
4954
with self._lock:
@@ -58,23 +63,23 @@ def get_connection(
5863
connection.close_smb_session()
5964
except Exception:
6065
pass
61-
6266
# Create new connection
6367
credentials = Credentials(
6468
domain=options.auth_domain,
6569
username=options.auth_user,
6670
password=options.auth_password,
6771
hashes=options.auth_hashes,
68-
use_kerberos=False,
69-
aesKey=None,
70-
kdcHost=None,
72+
use_kerberos=options.use_kerberos,
73+
aesKey=options.auth_key,
74+
kdcHost=options.kdc_host,
7175
)
7276

7377
smb_session = SMBSession(
7478
host=host,
7579
port=445,
7680
timeout=10,
7781
credentials=credentials,
82+
remote_name=remote_name,
7883
advertisedName=options.advertised_name,
7984
config=config,
8085
logger=logger,
@@ -137,6 +142,7 @@ def process_share_task(
137142
share_name: str,
138143
share_data: dict,
139144
host: str,
145+
remote_name: str,
140146
options: argparse.Namespace,
141147
config: Config,
142148
graph: OpenGraph,
@@ -157,12 +163,14 @@ def process_share_task(
157163
"""
158164

159165
# Create a task-specific logger for this share
160-
task_logger = TaskLogger(base_logger=logger, task_id=f"{host}:{share_name}")
166+
task_logger = TaskLogger(base_logger=logger, task_id=f"{remote_name}:{share_name}")
161167

162168
def _process_share():
163169
with host_semaphore: # Limit concurrency per host
164170
# Get connection from pool
165-
smb_session = connection_pool.get_connection(host, options, config, logger)
171+
smb_session = connection_pool.get_connection(
172+
host, remote_name, options, config, logger
173+
)
166174
if not smb_session:
167175
task_logger.debug(f"Failed to get connection for host {host}")
168176
return (0, 1, 0, 0, 0, 0, 0, 0)
@@ -310,7 +318,9 @@ def multithreaded_share_worker(
310318

311319
try:
312320
target_type = target[0]
313-
target_ip = target[1]
321+
target_value = target[1]
322+
remote_name = target_value
323+
target_ip = target_value
314324

315325
logger = Logger(config=config, logfile=options.logfile)
316326

@@ -351,7 +361,7 @@ def multithreaded_share_worker(
351361

352362
# Get initial connection to discover shares
353363
initial_connection = connection_pool.get_connection(
354-
target_ip, options, config, logger
364+
target_ip, remote_name, options, config, logger
355365
)
356366
if not initial_connection:
357367
logger.debug("Failed to initialize SMB session")
@@ -390,6 +400,7 @@ def multithreaded_share_worker(
390400
share_name,
391401
share_data,
392402
target_ip,
403+
remote_name,
393404
options,
394405
config,
395406
graph,

0 commit comments

Comments
 (0)