Skip to content

Commit

Permalink
smb url fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SkelSec committed Sep 9, 2022
1 parent 75a240d commit 4b09080
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions pypykatz/smb/dcsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from pypykatz import logger

async def dcsync(url, username = None):
from aiosmb.commons.connection.url import SMBConnectionURL
from aiosmb.commons.connection.factory import SMBConnectionFactory
from aiosmb.commons.interfaces.machine import SMBMachine

smburl = SMBConnectionURL(url)
smburl = SMBConnectionFactory.from_url(url)
connection = smburl.get_connection()

users = []
Expand Down
13 changes: 6 additions & 7 deletions pypykatz/smb/lsassutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def natatime(n, iterable, fillvalue = None):
from pypykatz import logger

async def lsassfile(url, packages = ['all'], chunksize = 64*1024):
from aiosmb.commons.connection.url import SMBConnectionURL
from aiosmb.commons.connection.factory import SMBConnectionFactory
from pypykatz.alsadecryptor.asbmfile import SMBFileReader
from pypykatz.apypykatz import apypykatz

smburl = SMBConnectionURL(url)
smburl = SMBConnectionFactory.from_url(url)
connection = smburl.get_connection()
smbfile = smburl.get_file()

Expand All @@ -49,9 +49,8 @@ async def lsassfile(url, packages = ['all'], chunksize = 64*1024):
logger.debug('[LSASSFILE] LSASS file parsed OK!')
return mimi

async def lsassdump(url, method = 'task', remote_base_path = 'C:\\Windows\\Temp\\', remote_share_name = '\\c$\\Windows\\Temp\\',chunksize = 64*1024, packages = ['all'], targets = [], worker_cnt = 5):
from aiosmb.commons.connection.url import SMBConnectionURL

async def lsassdump(url, method = 'task', remote_base_path = 'C:\\Windows\\Temp\\', remote_share_name = '\\c$\\Windows\\Temp\\',chunksize = 64*1024, packages = ['all'], targets = [], worker_cnt = 5):
from aiosmb.commons.connection.factory import SMBConnectionFactory
base_url = None
base_conn = None
mimis = []
Expand All @@ -72,11 +71,11 @@ async def lsassdump(url, method = 'task', remote_base_path = 'C:\\Windows\\Temp\
if len(notfile) > 0:
tgens.append(ListTargetGen(notfile))

if isinstance(url, SMBConnectionURL):
if isinstance(url, SMBConnectionFactory):
base_url = url
base_conn = url.get_connection()
else:
base_url = SMBConnectionURL(url)
base_url = SMBConnectionFactory.from_url(url)
base_conn = base_url.get_connection()

lsassdump_coro = lsassdump_single(
Expand Down
8 changes: 4 additions & 4 deletions pypykatz/smb/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

async def printnightmare(url, dll_path, driverpath = None):
try:
from aiosmb.commons.connection.url import SMBConnectionURL
from aiosmb.commons.connection.factory import SMBConnectionFactory
from aiosmb.commons.interfaces.machine import SMBMachine

smburl = SMBConnectionURL(url)
smburl = SMBConnectionFactory.from_url(url)
connection = smburl.get_connection()

async with connection:
Expand All @@ -32,10 +32,10 @@ async def printnightmare(url, dll_path, driverpath = None):

async def parprintnightmare(url, dll_path, driverpath = None):
try:
from aiosmb.commons.connection.url import SMBConnectionURL
from aiosmb.commons.connection.factory import SMBConnectionFactory
from aiosmb.commons.interfaces.machine import SMBMachine

smburl = SMBConnectionURL(url)
smburl = SMBConnectionFactory.from_url(url)
connection = smburl.get_connection()

async with connection:
Expand Down
10 changes: 5 additions & 5 deletions pypykatz/smb/regutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


async def regdump(url, hives = ['HKLM\\SAM', 'HKLM\\SYSTEM', 'HKLM\\SECURITY'], remote_base_path = 'C:\\Windows\\Temp\\', remote_share_name = '\\c$\\Windows\\Temp\\', enable_wait = 3, targets = [], worker_cnt = 5):
from aiosmb.commons.connection.url import SMBConnectionURL
from aiosmb.commons.connection.factory import SMBConnectionFactory

base_url = None
base_conn = None
Expand All @@ -29,11 +29,11 @@ async def regdump(url, hives = ['HKLM\\SAM', 'HKLM\\SYSTEM', 'HKLM\\SECURITY'],
if len(notfile) > 0:
tgens.append(ListTargetGen(notfile))

if isinstance(url, SMBConnectionURL):
if isinstance(url, SMBConnectionFactory):
base_url = url
base_conn = url.get_connection()
else:
base_url = SMBConnectionURL(url)
base_url = SMBConnectionFactory.from_url(url)
base_conn = base_url.get_connection()

regdump_coro = regdump_single(
Expand Down Expand Up @@ -173,12 +173,12 @@ async def regdump_single(targetid, connection, hives = ['HKLM\\SAM', 'HKLM\\SYST


async def regfile(url, system, sam = None, security = None, software = None, smb_basepath = None):
from aiosmb.commons.connection.url import SMBConnectionURL
from aiosmb.commons.connection.factory import SMBConnectionFactory
from aiosmb.commons.interfaces.file import SMBFile
from pypykatz.alsadecryptor.asbmfile import SMBFileReader
from pypykatz.registry.aoffline_parser import OffineRegistry

smburl = SMBConnectionURL(url)
smburl = SMBConnectionFactory.from_url(url)
connection = smburl.get_connection()

if smb_basepath is None:
Expand Down
7 changes: 0 additions & 7 deletions pypykatz/smb/shareenum.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@ async def generate(self):


async def shareenum(smb_url, ldap_url = None, targets = None, smb_worker_count = 10, depth = 3, out_file = None, progress = False, max_items = None, dirsd = False, filesd = False, authmethod = 'ntlm', protocol_version = '2', output_type = 'str', max_runtime = None, exclude_share = ['print$'], exclude_dir = [], exclude_target = []):
from aiosmb.commons.connection.url import SMBConnectionURL
from pypykatz.alsadecryptor.asbmfile import SMBFileReader
from pypykatz.apypykatz import apypykatz


#if targets is None and ldap_url is None:
# raise Exception('Shareenum needs a list of targets or LDAP connection string')

if smb_url == 'auto':
smb_url = get_smb_url(authmethod=authmethod, protocol_version=protocol_version)

Expand Down

0 comments on commit 4b09080

Please sign in to comment.