Bjorn Documentation

Bjorn is a powerful network scanning and offensive security tool for the Raspberry Pi with a 2.13-inch e-Paper HAT. It discovers network targets, identifies...

RAW Doc

File: README.md

Bjorn


Bjorn is aย ยซย Tamagotchi likeย ยป sophisticated, autonomous network scanning, vulnerability assessment, and offensive security tool designed to run on a Raspberry Pi equipped with a 2.13-inch e-Paper HAT. This document provides a detailed explanation of the project.

๐Ÿ“š Table of Contents

๐Ÿ“„ Introduction

Bjorn is a powerful tool designed to perform comprehensive network scanning, vulnerability assessment, and data ex-filtration. Its modular design and extensive configuration options allow for flexible and targeted operations. By combining different actions and orchestrating them intelligently, Bjorn can provide valuable insights into network security and help identify and mitigate potential risks.

The e-Paper HAT display and web interface make it easy to monitor and interact with Bjorn, providing real-time updates and status information. With its extensible architecture and customizable actions, Bjorn can be adapted to suit a wide range of security testing and monitoring needs.

๐ŸŒŸ Features

  • Network Scanning: Identifies live hosts and open ports on the network.
  • Vulnerability Assessment: Performs vulnerability scans using Nmap and other tools.
  • System Attacks: Conducts brute-force attacks on various services (FTP, SSH, SMB, RDP, Telnet, SQL).
  • File Stealing: Extracts data from vulnerable services.
  • User Interface: Real-time display on the e-Paper HAT and web interface for monitoring and interaction.

๐Ÿš€ Getting Started

๐Ÿ“Œ Prerequisites

๐Ÿ“‹ Prerequisites for RPI zero W (32bits)

  • Raspberry Pi OS installed.
    • Stable:
      • System: 32-bit
      • Kernel version: 6.6
      • Debian version: 12 (bookworm) '2024-10-22-raspios-bookworm-armhf-lite'
  • Username and hostname set to bjorn.
  • 2.13-inch e-Paper HAT connected to GPIO pins.

๐Ÿ“‹ Prerequisites for RPI zero W2 (64bits)

I did not develop Bjorn for the raspberry pi zero w2 64bits, but several feedbacks have attested that the installation worked perfectly.

  • Raspberry Pi OS installed.
    • Stable:
      • System: 64-bit
      • Kernel version: 6.6
      • Debian version: 12 (bookworm) '2024-10-22-raspios-bookworm-arm64-lite'
  • Username and hostname set to bjorn.
  • 2.13-inch e-Paper HAT connected to GPIO pins.

At the moment the paper screen v2 v4 have been tested and implemented.
I juste hope the V1 & V3 will work the same.

๐Ÿ”จ Installation

The fastest way to install Bjorn is using the automatic installation script :

bash
# Download and run the installer
wget https://raw.githubusercontent.com/infinition/Bjorn/refs/heads/main/install_bjorn.sh
sudo chmod +x install_bjorn.sh && sudo ./install_bjorn.sh
# Choose the choice 1 for automatic installation. It may take a while as a lot of packages and modules will be installed. You must reboot at the end.

For detailed information about installation process go to Install Guide

โšก Quick Start

Need help ? You struggle to find Bjorn's IP after the installation ?
Use my Bjorn Detector & SSH Launcher :

https://github.com/infinition/bjorn-detector

Hmm, You still need help ?
For detailed information about troubleshooting go to Troubleshooting

Quick Installation: you can use the fastest way to install Bjorn Getting Started

๐Ÿ’ก Usage Example

Here's a demonstration of how Bjorn autonomously hunts through your network like a Viking raider (fake demo for illustration):

bash
# Reconnaissance Phase
[NetworkScanner] Discovering alive hosts...
[+] Host found: 192.168.1.100
    โ”œโ”€โ”€ Ports: 22,80,445,3306
    โ””โ”€โ”€ MAC: 00:11:22:33:44:55

# Attack Sequence 
[NmapVulnScanner] Found vulnerabilities on 192.168.1.100
    โ”œโ”€โ”€ MySQL 5.5 < 5.7 - User Enumeration
    โ””โ”€โ”€ SMB - EternalBlue Candidate

[SSHBruteforce] Cracking credentials...
[+] Success! user:password123
[StealFilesSSH] Extracting sensitive data...

# Automated Data Exfiltration
[SQLBruteforce] Database accessed!
[StealDataSQL] Dumping tables...
[SMBBruteforce] Share accessible
[+] Found config files, credentials, backups...

This is just a demo output - actual results will vary based on your network and target configuration.

All discovered data is automatically organized in the data/output/ directory, viewable through both the e-Paper display (as indicators) and web interface.
Bjorn works tirelessly, expanding its network knowledge base and growing stronger with each discovery.

No constant monitoring needed - just deploy and let Bjorn do what it does best: hunt for vulnerabilities.

