Skip to content

Commit

Permalink
fixed timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
zbalkan committed Dec 11, 2024
1 parent b611f43 commit 94cfb37
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
13 changes: 8 additions & 5 deletions src/panhunt.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ def hunt_pans() -> Report:
def display_report(report: Report) -> None:

newline = '\n'
header: str = f'PAN Hunt Report - {time.strftime("%H:%M:%S %d/%m/%Y")}{newline}{"=" * 100}{newline}'
header += f'Searched {report.__searched}\nExcluded {report.__excluded}{newline}'
header += f'Command: {report.__command}{newline}'
header: str = f'PAN Hunt Report - {report.timestamp.strftime("%H:%M:%S %d/%m/%Y")}{newline}'
header = f'{"=" * 100}{newline}'
header += f'Searched {report.searched}{newline}'
header += f'Excluded {report.excluded}{newline}'
header += f'Command: {report.command}{newline}'
header += f'Uname: {" | ".join(platform.uname())}{newline}'
header += f'Elapsed time: {report.__elapsed}{newline}'
header += f'Found {report.pan_count} possible PANs.{newline}{"=" * 100}{newline}{newline}'
header += f'Elapsed time: {report.elapsed}{newline}'
header += f'Found {report.pan_count} possible PANs.{newline}'
header += f'{"=" * 100}{newline}{newline}'
print(colorama.Fore.WHITE + header)

pan_sep: str = '\n\t'
Expand Down
44 changes: 22 additions & 22 deletions src/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@

class Report:

__start: datetime
__end: datetime
__searched: str
__excluded: str
start: datetime
end: datetime
searched: str
excluded: str
pan_count: int
matched_files: list[Finding]
interesting_files: list[Finding]

__command: str
__timestamp: str
__elapsed: timedelta
command: str
timestamp: datetime
elapsed: timedelta

def __init__(self,
matched_files: list[Finding],
interesting_files: list[Finding],
start: datetime,
end: datetime) -> None:
'''excluded_dirs: list[str]'''
self.__start = start
self.__end = end
self.start = start
self.end = end
self.matched_files = matched_files
self.interesting_files = interesting_files
self.__searched = PANHuntConfiguration().search_dir
self.__excluded = ','.join(PANHuntConfiguration().excluded_directories)
self.__command = ' '.join(sys.argv)
self.__timestamp = time.strftime("%H:%M:%S %d/%m/%Y")
self.__elapsed = self.__end - self.__start
self.searched = PANHuntConfiguration().search_dir
self.excluded = ','.join(PANHuntConfiguration().excluded_directories)
self.command = ' '.join(sys.argv)
self.timestamp = datetime.now()
self.elapsed = self.end - self.start
self.pan_count = len(
[pan for f in self.matched_files if f.matches for pan in f.matches])

Expand All @@ -52,10 +52,10 @@ def create_text_report(self) -> None:
logging.info("Creating TXT report.")
newline = '\n'
report: str = f'PAN Hunt Report - {time.strftime("%H:%M:%S %d/%m/%Y")}{newline}{"=" * 100}{newline}'
report += f'Searched {self.__searched}\nExcluded {self.__excluded}{newline}'
report += f'Command: {self.__command}{newline}'
report += f'Searched {self.searched}\nExcluded {self.excluded}{newline}'
report += f'Command: {self.command}{newline}'
report += f'Uname: {" | ".join(platform.uname())}{newline}'
report += f'Elapsed time: {self.__elapsed}{newline}'
report += f'Elapsed time: {self.elapsed}{newline}'
report += f'Found {self.pan_count} possible PANs.{newline}{"=" * 100}{newline}{newline}'

for file in self.matched_files:
Expand Down Expand Up @@ -88,11 +88,11 @@ def create_json_report(self) -> None:
logging.info("Creating JSON report.")

report: dict = {}
report['timestamp'] = self.__timestamp
report['searched'] = self.__searched
report['excluded'] = self.__excluded
report['command'] = self.__command
report['elapsed'] = str(self.__elapsed)
report['timestamp'] = self.timestamp.strftime("%H:%M:%S %d/%m/%Y")
report['searched'] = self.searched
report['excluded'] = self.excluded
report['command'] = self.command
report['elapsed'] = str(self.elapsed)
report['pans_found'] = self.pan_count

matched_items: dict[str, list[str]] = {}
Expand Down

0 comments on commit 94cfb37

Please sign in to comment.