mirror of
https://github.com/cisagov/snafflepy
synced 2026-09-24 18:22:23 +00:00
file listing from shares working, enumeration of shares still WIP. added requirements.txt and enabled logging to stdout
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
# created by virtualenv automatically
|
||||
snaffcore/__pycache__/
|
||||
active_directory/
|
||||
snaffcore/active_directory/
|
||||
.idea
|
||||
.vscode
|
||||
snafflepy/
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
argcomplete==3.1.1
|
||||
blinker==1.6.2
|
||||
cffi==1.15.1
|
||||
chardet==5.1.0
|
||||
click==8.1.3
|
||||
cryptography==41.0.1
|
||||
dnspython==2.3.0
|
||||
Flask==2.3.2
|
||||
future==0.18.3
|
||||
impacket==0.10.0
|
||||
itsdangerous==2.1.2
|
||||
Jinja2==3.1.2
|
||||
ldap3==2.9.1
|
||||
ldapdomaindump==0.9.4
|
||||
MarkupSafe==2.1.3
|
||||
packaging==23.1
|
||||
pipx==1.2.0
|
||||
pyasn1==0.5.0
|
||||
pycparser==2.21
|
||||
pycryptodomex==3.18.0
|
||||
pyOpenSSL==23.2.0
|
||||
six==1.16.0
|
||||
userpath==1.8.0
|
||||
Werkzeug==2.3.6
|
||||
+2
-2
@@ -4,9 +4,9 @@ from impacket.nmb import NetBIOSError, NetBIOSTimeout
|
||||
from impacket.smb import SessionError, UnsupportedFeature
|
||||
from impacket.smbconnection import SessionError as CSessionError
|
||||
|
||||
# Stolen from https://github.com/blacklanternsecurity/MANSPIDER
|
||||
# RT: Stolen from manspider - https://github.com/blacklanternsecurity/MANSPIDER
|
||||
# set up logging
|
||||
log = logging.getLogger('snafflerpy')
|
||||
log = logging.getLogger('snafflepy')
|
||||
|
||||
|
||||
class SnafflerError(Exception):
|
||||
|
||||
+3
-2
@@ -3,12 +3,13 @@ from .utilities import *
|
||||
from .errors import *
|
||||
from pathlib import Path
|
||||
|
||||
# RT: Stolen from manspider - https://github.com/blacklanternsecurity/MANSPIDER
|
||||
|
||||
class RemoteFile():
|
||||
'''
|
||||
Represents a file on an SMB share
|
||||
Passed from a spiderling up to its parent spide
|
||||
r '''
|
||||
Passed from a spiderling up to its parent spider
|
||||
'''
|
||||
|
||||
def __init__(self, name, share, target, size=0):
|
||||
|
||||
|
||||
+19
-37
@@ -9,43 +9,25 @@ def begin_snaffle(options):
|
||||
print("Beginning the snaffle...")
|
||||
sleep(0.2)
|
||||
|
||||
# TODO: Talk to AD via LDAP to get list of computers with file shares
|
||||
|
||||
# TESTING
|
||||
if options.test:
|
||||
server = Server('testing server', get_info=ALL)
|
||||
conn = Connection(server, user='cn=user0,ou=test,o=lab', password='test0000', client_strategy=MOCK_SYNC)
|
||||
# Login via SMB
|
||||
for target in options.targets:
|
||||
try:
|
||||
smb_client = SMBClient(target, options.username, options.password, options.domain, options.hash)
|
||||
smb_client.login()
|
||||
|
||||
for share in smb_client.shares:
|
||||
try:
|
||||
files = smb_client.ls(share, "")
|
||||
|
||||
conn.strategy.add_entry('cn=user0,ou=test,o=lab', {'userPassword': 'test0000', 'sn': 'user0_sn', 'revision': 0})
|
||||
conn.strategy.add_entry('cn=user1,ou=test,o=lab', {'userPassword': 'test1111', 'sn': 'user1_sn', 'revision': 0})
|
||||
conn.strategy.add_entry('cn=user2,ou=test,o=lab', {'userPassword': 'test2222', 'sn': 'user2_sn', 'revision': 0})
|
||||
|
||||
if conn.bind():
|
||||
print(server.info)
|
||||
else:
|
||||
print("Error connecting to domain")
|
||||
print(conn.result)
|
||||
sys.exit(2)
|
||||
else:
|
||||
|
||||
# Login through LDAP
|
||||
#server = Server(options.targets[0], get_info=ALL)
|
||||
#conn = Connection(server)
|
||||
|
||||
# if not conn.bind():
|
||||
# print("Error connecting to domain")
|
||||
# print(conn.result)
|
||||
# sys.exit(2)
|
||||
|
||||
#print(server.info)
|
||||
|
||||
# Login via SMB
|
||||
for target in options.targets:
|
||||
try:
|
||||
smb_client = SMBClient(target, options.username, options.password, options.domain, options.hash)
|
||||
smb_client.login()
|
||||
|
||||
for share in smb_client.shares:
|
||||
print(share)
|
||||
for file in files:
|
||||
print("Found file in %s: %s" % (share, file))
|
||||
|
||||
except Exception as e:
|
||||
print("Exception: ", e)
|
||||
except FileListError:
|
||||
print("Access Denied, cannot list files in %s" % share)
|
||||
continue
|
||||
|
||||
except Exception as e:
|
||||
print("Exception: ", e)
|
||||
|
||||
@@ -9,6 +9,8 @@ from logging.handlers import QueueHandler, QueueListener
|
||||
|
||||
### PRETTY COLORS ###
|
||||
|
||||
# RT: Stolen from manspider - https://github.com/blacklanternsecurity/MANSPIDER
|
||||
|
||||
|
||||
class ColoredFormatter(logging.Formatter):
|
||||
|
||||
@@ -85,6 +87,8 @@ console = logging.StreamHandler(stdout)
|
||||
# tell the handler to use this format
|
||||
console.setFormatter(ColoredFormatter('%(levelname)s %(message)s'))
|
||||
|
||||
|
||||
|
||||
### LOG TO FILE ###
|
||||
|
||||
log_queue = Queue()
|
||||
@@ -97,4 +101,6 @@ logdir.mkdir(parents=True, exist_ok=True)
|
||||
logfile = f'snafflepy_{datetime.now().strftime("%m-%d-%Y")}.log'
|
||||
handler = logging.FileHandler(str(logdir / logfile))
|
||||
handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
|
||||
|
||||
logging.getLogger('snafflepy').addHandler(console)
|
||||
logging.getLogger('snafflepy').addHandler(handler)
|
||||
+6
-2
@@ -1,13 +1,17 @@
|
||||
import ntpath
|
||||
import struct
|
||||
import logging
|
||||
|
||||
from .errors import *
|
||||
from impacket.nmb import NetBIOSError, NetBIOSTimeout
|
||||
from impacket.smbconnection import SessionError, SMBConnection
|
||||
|
||||
|
||||
|
||||
# RT: Stolen from manspider - https://github.com/blacklanternsecurity/MANSPIDER
|
||||
|
||||
# set up logging
|
||||
# Stolen from https://github.com/blacklanternsecurity/MANSPIDER
|
||||
log = logging.getLogger('snafflerpy.smb')
|
||||
log = logging.getLogger('snafflepy.smb')
|
||||
|
||||
|
||||
class SMBClient:
|
||||
|
||||
@@ -6,7 +6,7 @@ import logging
|
||||
import ipaddress
|
||||
from pathlib import Path
|
||||
|
||||
# Stolen from https://github.com/blacklanternsecurity/MANSPIDER
|
||||
# RT: Stolen from manspider - https://github.com/blacklanternsecurity/MANSPIDER
|
||||
|
||||
log = logging.getLogger('snafflerpy.util')
|
||||
|
||||
|
||||
+24
-2
@@ -1,12 +1,13 @@
|
||||
import argparse
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from snaffcore.go_snaffle import *
|
||||
from snaffcore.utilities import *
|
||||
from snaffcore.logger import *
|
||||
|
||||
log = logging.getLogger('snafflepy')
|
||||
log.setLevel(logging.DEBUG)
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
def parse_arguments():
|
||||
syntax_error = False
|
||||
@@ -19,7 +20,12 @@ def parse_arguments():
|
||||
parser.add_argument("-d", "--domain", metavar='domain', default="", help="FQDN domain to authenticate to")
|
||||
parser.add_argument("-H", "--hash", metavar='hash', default="", help="NT hash for authentication")
|
||||
parser.add_argument("-v", "--verbose", action='store_true', help="Show more info")
|
||||
parser.add_argument("--test", metavar='test', type=bool, default=False, help="switch to testing mode")
|
||||
|
||||
# TODO
|
||||
parser.add_argument("-i", "--no-discovery", action='store_true', help="Disables computer and share discovery (more stealthy)")
|
||||
parser.add_argument("-n", "--disable-computer-discovery", action='store_true', help="Disable computer discovery, requires a list of hosts to do discovery on")
|
||||
|
||||
|
||||
|
||||
|
||||
try:
|
||||
@@ -39,9 +45,22 @@ def parse_arguments():
|
||||
else:
|
||||
options = parser.parse_args()
|
||||
|
||||
# TODO
|
||||
if options.verbose:
|
||||
log.setLevel('DEBUG')
|
||||
|
||||
# TODO
|
||||
if options.hash:
|
||||
pass
|
||||
|
||||
# TODO
|
||||
if options.no_discovery:
|
||||
pass
|
||||
|
||||
# TODO
|
||||
if options.disable_computer_discovery:
|
||||
pass
|
||||
|
||||
targets = set()
|
||||
[[targets.add(t) for t in g] for g in options.targets]
|
||||
options.targets = list(targets)
|
||||
@@ -58,6 +77,7 @@ O~~ O~~ O~ O~ O~~ O~~ O~~
|
||||
O~~ O~~ O~~ O~~O~~ O~~ O~~ O~~ O~~O~ O~~ O~~
|
||||
O~~ ~~ O~~~ O~~ O~~ O~~~ O~~ O~~ O~~~ O~~~~ O~~ O~~
|
||||
O~~ ''')
|
||||
|
||||
print("")
|
||||
print("")
|
||||
|
||||
@@ -69,6 +89,8 @@ def main():
|
||||
|
||||
|
||||
print("\nI snaffled 'til the snafflin was done")
|
||||
sleep(0.2)
|
||||
print("View log file at ~/.snafflepy/logs/")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user