๐Ÿ”ง Expand Bjorn's Arsenal!
Bjorn is designed to be a community-driven weapon forge. Create and share your own attack modules!

โš ๏ธ For educational and authorized testing purposes only โš ๏ธ

๐Ÿค Contributing

The project welcomes contributions in:

  • New attack modules.
  • Bug fixes.
  • Documentation.
  • Feature improvements.

For detailed information about contributing process go to Contributing Docs, Code Of Conduct and Development Guide.

๐Ÿ“ซ Contact

  • Report Issues: Via GitHub.

  • Guidelines:

    • Follow ethical guidelines.
    • Document reproduction steps.
    • Provide logs and context.
  • Author: infinition

  • GitHub: infinition/Bjorn

๐ŸŒ  Stargazers


๐Ÿ“œ License

2024 - Bjorn is distributed under the MIT License. For more details, please refer to the LICENSE file included in this repository.


File: CODE_OF_CONDUCT.md

๐Ÿ“ Code of Conduct

Take Note About This... Take Note...

๐Ÿค Our Commitment

We are committed to fostering an open and welcoming environment for all contributors. As such, everyone who participates in Bjorn is expected to adhere to the following code of conduct.

๐ŸŒŸ Expected Behavior

  • Respect: Be respectful of differing viewpoints and experiences.
  • Constructive Feedback: Provide constructive feedback and be open to receiving it.
  • Empathy and Kindness: Show empathy and kindness towards other contributors.
  • Respect for Maintainers: Respect the decisions of the maintainers.
  • Positive Intent: Assume positive intent in interactions with others.

๐Ÿšซ Unacceptable Behavior

  • Harassment or Discrimination: Harassment or discrimination in any form.
  • Inappropriate Language or Imagery: Use of inappropriate language or imagery.
  • Personal Attacks: Personal attacks or insults.
  • Public or Private Harassment: Public or private harassment.

๐Ÿ“ข Reporting Misconduct

If you encounter any behavior that violates this code of conduct, please report it by contacting [email protected]. All complaints will be reviewed and handled appropriately.

โš–๏ธ Enforcement

Instances of unacceptable behavior may be addressed by the project maintainers, who are responsible for clarifying and enforcing this code of conduct. Violations may result in temporary or permanent bans from the project and related spaces.

๐Ÿ™ Acknowledgments

This code of conduct is adapted from the Contributor Covenant, version 2.0.


๐Ÿ“œ License

2024 - Bjorn is distributed under the MIT License. For more details, please refer to the LICENSE file included in this repository.


File: CONTRIBUTING.md

๐Ÿค Contributing to Bjorn

We welcome contributions to Bjorn! To make sure the process goes smoothly, please follow these guidelines:

๐Ÿ“‹ Code of Conduct

Please note that all participants in our project are expected to follow our Code of Conduct. Make sure to review it before contributing.

๐Ÿ›  How to Contribute

  1. Fork the repository:
    Fork the project to your GitHub account using the GitHub interface.

  2. Create a new branch:
    Use a descriptive branch name for your feature or bugfix:

    git checkout -b feature/your-feature-name

  3. Make your changes:
    Implement your feature or fix the bug in your branch. Make sure to include tests where applicable and follow coding standards.

  4. Test your changes:
    Run the test suite to ensure your changes donโ€™t break any functionality:

    • ...
  5. Commit your changes:
    Use meaningful commit messages that explain what you have done:

    git commit -m "Add feature/fix: Description of changes"

  6. Push your changes:
    Push your changes to your fork:

    git push origin feature/your-feature-name

  7. Submit a Pull Request:
    Create a pull request on the main repository, detailing the changes youโ€™ve made. Link any issues your changes resolve and provide context.

๐Ÿ“‘ Guidelines for Contributions

  • Lint your code before submitting a pull request. We use ESLint for frontend and pylint for backend linting.
  • Ensure test coverage for your code. Uncovered code may delay the approval process.
  • Write clear, concise commit messages.

Thank you for helping improve!


๐Ÿ“œ License

2024 - Bjorn is distributed under the MIT License. For more details, please refer to the LICENSE file included in this repository.


File: DEVELOPMENT.md

๐Ÿ–ฒ๏ธ Bjorn Development

๐Ÿ“š Table of Contents

๐ŸŽจ Design

  • Portability: Self-contained and portable device, ideal for penetration testing.
  • Modularity: Extensible architecture allowing addition of new actions.
  • Visual Interface: The e-Paper HAT provides a visual interface for monitoring the ongoing actions, displaying results or stats, and interacting with Bjorn .

๐Ÿ“” Educational Aspects

  • Learning Tool: Designed as an educational tool to understand cybersecurity concepts and penetration testing techniques.
  • Practical Experience: Provides a practical means for students and professionals to familiarize themselves with network security practices and vulnerability assessment tools.

