Bash


Executing a Cron Job Within an Anaconda Environment

For those seeking to automate their Python scripts using cron jobs within an Anaconda environment, there’s a straightforward method to ensure your scripts run under the correct environment. This approach involves leveraging the capabilities of bash and the configuration of your cron environment to recognize and activate the necessary Anaconda environment. Here’s how to set it up:

  1. Export Anaconda Initialization to a Dedicated Configuration File First, isolate the Anaconda initialization snippet from your ~/.bashrc file by copying it to a new file, say ~/.bashrc_for_cron. This step ensures the cron environment can source the necessary configurations to activate Anaconda environments. Make sure that:
  • The file is readable by the user scheduling the cron job.
  • The file is secured against write access from other users to mitigate security risks.
  1. Configure Cron to Use Bash and Source the Anaconda Configuration Edit your crontab configuration by running crontab -e and prepend your cron jobs with two crucial lines:
   SHELL=/bin/bash
   BASH_ENV=~/.bashrc_for_cron

These lines configure cron to execute jobs using bash instead of the default sh shell and to source the Anaconda configurations from ~/.bashrc_for_cron. When invoked by cron, this setup ensures that bash is aware of the necessary environment to activate Anaconda environments.

  1. Activate Anaconda Environment Before Executing Your Script When scheduling your Python script in crontab -e, prefix the command with the conda activate instruction to switch to your desired Anaconda environment. For instance, to run a script at 12:30 AM every day within a specific Anaconda environment, your cron job entry would look like:
   30 0 * * * conda activate opencv_env; python /path/to/script.py

This ensures that the script executes within the context of the specified Anaconda environment, opencv_env, leveraging any dependencies or configurations defined within that environment.

By following these steps, you can seamlessly schedule and run Python scripts under specific Anaconda environments, leveraging cron’s scheduling capabilities while ensuring the correct environment and dependencies for your scripts.


Various problems with legacy SSH systems

Case 1

Unable to negotiate with 192.168.1.1 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

We solved this problem using the following command:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 [email protected];

Case 2

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 [email protected];
Unable to negotiate with 192.168.1.1 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

We solved this problem using the following command:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-dss [email protected];

Decrypting Firefox Traffic Using Wireshark in Ubuntu GNU/Linux

Wireshark is a powerful network protocol analyzer that lets you capture and analyze real-time network traffic. By default, Wireshark does not decrypt encrypted traffic, such as HTTPS, as it is designed to maintain security and privacy. However, there are cases where decrypting network traffic can be helpful in debugging or analyzing security issues. This blog post will guide you through the steps to decrypt Firefox traffic using Wireshark in Ubuntu GNU/Linux.

Step 1: Download and Extract Firefox:

Since Ubuntu uses the snap package manager to install Firefox, which does not provide access to the file system by default, we need to download Firefox from the official website as a tar.gz archive. Open your browser and navigate to the Mozilla Firefox website (https://www.mozilla.org/en-US/firefox/new/) to download the tar.gz package suitable for your Ubuntu version.

Once the download is complete, navigate to the downloaded location and extract the tar.gz file using the following command:

tar -xvf firefox-<version>.tar.gz;

Step 2: Set up the SSLKEYLOGFILE Environment Variable:

To enable Wireshark to decrypt the SSL/TLS traffic from Firefox, we need to set up the SSLKEYLOGFILE environment variable. This variable will point to a log file where Firefox will write the session keys used for encryption. Execute the following command in the terminal:

export SSLKEYLOGFILE="/home/$USER/.ssl-key.log";

This command sets the SSLKEYLOGFILE environment variable to the specified file path, which is /home/$USER/.ssl-key.log. Feel free to change the file path and name to your preference.

Step 3: Launch Wireshark and Configure Preferences:

Open the terminal and start Wireshark by entering the following command:

wireshark;

Once Wireshark runs, go to “Edit” in the menu bar and select “Preferences” from the dropdown menu. This will open the Wireshark Preferences window.

Step 4: Configure TLS Protocol Preferences:

In the Preferences window, locate and select “Protocols” on the left-hand side. Scroll down the protocols list and find “TLS”. Click on it to expand the options.

Within the TLS section, you will find a field labeled “(Pre)-Master-Secret log filename”. Click on the folder icon next to the field and browse to select the file path for the SSLKEYLOGFILE we set earlier.

After selecting the file path, click the “OK” button to save the changes and close the Preferences window.

Step 5: Capture and Decrypt Firefox Traffic:

With the configuration set up, you can now start capturing and decrypting Firefox traffic. Keep the Wireshark application running and launch the Firefox browser you downloaded and extracted earlier.

Wireshark will capture the network traffic as you browse the web using Firefox. You should be able to see the decrypted traffic in the Wireshark capture window.

Conclusion:

Decrypting network traffic using Wireshark can be valuable for analyzing and troubleshooting network-related issues. This blog post covered the steps to decrypt Firefox traffic using Wireshark in Ubuntu GNU/Linux. By downloading Firefox directly from the website, setting up the SSLKEYLOGFILE environment variable, and configuring Wireshark preferences, you can capture and analyze unencrypted network traffic within Wireshark. Remember to use this technique responsibly and respect the privacy of others while conducting network analysis.


Upgrade O.MG Cable Firmware in Ubuntu GNU/Linux

The O.MG Cable is a popular tool for security professionals and enthusiasts, offering a covert way to gain access to a target device. To ensure its optimal performance and take advantage of new features and security enhancements, it’s important to keep the firmware up to date. In this blog post, we will guide you through the process of upgrading the firmware of an O.MG Cable on a GNU/Linux Ubuntu system using a set of simple commands.

Step 1: Installing pySerial

The first step is to install the pySerial library, which allows communication with serial ports. Open a terminal and execute the following command:

sudo pip3 install pyserial;

This command will install pySerial and its dependencies on your system. You may be prompted to enter your password to proceed with the installation.

Step 2: Cloning the O.MG-Firmware Repository

Next, we need to obtain the O.MG-Firmware repository from GitHub. Change to the desired directory in the terminal and execute the following command:

git clone https://github.com/O-MG/O.MG-Firmware;

This command will create a local copy of the O.MG-Firmware repository on your machine.

Step 3: Navigating to the O.MG-Firmware Directory

Change into the newly created O.MG-Firmware directory by running the following command:

cd O.MG-Firmware/;

This command ensures that you are in the correct directory to proceed with the firmware upgrade.

Step 4: Plugging in the O.MG Cable

Before flashing the firmware, plug in the O.MG Cable to your computer’s USB port. Ensure that the cable is properly connected and recognized by the system.

Step 5: Flashing the Firmware

To initiate the firmware upgrade process, execute the following command:

sudo python3 ./flash.py;

This command triggers the firmware flashing script using Python 3 and grants it the necessary privileges to access the USB port. You may be prompted to enter your password.

You will see progress updates and notifications on the terminal during the flashing process. Do not disconnect or interrupt the cable while the firmware is being flashed.

Once the flashing process completes, the O.MG Cable will install the latest firmware, ensuring optimal performance and security.

Conclusion: In this blog post, we provided a step-by-step guide on upgrading the firmware of an O.MG Cable on a GNU/Linux Ubuntu system. By following these commands, you can keep your O.MG Cable up to date, benefit from new features, and enhance its security. Remember to exercise caution during the firmware flashing process and avoid interrupting it. Enjoy exploring the capabilities of your upgraded O.MG Cable!