33from scapy .all import rdpcap
44import os
55import ast
6+ from .manager_files_pcap import ManagerFilePcap
67
78
8- class ManagerFile :
9+ class ManagerFile ( ManagerFilePcap ) :
910 def __init__ (self , * args , ** kwargs ):
1011 self .Path = Path
1112 self .file = kwargs .get ("file" )
@@ -17,6 +18,13 @@ def __init__(self, *args, **kwargs):
1718 self .setup_named_folders ()
1819 self .get_challenge_file ()
1920
21+ def initializing_all_ancestors (self , * args , ** kwargs ):
22+ """
23+ Description:
24+ Initializes all the ancestors of the class
25+ """
26+ ManagerFilePcap .__init__ (self , * args , ** kwargs )
27+
2028 def get_parent (self ):
2129 """
2230 Description:
@@ -32,6 +40,10 @@ def get_parent(self):
3240 self .parent = self .parent .parent
3341
3442 def setup_named_folder_list (self ):
43+ """
44+ Description:
45+ Setup the main named folder list. If the user has provided a list, add the must folders to it
46+ """
3547 if self .folders_name_list is None :
3648 self .folders_name_list = self .folders_names_must
3749 elif len (self .folders_name_list ) > 1 :
@@ -41,7 +53,7 @@ def setup_named_folder_list(self):
4153 def setup_named_folders (self ):
4254 """
4355 Description:
44- Create folders for the challenge
56+ Create folders for the challenge. (data, files, payloads)
4557 """
4658
4759 self .folder_payloads = None
@@ -53,7 +65,10 @@ def setup_named_folders(self):
5365 self .folder_payloads = Path (self .parent , "payloads" )
5466
5567 def create_parent_folder (self ):
56- """ """
68+ """
69+ Description:
70+ Create the parent folder of the file that called the class if they don't exist
71+ """
5772
5873 self .folder_data = Path (self .parent , "data" )
5974 self .folder_files = Path (self .parent , "files" )
@@ -65,17 +80,14 @@ def create_parent_folder(self):
6580 self .folder_files ,
6681 ]
6782
68- # add the folders that are in the named_list but are not in the folder_list
69- # Make the folder_list public
70-
7183 for folder in folder_list :
7284 if not folder .exists ():
7385 folder .mkdir ()
7486
7587 def prepare_space (self , files = None , folder = None , test_text = "picoCTF{test}" ):
7688 """
7789 Description:
78- Prepare the space for the challenge by creating the folders if they don't exist
90+ Prepare the space for the challenge by creating the folders if they don't exist, create files from the file list provided
7991 """
8092 files = files if files else []
8193 folder = folder if folder else self .folder_files
@@ -86,9 +98,13 @@ def prepare_space(self, files=None, folder=None, test_text="picoCTF{test}"):
8698 f .write (test_text )
8799
88100 def get_challenge_file (self ):
89- if self .file and self .folder_data :
101+ """
102+ Description:
103+ Get the challenge file and assign it to the self.challenge_file for ease of access
104+ """
105+ if self .file and self .folder_files :
90106 self .challenge_file = Path (self .folder_files , self .file )
91- elif not self .folder_data :
107+ elif not self .folder_files :
92108 if self .debug :
93109 print ("Data folder not found" )
94110
@@ -156,6 +172,7 @@ def pcap_open(self, file=None):
156172 Description:
157173 Open the pcap file with scapy and saves it in self.packets
158174 """
175+ # Todo : Transfer into a different class that will be mainly for packet analysis
159176
160177 if not file :
161178 file = self .challenge_file
@@ -204,6 +221,12 @@ def search_files(
204221 return output
205222
206223 def search_for_base64 (self , file , * args , ** kwargs ):
224+ """
225+ Depracated, checkout search_for_base64_file
226+ """
227+ return self .search_for_base64_file (file , * args , ** kwargs )
228+
229+ def search_for_base64_file (self , file , * args , ** kwargs ):
207230 """
208231 Description:
209232 Search for base64 string in the file
0 commit comments