โœ’๏ธ Disclaimer

  • Ethical Use: This project is strictly for educational purposes.
  • Responsibility: The author and contributors disclaim any responsibility for misuse of Bjorn.
  • Legal Compliance: Unauthorized use of this tool for malicious activities is prohibited and may be prosecuted by law.

๐Ÿงฉ Extensibility

  • Evolution: The main purpose of Bjorn is to gain new actions and extend his arsenal over time.
  • Modularity: Actions are designed to be modular and can be easily extended or modified to add new functionality.
  • Possibilities: From capturing pcap files to cracking hashes, man-in-the-middle attacks, and moreโ€”the possibilities are endless.
  • Contribution: It's up to the user to develop new actions and add them to the project.

๐Ÿ”ฆ Development Status

  • Project Status: Ongoing development.
  • Current Version: Scripted auto-installer, or manual installation. Not yet packaged with Raspberry Pi OS.
  • Reason: The project is still in an early stage, requiring further development and debugging.

๐Ÿ—‚๏ธ Project Structure

text
Bjorn/
โ”œโ”€โ”€ Bjorn.py
โ”œโ”€โ”€ comment.py
โ”œโ”€โ”€ display.py
โ”œโ”€โ”€ epd_helper.py
โ”œโ”€โ”€ init_shared.py
โ”œโ”€โ”€ kill_port_8000.sh
โ”œโ”€โ”€ logger.py
โ”œโ”€โ”€ orchestrator.py
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ shared.py
โ”œโ”€โ”€ utils.py
โ”œโ”€โ”€ webapp.py
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ actions/
โ”‚   โ”œโ”€โ”€ ftp_connector.py
โ”‚   โ”œโ”€โ”€ ssh_connector.py
โ”‚   โ”œโ”€โ”€ smb_connector.py
โ”‚   โ”œโ”€โ”€ rdp_connector.py
โ”‚   โ”œโ”€โ”€ telnet_connector.py
โ”‚   โ”œโ”€โ”€ sql_connector.py
โ”‚   โ”œโ”€โ”€ steal_files_ftp.py
โ”‚   โ”œโ”€โ”€ steal_files_ssh.py
โ”‚   โ”œโ”€โ”€ steal_files_smb.py
โ”‚   โ”œโ”€โ”€ steal_files_rdp.py
โ”‚   โ”œโ”€โ”€ steal_files_telnet.py
โ”‚   โ”œโ”€โ”€ steal_data_sql.py
โ”‚   โ”œโ”€โ”€ nmap_vuln_scanner.py
โ”‚   โ”œโ”€โ”€ scanning.py
โ”‚   โ””โ”€โ”€ __init__.py
โ”œโ”€โ”€ backup/
โ”‚   โ”œโ”€โ”€ backups/
โ”‚   โ””โ”€โ”€ uploads/
โ”œโ”€โ”€ config/
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ input/
โ”‚   โ”‚   โ””โ”€โ”€ dictionary/
โ”‚   โ”œโ”€โ”€ logs/
โ”‚   โ””โ”€โ”€ output/
โ”‚       โ”œโ”€โ”€ crackedpwd/
โ”‚       โ”œโ”€โ”€ data_stolen/
โ”‚       โ”œโ”€โ”€ scan_results/
โ”‚       โ”œโ”€โ”€ vulnerabilities/
โ”‚       โ””โ”€โ”€ zombies/
โ””โ”€โ”€ resources/
    โ””โ”€โ”€ waveshare_epd/

โš“ Core Files

Bjorn.py

The main entry point for the application. It initializes and runs the main components, including the network scanner, orchestrator, display, and web server.

comment.py

Handles generating all the Bjorn comments displayed on the e-Paper HAT based on different themes/actions and statuses.

display.py

Manages the e-Paper HAT display, updating the screen with Bjorn character, the dialog/comments, and the current information such as network status, vulnerabilities, and various statistics.

epd_helper.py

Handles the low-level interactions with the e-Paper display hardware.

logger.py

Defines a custom logger with specific formatting and handlers for console and file logging. It also includes a custom log level for success messages.

orchestrator.py

Bjornโ€™s AI, a heuristic engine that orchestrates the different actions such as network scanning, vulnerability scanning, attacks, and file stealing. It loads and executes actions based on the configuration and sets the status of the actions and Bjorn.

shared.py

Defines the SharedData class that holds configuration settings, paths, and methods for updating and managing shared data across different modules.

init_shared.py

Initializes shared data that is used across different modules. It loads the configuration and sets up necessary paths and variables.

utils.py

Contains utility functions used throughout the project.

webapp.py

Sets up and runs a web server to provide a web interface for changing settings, monitoring and interacting with Bjorn.

โ–ถ๏ธ Actions

actions/scanning.py

Conducts network scanning to identify live hosts and open ports. It updates the network knowledge base (netkb) and generates scan results.

actions/nmap_vuln_scanner.py

