From 9e9383eeef57ef7d68f496270f7f5be3dc554623 Mon Sep 17 00:00:00 2001 From: n0mad1k Date: Thu, 1 May 2025 22:39:02 -0400 Subject: [PATCH] fixed payload sync and motd --- files/secure_payload_sync.sh | 2 +- files/setup_payload_sync.sh | 54 ------------------- tasks/configure_c2.yml | 46 ++++++++++++++++ tasks/configure_redirector.yml | 16 ++++++ templates/motd-redirector.j2 | 16 ++++++ .../redirector-site-with-tracker.conf.j2 | 4 +- templates/redirector-site.conf.j2 | 4 +- 7 files changed, 83 insertions(+), 59 deletions(-) delete mode 100644 files/setup_payload_sync.sh create mode 100644 templates/motd-redirector.j2 diff --git a/files/secure_payload_sync.sh b/files/secure_payload_sync.sh index bd7c73c..1d1f3e3 100644 --- a/files/secure_payload_sync.sh +++ b/files/secure_payload_sync.sh @@ -6,7 +6,7 @@ C2_PAYLOAD_DIR="/root/Tools/Havoc/payloads" REDIRECTOR_IP="{{ redirector_ip }}" REDIRECTOR_USER="root" SSH_KEY_PATH="/root/.ssh/id_ed25519" -REMOTE_PAYLOAD_DIR="/var/www/payloads" +REMOTE_PAYLOAD_DIR="/var/www/resources" ENCRYPTED_TRANSFER=true LOG_FILE="/root/Tools/logs/payload_sync.log" LOG_RETENTION_DAYS=3 diff --git a/files/setup_payload_sync.sh b/files/setup_payload_sync.sh deleted file mode 100644 index c739c69..0000000 --- a/files/setup_payload_sync.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# setup_payload_sync.sh - Configure systemd service and timer - -# Create systemd service file -cat > /etc/systemd/system/payload-sync.service << EOF -[Unit] -Description=Secure Payload Sync Service -After=network-online.target -Wants=network-online.target - -[Service] -Type=oneshot -ExecStart=/root/Tools/secure_payload_sync.sh -User=root -Group=root -# Security hardening -PrivateTmp=true -ProtectSystem=full -NoNewPrivileges=true -# Hide process information -StandardOutput=null -StandardError=journal - -[Install] -WantedBy=multi-user.target -EOF - -# Create systemd timer with randomized schedule -cat > /etc/systemd/system/payload-sync.timer << EOF -[Unit] -Description=Secure Payload Sync Timer -Requires=payload-sync.service - -[Timer] -# Run every 30-60 minutes with randomization -OnBootSec=5min -OnUnitActiveSec=30m -RandomizedDelaySec=30m -Persistent=true - -[Install] -WantedBy=timers.target -EOF - -# Copy script to proper location -cp secure_payload_sync.sh /root/Tools/ -chmod 700 /root/Tools/secure_payload_sync.sh - -# Enable and start timer -systemctl daemon-reload -systemctl enable payload-sync.timer -systemctl start payload-sync.timer - -echo "Payload sync service installed and timer started" \ No newline at end of file diff --git a/tasks/configure_c2.yml b/tasks/configure_c2.yml index a5a26b9..8c4d83f 100644 --- a/tasks/configure_c2.yml +++ b/tasks/configure_c2.yml @@ -6,6 +6,13 @@ apt: update_cache: yes +- name: Disable default Kali MOTD + file: + path: "{{ ansible_env.HOME }}/.hushlogin" + state: touch + mode: '0644' + when: ansible_distribution == "Kali GNU/Linux" + - name: Set a custom MOTD template: src: "../templates/motd.j2" @@ -106,6 +113,7 @@ - "../files/secure-exit.sh" - "../files/havoc_installer.sh" - "../files/havoc_shell_handler.sh" + - "../files/secure_payload_sync.sh" - name: Copy post-install script copy: @@ -131,6 +139,44 @@ owner: root group: root +- name: Set up systemd timer for payload sync + shell: | + cat > /etc/systemd/system/payload-sync.service << 'EOF' + [Unit] + Description=Secure Payload Sync Service + After=network-online.target + + [Service] + Type=oneshot + ExecStart=/root/Tools/secure_payload_sync.sh + User=root + Group=root + PrivateTmp=true + StandardOutput=null + + [Install] + WantedBy=multi-user.target + EOF + + cat > /etc/systemd/system/payload-sync.timer << 'EOF' + [Unit] + Description=Secure Payload Sync Timer + Requires=payload-sync.service + + [Timer] + OnBootSec=5min + OnUnitActiveSec=30m + RandomizedDelaySec=30m + Persistent=true + + [Install] + WantedBy=timers.target + EOF + + systemctl daemon-reload + systemctl enable payload-sync.timer + systemctl start payload-sync.timer + - name: Install Havoc C2 Framework shell: "/root/Tools/havoc_installer.sh" args: diff --git a/tasks/configure_redirector.yml b/tasks/configure_redirector.yml index 34df95d..ba872e4 100644 --- a/tasks/configure_redirector.yml +++ b/tasks/configure_redirector.yml @@ -2,6 +2,14 @@ # Common task for configuring redirector with full encryption # Shared across all providers +- name: Set a custom MOTD + template: + src: "../templates/motd-redirector.j2" + dest: /etc/motd + owner: root + group: root + mode: '0644' + - name: Install required packages for redirector apt: name: @@ -111,6 +119,14 @@ group: root when: zero_logs | bool +- name: Create payload directory + file: + path: /var/www/resources + state: directory + mode: '0755' + owner: www-data + group: www-data + # Run port randomization if enabled - name: Run port randomization if enabled include_tasks: port_randomization.yml diff --git a/templates/motd-redirector.j2 b/templates/motd-redirector.j2 new file mode 100644 index 0000000..84d0312 --- /dev/null +++ b/templates/motd-redirector.j2 @@ -0,0 +1,16 @@ +================================================================ +C2itall Redirector Post-Installation Instructions +================================================================ + +To complete your setup with SSL certificates, run: + /root/Tools/post_install_redirector.sh + +This script will guide you through: +- Setting up Let's Encrypt certificates +- Starting required services +- Updating NGINX configuration + +For enhanced OPSEC, you can also randomize ports: + /root/Tools/randomize_ports.sh + +Run these after you've configured your DNS records to point to this server. diff --git a/templates/redirector-site-with-tracker.conf.j2 b/templates/redirector-site-with-tracker.conf.j2 index 2a51915..4d8a323 100644 --- a/templates/redirector-site-with-tracker.conf.j2 +++ b/templates/redirector-site-with-tracker.conf.j2 @@ -58,8 +58,8 @@ server { } # Secure payload delivery path for synced payloads - location /payloads/ { - alias /var/www/payloads/; + location /resources/ { + alias /var/www/resources/; limit_except GET { deny all; } add_header X-Content-Type-Options "nosniff" always; add_header Content-Security-Policy "default-src 'none'" always; diff --git a/templates/redirector-site.conf.j2 b/templates/redirector-site.conf.j2 index 97bd32b..3303aae 100644 --- a/templates/redirector-site.conf.j2 +++ b/templates/redirector-site.conf.j2 @@ -58,8 +58,8 @@ server { } # Secure payload delivery path for synced payloads - location /payloads/ { - alias /var/www/payloads/; + location /resources/ { + alias /var/www/resources/; limit_except GET { deny all; } add_header X-Content-Type-Options "nosniff" always; add_header Content-Security-Policy "default-src 'none'" always;