Pre-Programmable Security Tool
π Index
π° Overview
PreSec is a cybersecurity software that I created to simplify the application of concepts I learned after completing the Leveling module in the Hackers do Bem course.
Entirely built in Python, PreSec features a modern and intuitive Graphical User Interface (GUI) created with Customtkinter, by Tom Schimansky.
It's a comprehensive solution initially designed to simplify non-critical tasks, such as preventive analysis and monitoring.
The software encompasses three main functionalities, allowing customization of appearance (dark mode and light mode) and language (English, Portuguese, and Spanish), as well as the creation and complete management (CRUD) of your own commands and CVE vulnerabilities.
π Command-line
Easy execution of command lines: PreSec facilitates command execution with a straightforward approach.
By registering and organizing commands from basic to advanced, this feature simplifies tasks,
mmaking them accessible to all skill levels.
Parameters:
Field | Type/reference | Description |
---|---|---|
user_type |
Combobox | Allows the user to filter commands by privileges. |
category |
Combobox | Allows the user to filter commands by category. |
system |
Entry | Automatically identifies the operating system. |
choose_a_command * |
Combobox | Required field. Allows the user to choose the command. |
command_line |
Textbox | Allows the user to view only the command line. |
command_description |
Textbox | Allows the user to view only the command description. |
π Port Scanner
Simplify network exploration with PreSec's active port scanner. Just provide the IP address, adjust your preferences, and allow the tool to perform an efficient scan. Ideal for identifying suspicious activities and maintaining a secure environment.
Parameters:
Field | Type/reference | Description |
---|---|---|
ipv4_adress * |
Entry | Required field. Allows the user to set IPv4 address. |
use_my_ip |
Slider | Allows the user to define an IPv4 or choose their own. |
threads |
Entry | Allows the user to define the number of threads that will be used. |
start_port * |
Entry | Required field. Allows the user to choose the start port. |
end_port * |
Entry | Required field. Allows the user to choose the end port. |
π‘οΈ CVE Vulnerability
- Easily identify known vulnerabilities by CVE on any website (with proper authorization) using PreSec. Simply provide the website URL, choose the desired scan type (single, list, or all), and let PreSec do the rest.
- Customize vulnerabilities and categories (in the "configure" tab) for a dynamic environment tailored to your needs.
Parameters:
Field | Type/reference | Description |
---|---|---|
target_url * |
Entry | Required field. Allows the user to define any target url. |
single_cve_check , list_cve_check and all_cve_check |
Combobox | Allows the user to choose between a single CVE code, a list of code (containing a group of CVE codes), or all registered CVE codes. |
list , single and all |
Switch | Allows the user to set the type of check: single, list or all. |
vulnerability_description |
Textbox | Allows the user to view only the vulnerability description. |
... and more are coming!
βοΈ User settings
User type (e.g., user
or admin
) and platform system (e.g., Windows
or Linux
) are stored as user preferences in JSON format, in this folder: src/json/preferences.json
.
Add more as needed.
π οΈ Customize it (CRUD)
Create your own:
π Good practices
Category | Badges | Description |
---|---|---|
Clean Code | Practices for coding to make the code clean and readable. | |
PEPs | Standards for code style in Python. Zen of Python principles. Conventions for docstrings in Python. | |
Pythonic | Writing Python code in the "Pythonic" way. |
πΌοΈ Frame management (screenshot)
All are separated into frames and subframes to facilitate the layout/grid and manipulation of elements.πΌοΈ Dependencies (screenshot)
Dependencies do not have CVE vulnerabilities.[!IMPORTANT] During development, only one dependency with a CVE vulnerability was identified, but it has already been corrected.
π₯ Video presentation
Opens on YouTube.
[!WARNING] Active captions, audio in Portuguese (π§π·) only.
Video url: https://www.youtube.com/watch?v=Heqp-fZ53xA
π
PreSec (beta)
is currently under development in branchmain
.
π Prerequisites
- Windows 10 or higher and Ubuntu 22.04 or higher.
- Python 3.11.4 or higher
- git 2.40.1 or higher
- pip 23.1.2 or higher
β¬οΈ Installing prerequisites
Update system dependencies before proceeding. To do this, copy and paste the command below into your Terminal and press enter
:
sudo apt update
...and only then, proceed with the tutorial below:
π Installing Python
sudo apt install python3.11
π Installing git
sudo apt install git
π¦ Installing pip
sudo apt install python3.11-pip
To use this software, follow the steps below:
1οΈβ£ Cloning this repository
-
Navigate to the folder where you typically install programs or applications on your computer. Any folder you prefer.
-
Opens the Terminal. To do this, follow any of the instructions below:
On Windows, there are 2 options:
- Via CMD (Command Prompt):
- In the address bar located at the top of the window, click on the folder address field. If it's not visible, ensure that 'Address Bar' is checked in the 'View' menu.
- Type
CMD
in the selected address bar and pressenter
. This opens a CMD-type terminal in the current folder.
- Via PowerShell:
- In the upper address bar, click to select the folder address. If not visible, ensure 'Address Bar' is checked in the 'View' menu.
- Right-click on the selected address bar and choose
Open in Terminal
. This opens a PowerShell-type terminal in the current folder.
On Linux (via Bash):
- Right-click on the folder background and select
Open in Terminal
or navigate to the project root folder using thecd
command.
- Via CMD (Command Prompt):
-
Next, clone this repository into the folder you chose. To do this, copy and paste the command below into your terminal and press
enter
:
git clone https://github.com/GustavoRosas-Dev/GUI_PreSec.git
Then, navigate into the project folder. To do this, copy and paste the command below into your terminal and press enter
:
cd GUI_PreSec
[!NOTE] The above command will use the git clone module to create an exact copy of this repository in your folder (local repository).
2οΈβ£ Create virtual environment
With the Terminal still open, copy and paste the command below and press enter
:
On Windows:
python -m venv venv
On Linux:
Begin by installing the package below, which provides support for virtual environments (venv), in Python 3.11.
sudo apt install python3.11-venv
The execution of the above command requires elevated administrative privileges (indicated by the use of sudo
). Therefore, you will be prompted for the superuser (root
) password to ensure security and authorize the package installation in Python 3.11.
Next, create your virtual environment by copying and pasting the code below into your Terminal:
python3.11 -m venv venv
[!NOTE] The above command utilizes the
python
interpreter (via environment variables) with the-m
(module) parameter to create a virtual environment (venv
) named the same asvenv
. You could name it whatever you like; however, it is a universal convention (adopted by the Python community) to name it this way.
3οΈβ£ Activate virtual environment
The next step is to activate the virtual environment. See how simple it is:
On Windows:
-
Navigate to the
Scripts
folder:cd venv\Scripts
-
Then, activate the virtual environment:
activate
-
And finally, return to the root folder. To do this, type the command below and press
enter
. Repeat this twice:cd ..
[!NOTE] The
cd
(change directory) command, when used with..
, allows you to navigate up one level in the directory structure. Executing this combination twice will bring you back to the main project folder, specifically theGUI_PreSec/
directory.
On Linux:
source venv/bin/activate
β
To confirm that the virtual environment has been activated correctly , simply look at your Terminal and check if (venv)
appears on the same line where you would type your next command.
See an example in the image below:
(Bonus) If you are a newbie in development (like me π), click here.
Now, you might be wondering, 'Why should I create and activate a virtual environment, I'm right?'
If you're wondering why you should create and activate a virtual environment, it's essential to understand that a virtual environment provides a dedicated space for installing dependencies (libraries) isolated from the rest of your machine. Each project can have its own virtual environment, ensuring that the dependencies required for that specific project are maintained separately.
This practice is crucial for a few reasons:
[!TIP] Consistency: It guarantees a consistent environment for your project, preventing conflicts between different projects that may require different versions of the same library.
[!TIP] Isolation: Dependencies are confined to the virtual environment, avoiding interference with other projects or system-level packages.
[!TIP] Collaboration: When collaborating on projects, sharing the project's virtual environment specifications (usually stored in a requirements.txt file) enables others to recreate the exact environment, ensuring a smooth collaboration experience across different machines.
4οΈβ£ Install requirements
With the virtual environment active, simply install the dependencies (libraries) that the project needs to function. To do this, copy and paste the command below into the Terminal and press enter
:
On Windows:
pip install -r requirements.txt
On Linux:
pip3.11 install -r requirements.txt
[!NOTE] The above command uses
pip
(Package Installer for Python) to install dependencies specified in the requirements file. Theinstall
command is a fundamental part of pip, followed by the-r
(read) parameter, indicating that it should read and install the requirements. Therequirements.txt
file, located in the root folder of this project, contains a list of necessary libraries for the project to function.
Make sure you are in the project's root folder (GUI_PreSec/
). Then, copy and paste the command below into the Terminal, and press enter
:
python main.py
python3.11 main.py
See CONTRIBUTING
See LICENSE
Hackers Do Bem (1st BR class).