Performs vulnerability scanning using Nmap. It parses the results and updates the vulnerability summary for each host.

Protocol Connectors

  • ftp_connector.py: Brute-force attacks on FTP services.
  • ssh_connector.py: Brute-force attacks on SSH services.
  • smb_connector.py: Brute-force attacks on SMB services.
  • rdp_connector.py: Brute-force attacks on RDP services.
  • telnet_connector.py: Brute-force attacks on Telnet services.
  • sql_connector.py: Brute-force attacks on SQL services.

File Stealing Modules

  • steal_files_ftp.py: Steals files from FTP servers.
  • steal_files_smb.py: Steals files from SMB shares.
  • steal_files_ssh.py: Steals files from SSH servers.
  • steal_files_telnet.py: Steals files from Telnet servers.
  • steal_data_sql.py: Extracts data from SQL databases.

๐Ÿ“‡ Data Structure

Network Knowledge Base (netkb.csv)

Located at data/netkb.csv. Stores information about:

  • Known hosts and their status. (Alive or offline)
  • Open ports and vulnerabilities.
  • Action execution history. (Success or failed)

Preview Example:

Scan Results

Located in data/output/scan_results/.
This file is generated everytime the network is scanned. It is used to consolidate the data and update netkb.

Example:

Live Status (livestatus.csv)

Contains real-time information displayed on the e-Paper HAT:

  • Total number of known hosts.
  • Currently alive hosts.
  • Open ports count.
  • Other runtime statistics.

๐Ÿ“– Detailed Project Description

๐Ÿ‘€ Behavior of Bjorn

Once launched, Bjorn performs the following steps:

  1. Initialization: Loads configuration, initializes shared data, and sets up necessary components such as the e-Paper HAT display.
  2. Network Scanning: Scans the network to identify live hosts and open ports. Updates the network knowledge base (netkb) with the results.
  3. Orchestration: Orchestrates different actions based on the configuration and network knowledge base. This includes performing vulnerability scanning, attacks, and file stealing.
  4. Vulnerability Scanning: Performs vulnerability scans on identified hosts and updates the vulnerability summary.
  5. Brute-Force Attacks and File Stealing: Starts brute-force attacks and steals files based on the configuration criteria.
  6. Display Updates: Continuously updates the e-Paper HAT display with current information such as network status, vulnerabilities, and various statistics. Bjorn also displays random comments based on different themes and statuses.
  7. Web Server: Provides a web interface for monitoring and interacting with Bjorn.

โ–ถ๏ธ Running Bjorn

๐Ÿ“— Manual Start

To manually start Bjorn (without the service, ensure the service is stopped ยซย sudo systemctl stop bjorn.serviceย ยป):

bash
cd /home/bjorn/Bjorn

# Run Bjorn
sudo python Bjorn.py

๐Ÿ•น๏ธ Service Control

Control the Bjorn service:

bash
# Start Bjorn
sudo systemctl start bjorn.service

# Stop Bjorn
sudo systemctl stop bjorn.service

# Check status
sudo systemctl status bjorn.service

# View logs
sudo journalctl -u bjorn.service

๐Ÿช„ Fresh Start

To reset Bjorn to a clean state:

bash
sudo rm -rf /home/bjorn/Bjorn/config/*.json \
    /home/bjorn/Bjorn/data/*.csv \
    /home/bjorn/Bjorn/data/*.log \
    /home/bjorn/Bjorn/data/output/data_stolen/* \
    /home/bjorn/Bjorn/data/output/crackedpwd/* \
    /home/bjorn/Bjorn/config/* \
    /home/bjorn/Bjorn/data/output/scan_results/* \
    /home/bjorn/Bjorn/__pycache__ \
    /home/bjorn/Bjorn/config/__pycache__ \
    /home/bjorn/Bjorn/data/__pycache__ \
    /home/bjorn/Bjorn/actions/__pycache__ \
    /home/bjorn/Bjorn/resources/__pycache__ \
    /home/bjorn/Bjorn/web/__pycache__ \
    /home/bjorn/Bjorn/*.log \
    /home/bjorn/Bjorn/resources/waveshare_epd/__pycache__ \
    /home/bjorn/Bjorn/data/logs/* \
    /home/bjorn/Bjorn/data/output/vulnerabilities/* \
    /home/bjorn/Bjorn/data/logs/*

Everything will be recreated automatically at the next launch of Bjorn.

โ‡๏ธ Important Configuration Files

๐Ÿ”— Shared Configuration (`shared_config.json`)

Defines various settings for Bjorn, including:

  • Boolean settings (manual_mode, websrv, debug_mode, etc.).
  • Time intervals and delays.
  • Network settings.
  • Port lists and blacklists.
    These settings are accessible on the webpage.

๐Ÿ› ๏ธ Actions Configuration (`actions.json`)

Lists the actions to be performed by Bjorn, including (dynamically generated with the content of the folder):

  • Module and class definitions.
  • Port assignments.
  • Parent-child relationships.
  • Action status definitions.

๐Ÿ“Ÿ E-Paper Display Support

Currently, hardcoded for the 2.13-inch V2 & V4 e-Paper HAT.
My program automatically detect the screen model and adapt the python expressions into my code.

For other versions:

  • As I don't have the v1 and v3 to validate my algorithm, I just hope it will work properly.

๐Ÿพ Ghosting Removed!

In my journey to make Bjorn work with the different screen versions, I struggled, hacking several parameters and found out that it was possible to remove the ghosting of screens! I let you see this, I think this method will be very useful for all other projects with the e-paper screen!

โœ๏ธ Development Guidelines

โž• Adding New Actions

  1. Create a new action file in actions/.
  2. Implement required methods:
    • __init__(self, shared_data)
    • execute(self, ip, port, row, status_key)
  3. Add the action to actions.json.
  4. Follow existing action patterns.

๐Ÿงช Testing

  1. Create a test environment.
  2. Use an isolated network.
  3. Follow ethical guidelines.
  4. Document test cases.

๐Ÿ’ป Web Interface

  • Access: http://[device-ip]:8000
  • Features:
    • Real-time monitoring with a console.
    • Configuration management.
    • Viewing results. (Credentials and files)
    • System control.

๐Ÿงญ Project Roadmap

๐Ÿช› Current Focus

  • Stability improvements.
  • Bug fixes.
  • Service reliability.
  • Documentation updates.

๐Ÿงท Future Plans

  • Additional attack modules.
  • Enhanced reporting.
  • Improved user interface.
  • Extended protocol support.

๐Ÿ“œ License

2024 - Bjorn is distributed under the MIT License. For more details, please refer to the LICENSE file included in this repository.


File: INSTALL.md

๐Ÿ”ง Installation and Configuration

๐Ÿ“š Table of Contents

Use Raspberry Pi Imager to install your OS
https://www.raspberrypi.com/software/

๐Ÿ“Œ Prerequisites for RPI zero W (32bits)

  • Raspberry Pi OS installed.
    • Stable:
      • System: 32-bit
      • Kernel version: 6.6
      • Debian version: 12 (bookworm) '2024-10-22-raspios-bookworm-armhf-lite'
  • Username and hostname set to bjorn.
  • 2.13-inch e-Paper HAT connected to GPIO pins.

๐Ÿ“Œ Prerequisites for RPI zero W2 (64bits)

I did not develop Bjorn for the raspberry pi zero w2 64bits, but several feedbacks have attested that the installation worked perfectly.

  • Raspberry Pi OS installed.
    • Stable:
      • System: 64-bit
      • Kernel version: 6.6
      • Debian version: 12 (bookworm) '2024-10-22-raspios-bookworm-arm64-lite'
  • Username and hostname set to bjorn.
  • 2.13-inch e-Paper HAT connected to GPIO pins.

At the moment the paper screen v2 v4 have been tested and implemented.
I juste hope the V1 & V3 will work the same.

โšก Quick Install

The fastest way to install Bjorn is using the automatic installation script :

bash
# Download and run the installer
wget https://raw.githubusercontent.com/infinition/Bjorn/refs/heads/main/install_bjorn.sh
sudo chmod +x install_bjorn.sh
sudo ./install_bjorn.sh
# Choose the choice 1 for automatic installation. It may take a while as a lot of packages and modules will be installed. You must reboot at the end.

๐Ÿงฐ Manual Install

Step 1: Activate SPI & I2C

bash
sudo raspi-config
  • Navigate to "Interface Options".
  • Enable SPI.
  • Enable I2C.

Step 2: System Dependencies

bash
# Update system
sudo apt-get update && sudo apt-get upgrade -y

# Install required packages

 sudo apt install -y \
  libjpeg-dev \
  zlib1g-dev \
  libpng-dev \
  python3-dev \
  libffi-dev \
  libssl-dev \
  libgpiod-dev \
  libi2c-dev \
  libatlas-base-dev \
  build-essential \
  python3-pip \
  wget \
  lsof \
  git \
  libopenjp2-7 \
  nmap \
  libopenblas-dev \
  bluez-tools \
  bluez \
  dhcpcd5 \
  bridge-utils \
  python3-pil


# Update Nmap scripts database

sudo nmap --script-updatedb

Step 3: Bjorn Installation

bash
# Clone the Bjorn repository
cd /home/bjorn
git clone https://github.com/infinition/Bjorn.git
cd Bjorn

# Install Python dependencies within the virtual environment
sudo pip install -r requirements.txt --break-system-packages
# As i did not succeed "for now" to get a stable installation with a virtual environment, i installed the dependencies system wide (with --break-system-packages), it did not cause any issue so far. You can try to install them in a virtual environment if you want.

3.1: Configure E-Paper Display Type

Choose your e-Paper HAT version by modifying the configuration file:

  1. Open the configuration file:
bash
sudo vi /home/bjorn/Bjorn/config/shared_config.json

Press i to enter insert mode
Locate the line containing "epd_type":
Change the value according to your screen model:

  • For 2.13 V1: "epd_type": "epd2in13",
  • For 2.13 V2: "epd_type": "epd2in13_V2",
  • For 2.13 V3: "epd_type": "epd2in13_V3",
  • For 2.13 V4: "epd_type": "epd2in13_V4",

Press Esc to exit insert mode
Type :wq and press Enter to save and quit

Step 4: Configure File Descriptor Limits

To prevent OSError: [Errno 24] Too many open files, it's essential to increase the file descriptor limits.

4.1: Modify File Descriptor Limits for All Users

Edit /etc/security/limits.conf:

bash
sudo vi /etc/security/limits.conf

Add the following lines:

text
* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535

4.2: Configure Systemd Limits

Edit /etc/systemd/system.conf:

bash
sudo vi /etc/systemd/system.conf

Uncomment and modify:

text
DefaultLimitNOFILE=65535

Edit /etc/systemd/user.conf:

bash
sudo vi /etc/systemd/user.conf

Uncomment and modify:

text
DefaultLimitNOFILE=65535

4.3: Create or Modify `/etc/security/limits.d/90-nofile.conf`

bash
sudo vi /etc/security/limits.d/90-nofile.conf

Add:

text
root soft nofile 65535
root hard nofile 65535

4.4: Adjust the System-wide File Descriptor Limit

Edit /etc/sysctl.conf:

bash
sudo vi /etc/sysctl.conf

Add:

text
fs.file-max = 2097152

Apply the changes:

bash
sudo sysctl -p

Step 5: Reload Systemd and Apply Changes

Reload systemd to apply the new file descriptor limits:

bash
sudo systemctl daemon-reload

Step 6: Modify PAM Configuration Files

PAM (Pluggable Authentication Modules) manages how limits are enforced for user sessions. To ensure that the new file descriptor limits are respected, update the following configuration files.

Step 6.1: Edit `/etc/pam.d/common-session` and `/etc/pam.d/common-session-noninteractive`

bash
sudo vi /etc/pam.d/common-session
sudo vi /etc/pam.d/common-session-noninteractive

Add this line at the end of both files:

text
session required pam_limits.so

This ensures that the limits set in /etc/security/limits.conf are enforced for all user sessions.

Step 7: Configure Services

7.1: Bjorn Service

Create the service file:

bash
sudo vi /etc/systemd/system/bjorn.service

Add the following content:

ini
[Unit]
Description=Bjorn Service
DefaultDependencies=no
Before=basic.target
After=local-fs.target

[Service]
ExecStartPre=/home/bjorn/Bjorn/kill_port_8000.sh
ExecStart=/usr/bin/python3 /home/bjorn/Bjorn/Bjorn.py
WorkingDirectory=/home/bjorn/Bjorn
StandardOutput=inherit
StandardError=inherit
Restart=always
User=root

# Check open files and restart if it reached the limit (ulimit -n buffer of 1000)
ExecStartPost=/bin/bash -c 'FILE_LIMIT=$(ulimit -n); THRESHOLD=$(( FILE_LIMIT - 1000 )); while :; do TOTAL_OPEN_FILES=$(lsof | wc -l); if [ "$TOTAL_OPEN_FILES" -ge "$THRESHOLD" ]; then echo "File descriptor threshold reached: $TOTAL_OPEN_FILES (threshold: $THRESHOLD). Restarting service."; systemctl restart bjorn.service; exit 0; fi; sleep 10; done &'

[Install]
WantedBy=multi-user.target

7.2: Port 8000 Killer Script

Create the script to free up port 8000:

bash
vi /home/bjorn/Bjorn/kill_port_8000.sh

Add:

bash
#!/bin/bash
PORT=8000
PIDS=$(lsof -t -i:$PORT)

if [ -n "$PIDS" ]; then
    echo "Killing PIDs using port $PORT: $PIDS"
    kill -9 $PIDS
fi

Make the script executable:

bash
chmod +x /home/bjorn/Bjorn/kill_port_8000.sh

7.3: USB Gadget Configuration

Modify /boot/firmware/cmdline.txt:

bash
sudo vi /boot/firmware/cmdline.txt

Add the following right after rootwait:

text
modules-load=dwc2,g_ether

Modify /boot/firmware/config.txt:

bash
sudo vi /boot/firmware/config.txt

Add at the end of the file:

text
dtoverlay=dwc2

Create the USB gadget script:

bash
sudo vi /usr/local/bin/usb-gadget.sh

Add the following content:

bash
#!/bin/bash
set -e

modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir -p g1
cd g1

echo 0x1d6b > idVendor
echo 0x0104 > idProduct
echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB

mkdir -p strings/0x409
echo "fedcba9876543210" > strings/0x409/serialnumber
echo "Raspberry Pi" > strings/0x409/manufacturer
echo "Pi Zero USB" > strings/0x409/product

mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower

mkdir -p functions/ecm.usb0

# Check for existing symlink and remove if necessary
if [ -L configs/c.1/ecm.usb0 ]; then
    rm configs/c.1/ecm.usb0
fi
ln -s functions/ecm.usb0 configs/c.1/

# Ensure the device is not busy before listing available USB device controllers
max_retries=10
retry_count=0

while ! ls /sys/class/udc > UDC 2>/dev/null; do
    if [ $retry_count -ge $max_retries ]; then
        echo "Error: Device or resource busy after $max_retries attempts."
        exit 1
    fi
    retry_count=$((retry_count + 1))
    sleep 1
done

# Check if the usb0 interface is already configured
if ! ip addr show usb0 | grep -q "172.20.2.1"; then
    ifconfig usb0 172.20.2.1 netmask 255.255.255.0
else
    echo "Interface usb0 already configured."
fi

Make the script executable:

bash
sudo chmod +x /usr/local/bin/usb-gadget.sh

Create the systemd service:

bash
sudo vi /etc/systemd/system/usb-gadget.service

Add:

ini
[Unit]
Description=USB Gadget Service
After=network.target

[Service]
ExecStartPre=/sbin/modprobe libcomposite
ExecStart=/usr/local/bin/usb-gadget.sh
Type=simple
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Configure usb0:

bash
sudo vi /etc/network/interfaces

Add:

bash
allow-hotplug usb0
iface usb0 inet static
    address 172.20.2.1
    netmask 255.255.255.0

Reload the services:

bash
sudo systemctl daemon-reload
sudo systemctl enable systemd-networkd
sudo systemctl enable usb-gadget
sudo systemctl start systemd-networkd
sudo systemctl start usb-gadget

You must reboot to be able to use it as a USB gadget (with ip)

Windows PC Configuration

Set the static IP address on your Windows PC:

  • IP Address: 172.20.2.2
  • Subnet Mask: 255.255.255.0
  • Default Gateway: 172.20.2.1
  • DNS Servers: 8.8.8.8, 8.8.4.4

๐Ÿ“œ License

2024 - Bjorn is distributed under the MIT License. For more details, please refer to the LICENSE file included in this repository.


File: requirements.txt

RPi.GPIO==0.7.1
spidev==3.5
Pillow==9.4.0
numpy==2.1.3
rich==13.9.4
pandas==2.2.3
netifaces==0.11.0
ping3==4.0.8
get-mac==0.9.2
paramiko==3.5.0
smbprotocol==1.14.0
pysmb==1.2.10
pymysql==1.1.1
sqlalchemy==2.0.36
python-nmap==0.7.1


File: SECURITY.md

๐Ÿ”’ Security Policy

Security Policy for Bjorn repository includes all required compliance matrix and artifact mapping.

๐Ÿงฎ Supported Versions

We provide security updates for the following versions of our project:

Version Status Secure
1.0.0 Development No

๐Ÿ›ก๏ธ Security Practices

  • We follow best practices for secure coding and infrastructure management.
  • Regular security audits and code reviews are conducted to identify and mitigate potential risks.
  • Dependencies are monitored and updated to address known vulnerabilities.

๐Ÿ“ฒ Security Updates

  • Security updates are released as soon as possible after a vulnerability is confirmed.
  • Users are encouraged to update to the latest version to benefit from security fixes.

๐Ÿšจ Reporting a Vulnerability

If you discover a security vulnerability within this project, please follow these steps:

  1. Do not create a public issue. Instead, contact us directly to responsibly disclose the vulnerability.

  2. Email [email protected] with the following information:

    • A description of the vulnerability.
    • Steps to reproduce the issue.
    • Any potential impact or severity.
  3. Wait for a response. We will acknowledge your report and work with you to address the issue promptly.

๐Ÿ›ฐ๏ธ Additional Resources

Thank you for helping us keep this project secure!


๐Ÿ“œ License

2024 - Bjorn is distributed under the MIT License. For more details, please refer to the LICENSE file included in this repository.


File: TROUBLESHOOTING.md

๐Ÿ› Known Issues and Troubleshooting

๐Ÿ“š Table of Contents

๐Ÿชฒ Current Development Issues

Long Runtime Issue

  • Problem: OSError: [Errno 24] Too many open files
  • Status: Partially resolved with system limits configuration.
  • Workaround: Implemented file descriptor limits increase.
  • Monitoring: Check open files with lsof -p $(pgrep -f Bjorn.py) | wc -l
  • At the moment the logs show periodically this information as (FD : XXX)

๐Ÿ› ๏ธ Troubleshooting Steps

Service Issues

bash
#See bjorn journalctl service
journalctl -fu bjorn.service

# Check service status
sudo systemctl status bjorn.service

# View detailed logs
sudo journalctl -u bjorn.service -f

or

sudo tail -f /home/bjorn/Bjorn/data/logs/*


# Check port 8000 usage
sudo lsof -i :8000

Display Issues

bash
# Verify SPI devices
ls /dev/spi*

# Check user permissions
sudo usermod -a -G spi,gpio bjorn

Network Issues

bash
# Check network interfaces
ip addr show

# Test USB gadget interface
ip link show usb0

Permission Issues

bash
# Fix ownership
sudo chown -R bjorn:bjorn /home/bjorn/Bjorn

# Fix permissions
sudo chmod -R 755 /home/bjorn/Bjorn

๐Ÿ“œ License

2024 - Bjorn is distributed under the MIT License. For more details, please refer to the LICENSE file included in this repository.


File: version.txt

1.0.0 alpha 2


File: config/shared_config.json

{
"title_Bjorn": "Settings",
"manual_mode": false,
"websrv": true,
"web_increment ": false,
"debug_mode": true,
"scan_vuln_running": false,
"retry_success_actions": false,
"retry_failed_actions": true,
"blacklistcheck": true,
"displaying_csv": true,
"log_debug": true,
"log_info": true,
"log_warning": true,
"log_error": true,
"log_critical": true,
"startup_delay": 10,
"web_delay": 2,
"screen_delay": 1,
"comment_delaymin": 15,
"comment_delaymax": 30,
"livestatus_delay": 8,
"image_display_delaymin": 2,
"image_display_delaymax": 8,
"scan_interval": 180,
"scan_vuln_interval": 900,
"failed_retry_delay": 600,
"success_retry_delay": 900,
"ref_width": 122,
"ref_height": 250,
"epd_type": "epd2in13_V4",
"title_lists": "List Settings",
"portlist": [
20,
21,
22,
23,
25,
53,
69,
80,
110,
111,
135,
137,
139,
143,
161,
162,
389,
443,
445,
512,
513,
514,
587,
636,
993,
995,
1080,
1433,
1521,
2049,
3306,
3389,
5000,
5001,
5432,
5900,
8080,
8443,
9090,
10000
],
"mac_scan_blacklist": [
"00:11:32:c4:71:9b",
"00:11:32:c4:71:9a"
],
"ip_scan_blacklist": [
"192.168.1.1",
"192.168.1.12",
"192.168.1.38",
"192.168.1.53",
"192.168.1.40",
"192.168.1.29"
],
"steal_file_names": [
"ssh.csv",
"hack.txt"
],
"steal_file_extensions": [
".bjorn",
".hack",
".flag"
],
"title_network": "Network",
"nmap_scan_aggressivity": "-T2",
"portstart": 1,
"portend": 2,
"title_timewaits": "Time Wait Settings",
"timewait_smb": 0,
"timewait_ssh": 0,
"timewait_telnet": 0,
"timewait_ftp": 0,
"timewait_sql": 0,
"timewait_rdp": 0
}


File: data/input/dictionary/passwords.txt

root
admin
bjorn


File: data/input/dictionary/users.txt

root
admin
bjorn


File: web/manifest.json

{
"name": "Bjorn Cyberviking",
"short_name": "Bjorn",
"description": "Bjorn Cyberviking",
"start_url": "/index.html",
"display": "standalone",
"background_color": "#333",
"theme_color": "#333",
"icons": [
{
"src": "images/icon-60x60.png",
"sizes": "60x60",
"type": "image/png"
},
{
"src": "images/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "images/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "images/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "images/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "images/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "images/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "images/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}


File: .github/dependabot.yml

.github/dependabot.yml

version: 2
updates:

  • package-ecosystem: "pip"
    directory: "."
    schedule:
    interval: "weekly"
    commit-message:
    prefix: "fix(deps)"
    open-pull-requests-limit: 5
    target-branch: "dev"

File: .github/FUNDING.yml

These are supported funding model platforms

#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
#patreon: # Replace with a single Patreon username
#open_collective: # Replace with a single Open Collective username
#ko_fi: # Replace with a single Ko-fi username
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
#liberapay: # Replace with a single Liberapay username
#issuehunt: # Replace with a single IssueHunt username
#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
#polar: # Replace with a single Polar username
buy_me_a_coffee: infinition
#thanks_dev: # Replace with a single thanks.dev username
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']


File: .github/ISSUE_TEMPLATE/bug_report.md


name: Bug report about: Create a report to help us improve title: "" labels: "" assignees: ""

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Hardware (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.


File: .github/ISSUE_TEMPLATE/config.yml


.github/ISSUE_TEMPLATE/config.yml

blank_issues_enabled: false
contact_links:


File: .github/ISSUE_TEMPLATE/feature_request.md


name: Feature request about: Suggest an idea for this project title: "" labels: "" assignees: ""

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.