Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views6 pages

Compiling The Standalone Execution File

This document provides a comprehensive guide on compiling a standalone executable for a Python project using PyInstaller, configuring network settings for virtual machines in VirtualBox, and managing Docker containers. It includes detailed steps for verifying Python installations, setting static IP addresses in Ubuntu and Kali Linux, creating and running Docker images, and transferring Docker images between systems. Additionally, it covers network traffic capture and memory usage calculations.

Uploaded by

Ag Phyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Compiling The Standalone Execution File

This document provides a comprehensive guide on compiling a standalone executable for a Python project using PyInstaller, configuring network settings for virtual machines in VirtualBox, and managing Docker containers. It includes detailed steps for verifying Python installations, setting static IP addresses in Ubuntu and Kali Linux, creating and running Docker images, and transferring Docker images between systems. Additionally, it covers network traffic capture and memory usage calculations.

Uploaded by

Ag Phyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Compiling the standalone execution file

C:\Users\HP>python --version

Python 3.12.2

C:\Users\HP>pip --version

pip 24.0 from C:\Python312\Lib\site-packages\pip (python 3.12)

C:\Users\HP>echo %PATH%

PATH Configuration:
Python executable is located at C:\Python312\.
Python scripts (including pip) are located at C:\Python312\Scripts\.

This setup confirms that it can run Python scripts and install dependencies without additional
configuration.

Step 1: Verify Your Python Project


Place your main script (framework.py) and all modules in a directory (e.g., D:\Scanner).
Include any necessary files (e.g., configuration files or templates).

Step 2: Install PyInstaller


pip install pyinstaller

Step 3: Create the Standalone Executable


Run the following command in the directory containing the framework.py:
cd D:\RedisScanner

import modules and dependencies:


pyinstaller --onefile --name RedisScanner --add-data "modules;modules" --add-data
"apache_versions.txt;." --add-data "base_scanner_module.py;." --add-data "ca.crt;." --add-data
"common_php_pages.txt;." --hidden-import bs4 --hidden-import paramiko --hidden-import pyshark
framework.py

Step 4: Test the Executable


After the process is complete, go to the dist folder in the project directory:
cd dist

Run the executable to verify:


RedisScanner.exe
Step 1: Set the Network Adapter in VirtualBox

Open VirtualBox:
Select the VM (Kali Linux or Ubuntu) and click Settings.

Choose Network Type:


Go to the Network tab and choose the network type:
Host-Only Adapter: Use this if you only need communication between the VM and the host.
Bridged Adapter: Use this if you want the VM to be on the same network as your physical
machine and access the internet.
NAT Network: Use this for internet access and communication between VMs on the same NAT
network.

Select Adapter:
In the "Attached to" dropdown, select the desired network type.
Ensure Cable Connected is checked.

Step 2: Configure Static IP in Ubuntu


Check the Network Interface Name
Open a terminal in Ubuntu.
Run the following command to list all network interfaces:

ip a

Look for the name of your primary network interface, such as enp0s3 or eth0.

Edit Netplan Configuration

Open the Netplan configuration file for editing:

sudo nano /etc/netplan/01-netcfg.yaml

Add or modify the configuration:

network:
version: 2
renderer: networkd
ethernets:
enp0s3: # Replace with actual interface name
dhcp4: no
addresses:
- 192.168.1.125/24 # Static IP address
gateway4: 192.168.1.1 # Default gateway
nameservers:
addresses:
- 8.8.8.8 # Google DNS
- 8.8.4.4

Apply the changes:

sudo netplan apply

Verify the IP address:

ip a

Step 3: Configure Static IP in Kali Linux


Check the Network Interface Name

Open a terminal in Kali Linux.


Run the following command to list all network interfaces:

ip a

Note the primary interface name (e.g., eth0 or enp0s3).

Edit Network Configuration

Edit the /etc/network/interfaces file:

sudo nano /etc/network/interfaces

Add or modify the following configuration:

auto eth0
iface eth0 inet static
address 192.168.1.126 # Static IP address
netmask 255.255.255.0 # Subnet mask
gateway 192.168.1.1 # Default gateway
dns-nameservers 8.8.8.8 8.8.4.4 # DNS servers

Replace eth0 with the actual interface name.

Restart the networking service:

sudo systemctl restart networking

Verify the IP address:


ip a

Step 4: Test the Configuration

Ping the VM from the host to ensure connectivity:

ping 192.168.1.125 # Ubuntu


ping 192.168.1.126 # Kali

From the VM, test internet access:

ping google.com

Optional: Persist Changes in VirtualBox

To ensure the network settings persist:


Use the same network adapter type (e.g., Host-Only or Bridged) consistently.
Ensure the network configuration in Ubuntu or Kali is correctly applied during startup.

Create a virtual environment:


python3 -m venv venv

Activate the virtual environment:


source venv/bin/activate

Activate the virtual environment in U22.10:


source /home/phyo/Documents/Redis_Scanner/venv/bin/activate

Check docker version:


docker –version

If not install yet, install docker


Sudo apt install docker.io

Create docker file:


sudo nano Dockerfile

Build the docker image.


sudo docker build -t redis-scanner-image .

If something errors, remove all images:


sudo docker system prune -a –volumes
Check docker images, container ID, volumes
Docker ps
Docker ps -a

If the build successful, run the docker images.


sudo docker run --rm -it redis-scanner-image

sudo docker run --rm -it \


--name redis \
-v /home/kali/docker/ca.crt:/custom_mount/ca.crt \
redis

 Left side of the directory dynamic.


 Right side of the directory mount the local directory. Use in container run time.

Manual pdf report File Retrieval

If did not set up the mount and the file is saved within the container:

Find the Running Container ID:


docker ps

Copy the File to Your Host Machine:


docker cp <container_id>:/app/Redis_Scanning_Report_<timestamp>.pdf /path/to/host/folder

for example:
sudo docker cp redis-scanner:/app/Redis_Scanning_Report_20250304_141759.pdf
/home/kali/docker/

docker build -t redis-scanner:latest .


docker run --rm -it redis-scanner:latest

Step 1: Export the Image from Ubuntu

built the redis-scanner image on Ubuntu, need to transfer it to the Kali Linux system.

On Ubuntu 22.10 machine, export the image using:

sudo docker save -o redis-scanner.tar redis-scanner

This command saves the redis-scanner image into a file called redis-scanner.tar.

Step 2: Transfer the Image to Kali Linux


Use scp or a USB drive to transfer the redis-scanner.tar file from Ubuntu to Kali.
Option 1: Use SCP (if both systems are connected via SSH)

Run this command on Ubuntu to copy the file to Kali (replace kali_user and kali_ip with your actual Kali
Linux username and IP address):

scp redis-scanner.tar kali_user@kali_ip:/home/kali/

Enter the password when prompted.

Step 2: Load the Image on Kali Linux

Once the redis-scanner.tar file is on Kali Linux, run:

sudo docker load -i /home/kali/redis-scanner.tar

This will import the redis-scanner image into Docker on Kali.

To verify that the image was successfully loaded, run:


sudo docker images

see redis-scanner in the list.

Step 3: Run the Container on Kali Linux


start the container using:

sudo docker run --rm -it \


--name redis-scanner \
-v /home/kali/docker/ca.crt:/custom_mount/ca.crt \
-v /home/kali/docker/common_php_pages.txt:/custom_mount/common_php_pages.txt \
-v /home/kali/docker/apache_versions.txt:/custom_mount/apache_versions.txt \
redis-scanner

capture with tcpdump


sudo tcpdump -i any -n port 6379 or port 6380 -w redis_traffic1.pcap

for time checking and system usage


/usr/bin/time -v docker run --rm -it scanner

Memory Usage Formula


Memory Usage (%) = (Used Memory (KB) / Total Memory (KB) ) × 100

You might also like