Skip to content
Merged
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Changelog

# develop

# [v1.2.1](https://github.com/carvilsi/caetra/releases/tag/v1.2.1) (2026-07-17)

- Refactor to import as a module
- Adds name of HID for hid_interact shield

# [v1.2.0](https://github.com/carvilsi/caetra/releases/tag/v1.2.0) (2026-03-18)
Expand Down
15 changes: 7 additions & 8 deletions caetra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
import threading
import subprocess
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), "./src/utils/"))
sys.path.append(os.path.join(os.path.dirname(__file__), "./src/"))

from logger_setup import logger
from config_parser import config
import constants
from src.utils.logger_setup import logger
from src.utils.config_parser import config
import src.constants as constants


def run_script(script_name):
subprocess.run(["python3", script_name])
module = script_name[2:-3].replace(os.sep, ".")

subprocess.run(["python3", "-m", module])


# Threading execute all the shields under shield directory
Expand All @@ -27,6 +25,7 @@ def threading_excute_shields():
file.endswith(".py")
and file != constants.SHIELD_DEPLOYING_SCRIPT
and file != constants.SHIELD_STATUS_HANDLER_SCRIPT
and file != constants.PYTHON_MODULE_INIT
):
shieldname = os.path.splitext(file)[0]
if config["caetra"].get("shields_enabled") is not None:
Expand Down
Empty file added src/__init__.py
Empty file.
1 change: 1 addition & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SHIELD_PATH = "./src/shields/"
SHIELD_DEPLOYING_SCRIPT = "deploying.py"
SHIELD_STATUS_HANDLER_SCRIPT = "status_handler.py"
PYTHON_MODULE_INIT = "__init__.py"
SHIELD_CONFIG_EXT = ".toml"

CAETRA_SENDER_LABEL = "Shield"
Expand Down
Empty file added src/senders/__init__.py
Empty file.
6 changes: 1 addition & 5 deletions src/senders/send_canary_dns_token.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import base64
import socket
import re
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils/"))

from logger_setup import logger
from src.utils.logger_setup import logger

DOT = "."
MAGIC_STRING = "G69"
Expand Down
5 changes: 1 addition & 4 deletions src/senders/send_telegram_message_to_chat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import requests

import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
from logger_setup import logger
from src.utils.logger_setup import logger

HEADERS = {"Content-Type": "application/json"}

Expand Down
19 changes: 7 additions & 12 deletions src/senders/senders_handler.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
import constants
from config_parser import config
from logger_setup import logger
from caetra_exceptions import ConfigurationError
from dict_handler import validate_dict_structure
from send_canary_dns_token import send_canary
from send_telegram_message_to_chat import send_telegram
import src.constants as constants
from src.utils.config_parser import config
from src.utils.logger_setup import logger
from src.caetra_exceptions import ConfigurationError
from src.utils.dict_handler import validate_dict_structure
from src.senders.send_canary_dns_token import send_canary
from src.senders.send_telegram_message_to_chat import send_telegram


def check_send_config(senders_config):
Expand Down
Empty file added src/shields/__init__.py
Empty file.
Empty file.
25 changes: 8 additions & 17 deletions src/shields/ambient_light/ambient_light.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
# generic imports
import sys
import os

