Skip to content

Commit cecc8da

Browse files
committed
added functionalities, todo and docstrings
1 parent 0f441e7 commit cecc8da

5 files changed

Lines changed: 45 additions & 17 deletions

File tree

app/ctfsolver/src/ctfsolver.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,29 @@ def __init__(self, *args, **kwargs) -> None:
99
self.debug = kwargs.get("debug", False)
1010

1111
def initializing_all_ancestors(self, *args, **kwargs):
12+
"""
13+
Description:
14+
Initializes all the ancestors of the class
15+
"""
1216
ManagerFile.__init__(self, *args, **kwargs)
1317
ManagerCrypto.__init__(self, *args, **kwargs)
1418
ManagerConnections.__init__(self, *args, **kwargs)
1519

1620
def main(self):
21+
"""
22+
Description:
23+
Placeholder for the main function
24+
"""
1725
pass
1826

1927
def __str__(self):
20-
return f"CTFSolver({self.parent})"
28+
"""
29+
Description:
30+
Returns the string representation of the class, mainly the name of the parent folder
2131
22-
def __str__(self):
32+
Returns:
33+
_type_: _description_
34+
"""
2335
return f"CTFSolver({self.parent})"
2436

2537

app/ctfsolver/src/manager_crypto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def searching_text_in_packets(self, text, packets=None, display=False):
5151
str: Text found in the packet if found
5252
"""
5353

54+
# Todo : Transfer into a different class that will be mainly for packet analysis
5455
if not packets:
5556
packets = self.packets
5657

app/ctfsolver/src/manager_file.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def get_parent(self):
3232
self.parent = self.parent.parent
3333

3434
def setup_named_folder_list(self):
35+
"""
36+
Description:
37+
Setup the main named folder list. If the user has provided a list, add the must folders to it
38+
"""
3539
if self.folders_name_list is None:
3640
self.folders_name_list = self.folders_names_must
3741
elif len(self.folders_name_list) > 1:
@@ -41,7 +45,7 @@ def setup_named_folder_list(self):
4145
def setup_named_folders(self):
4246
"""
4347
Description:
44-
Create folders for the challenge
48+
Create folders for the challenge. (data, files, payloads)
4549
"""
4650

4751
self.folder_payloads = None
@@ -53,7 +57,10 @@ def setup_named_folders(self):
5357
self.folder_payloads = Path(self.parent, "payloads")
5458

5559
def create_parent_folder(self):
56-
""" """
60+
"""
61+
Description:
62+
Create the parent folder of the file that called the class if they don't exist
63+
"""
5764

5865
self.folder_data = Path(self.parent, "data")
5966
self.folder_files = Path(self.parent, "files")
@@ -65,17 +72,14 @@ def create_parent_folder(self):
6572
self.folder_files,
6673
]
6774

68-
# add the folders that are in the named_list but are not in the folder_list
69-
# Make the folder_list public
70-
7175
for folder in folder_list:
7276
if not folder.exists():
7377
folder.mkdir()
7478

7579
def prepare_space(self, files=None, folder=None, test_text="picoCTF{test}"):
7680
"""
7781
Description:
78-
Prepare the space for the challenge by creating the folders if they don't exist
82+
Prepare the space for the challenge by creating the folders if they don't exist, create files from the file list provided
7983
"""
8084
files = files if files else []
8185
folder = folder if folder else self.folder_files
@@ -86,9 +90,13 @@ def prepare_space(self, files=None, folder=None, test_text="picoCTF{test}"):
8690
f.write(test_text)
8791

8892
def get_challenge_file(self):
89-
if self.file and self.folder_data:
93+
"""
94+
Description:
95+
Get the challenge file and assign it to the self.challenge_file for ease of access
96+
"""
97+
if self.file and self.folder_files:
9098
self.challenge_file = Path(self.folder_files, self.file)
91-
elif not self.folder_data:
99+
elif not self.folder_files:
92100
if self.debug:
93101
print("Data folder not found")
94102

@@ -156,6 +164,7 @@ def pcap_open(self, file=None):
156164
Description:
157165
Open the pcap file with scapy and saves it in self.packets
158166
"""
167+
# Todo : Transfer into a different class that will be mainly for packet analysis
159168

160169
if not file:
161170
file = self.challenge_file
@@ -204,6 +213,12 @@ def search_files(
204213
return output
205214

206215
def search_for_base64(self, file, *args, **kwargs):
216+
"""
217+
Depracated, checkout search_for_base64_file
218+
"""
219+
return self.search_for_base64_file(file, *args, **kwargs)
220+
221+
def search_for_base64_file(self, file, *args, **kwargs):
207222
"""
208223
Description:
209224
Search for base64 string in the file

build/lib/ctfsolver/src/manager_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_parent(self):
2626

2727
self.file_called_frame = inspect.stack()
2828
self.file_called_path = Path(self.file_called_frame[-1].filename)
29-
self.parent = Path(self.file_called_path).parent
29+
self.parent = Path(self.file_called_path).parent.resolve()
3030

3131
if self.parent.name in self.folders_name_list:
3232
self.parent = self.parent.parent

docs/TODO.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
## Functionality
1010

1111
- add a list of files that can be considered part of the challenge for easier approach
12-
- Change the versioning
1312

1413
## Publish in pip ?
1514

1615
## Autoamted solver
1716

18-
- Automate the sphynx api documentation ( perhaps a git precommit )
17+
- ~Automate the sphynx api documentation ( perhaps a git precommit )~
1918

2019
## Refactor the bash shortcut
2120

2221
- change the way the bash shortcuts are called
2322
- find a way to add bash autocompletion to the venv
2423

25-
## Script running
26-
27-
- add functionality to figure out where the payloads folder is
28-
2924
## Documentation
3025

3126
Add the documentation on the commands to run and how the whole package is meant to be used
27+
28+
## Discerning libraries
29+
30+
- Transfer all the pcap files to a different class and just inher it
31+
- add a template for every other library used for the solver

0 commit comments

Comments
 (0)