# caetra imports
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../senders"))
from shields import deploying
from logger_setup import logger_shields
from caetra_exceptions import (
from src.shields.shields_common import (
constants,
deploying,
send,
status_handler,
logger_shields,
log_shield_exception,
log_shield_exception_warn,
ShieldConfigurationError,
ConfigurationError,
MaxActionReached,
)
from logging_handler import log_shield_exception, log_shield_exception_warn
from senders_handler import send
import constants
import status_handler

# shield name
# must be same with in toml root config
Expand Down
Empty file.
26 changes: 10 additions & 16 deletions src/shields/blt_connect/blt_connect.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
# generic imports
import sys
import os

# caetra imports
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../senders"))
from shields import deploying
from logger_setup import logger_shields
from caetra_exceptions import ShieldConfigurationError, ConfigurationError
from logging_handler import log_shield_exception
from senders_handler import send
from format_utils import mac_address_format
import constants
from src.shields.shields_common import (
constants,
deploying,
log_shield_exception,
logger_shields,
mac_address_format,
send,
ConfigurationError,
ShieldConfigurationError,
)

# shield name
# must be same with in toml root config
Expand Down
Empty file.
26 changes: 10 additions & 16 deletions src/shields/blt_disconnect/blt_disconnect.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
# generic imports
import sys
import os

# caetra imports
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../senders"))
from shields import deploying
from logger_setup import logger_shields
from caetra_exceptions import ShieldConfigurationError, ConfigurationError
from logging_handler import log_shield_exception
from senders_handler import send
from format_utils import mac_address_format
import constants
from src.shields.shields_common import (
constants,
deploying,
log_shield_exception,
logger_shields,
mac_address_format,
send,
ConfigurationError,
ShieldConfigurationError,
)

# shield name
# must be same with in toml root config
Expand Down
Empty file.
27 changes: 9 additions & 18 deletions src/shields/cd_dvd_rom/cd_dvd_rom.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
# generic imports
import sys
import os

# caetra imports
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../senders"))
from shields import deploying
from logger_setup import logger_shields
from caetra_exceptions import (
ShieldConfigurationError,
from src.shields.shields_common import (
constants,
deploying,
log_shield_exception,
log_shield_exception_warn,
logger_shields,
send,
status_handler,
ConfigurationError,
MaxActionReached,
ShieldConfigurationError,
)
from logging_handler import log_shield_exception, log_shield_exception_warn
from senders_handler import send
import constants
import status_handler

# shield name
# must be same with in toml root config
Expand Down
11 changes: 4 additions & 7 deletions src/shields/deploying.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from bcc import BPF
from logger_setup import logger
import tomllib
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
import constants
from caetra_exceptions import ShieldConfigurationError
from dict_handler import validate_dict_structure
from src.utils.logger_setup import logger
import src.constants as constants
from src.caetra_exceptions import ShieldConfigurationError
from src.utils.dict_handler import validate_dict_structure


# returns a BPF program loaded and attached to kernel
Expand Down
Empty file.
26 changes: 8 additions & 18 deletions src/shields/hibernation/hibernation.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
# generic imports
import sys
import os

# caetra imports
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../senders"))
from shields import deploying
from logger_setup import logger_shields
from caetra_exceptions import (
ShieldConfigurationError,
from src.shields.shields_common import (
constants,
deploying,
log_shield_exception,
logger_shields,
send,
status_handler,
ConfigurationError,
MaxRetriesReached,
ShieldConfigurationError,
)
from logging_handler import log_shield_exception
from senders_handler import send
import constants
import status_handler

# shield name
# must be same with in toml root config
Expand Down
2 changes: 1 addition & 1 deletion src/shields/hibernation/hibernation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# if this shield is enable
# TODO: this is giving false positive
enable = false
enable = true


# a description that will logged
Expand Down
Empty file.
27 changes: 9 additions & 18 deletions src/shields/hid_add_remove/hid_add_remove.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
# generic imports
import sys
import os

# caetra imports
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../senders"))
from shields import deploying
from logger_setup import logger_shields
from caetra_exceptions import (
ShieldConfigurationError,
from src.shields.shields_common import (
constants,
deploying,
logger_shields,
log_shield_exception,
log_shield_exception_warn,
send,
status_handler,
ConfigurationError,
MaxActionReached,
ShieldConfigurationError,
ShieldKernelSpaceCError,
)
from logging_handler import log_shield_exception, log_shield_exception_warn
from senders_handler import send
import constants
import status_handler

# from linux/hid.h
HID_TYPE = {
Expand Down
Empty file.
27 changes: 9 additions & 18 deletions src/shields/hid_interact/hid_interact.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
# generic imports
import sys
import os

# caetra imports
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../senders"))
from shields import deploying
from logger_setup import logger_shields
from caetra_exceptions import (
ShieldConfigurationError,
from src.shields.shields_common import (
constants,
deploying,
logger_shields,
log_shield_exception,
log_shield_exception_warn,
send,
status_handler,
ConfigurationError,
MaxActionReached,
ShieldConfigurationError,
)
from logging_handler import log_shield_exception, log_shield_exception_warn
from senders_handler import send
import constants
import status_handler

# from linux/hid.h
HID_TYPE = {
Expand Down
Empty file added src/shields/inet/__init__.py
Empty file.
29 changes: 10 additions & 19 deletions src/shields/inet/inet.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
# generic imports
import sys
import os

# caetra imports
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../utils"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../senders"))
from shields import deploying
from logger_setup import logger_shields
from caetra_exceptions import (
ShieldConfigurationError,
from src.shields.shields_common import (
constants,
deploying,
logger_shields,
log_shield_exception,
log_shield_exception_warn,
mac_address_format,
send,
status_handler,
ConfigurationError,
MaxActionReached,
MaxRetriesReached,
NoInternetConnection,
ShieldConfigurationError,
)
from logging_handler import log_shield_exception, log_shield_exception_warn
from senders_handler import send
from format_utils import mac_address_format
import constants
import status_handler

# from linux/netdevice.h
# only interesting events
Expand Down
Empty file.
Loading