working on aws
This commit is contained in:
+48
-12
@@ -53,6 +53,12 @@
|
||||
ami_id: "{{ ami_map[aws_c2_region] }}"
|
||||
when: ami_map is defined and aws_c2_region in ami_map
|
||||
|
||||
# Add AMI username mapping
|
||||
- name: Determine correct SSH user for the AMI
|
||||
set_fact:
|
||||
ami_ssh_user: >-
|
||||
{% if ami_id == 'ami-061b17d332829ab1c' %}kali{% else %}ubuntu{% endif %}
|
||||
|
||||
- name: Create EC2 key pair
|
||||
amazon.aws.ec2_key:
|
||||
name: "{{ c2_name }}"
|
||||
@@ -206,40 +212,70 @@
|
||||
name: "c2"
|
||||
groups: "c2servers"
|
||||
ansible_host: "{{ c2_ip }}"
|
||||
ansible_user: "{{ ssh_user }}"
|
||||
ansible_user: "{{ ami_ssh_user | default('kali') }}"
|
||||
ansible_ssh_private_key_file: "~/.ssh/{{ c2_name }}.pem"
|
||||
ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes"
|
||||
ansible_python_interpreter: "/usr/bin/python3"
|
||||
|
||||
# Rest of the playbook for configuring the C2 server
|
||||
# Configure C2 server with a proper structure
|
||||
- name: Configure C2 server
|
||||
hosts: c2servers
|
||||
become: true
|
||||
gather_facts: true
|
||||
vars_files:
|
||||
- vars.yaml
|
||||
become: yes
|
||||
vars:
|
||||
redirector_ip: "{{ hostvars['localhost']['redirector_ip'] | default('127.0.0.1') }}"
|
||||
c2_subdomain: "{{ c2_subdomain | default('mail') }}"
|
||||
|
||||
# Include the rest of your C2 configuration tasks here
|
||||
tasks:
|
||||
- name: Download Kali archive keyring to temporary location
|
||||
get_url:
|
||||
url: https://archive.kali.org/archive-keyring.gpg
|
||||
dest: /tmp/kali-archive-keyring.gpg
|
||||
mode: "0644"
|
||||
force: yes
|
||||
register: keyring_download
|
||||
|
||||
- name: Install Kali archive keyring
|
||||
command: install -m 0644 /tmp/kali-archive-keyring.gpg /usr/share/keyrings/kali-archive-keyring.gpg
|
||||
when: keyring_download is changed
|
||||
|
||||
- name: Wait for apt to be available
|
||||
apt:
|
||||
update_cache: yes
|
||||
register: apt_result
|
||||
until: apt_result is success
|
||||
retries: 5
|
||||
retries: 10
|
||||
delay: 10
|
||||
|
||||
- name: Install Rust compiler
|
||||
apt:
|
||||
name:
|
||||
- cargo
|
||||
- rustc
|
||||
- libssl-dev
|
||||
- pkg-config
|
||||
state: present
|
||||
register: rust_install
|
||||
until: rust_install is success
|
||||
retries: 3
|
||||
delay: 5
|
||||
|
||||
- name: Clean up any failed pipx installations
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- "/root/.local/state/pipx/venvs/netexec"
|
||||
- "/root/.local/state/pipx/venvs/trevorspray"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Include common tool installation tasks
|
||||
include_tasks: "../tasks/install_tools.yml"
|
||||
|
||||
|
||||
- name: Include common C2 configuration tasks
|
||||
include_tasks: "../tasks/configure_c2.yml"
|
||||
|
||||
|
||||
- name: Include common security hardening tasks
|
||||
include_tasks: "../tasks/security_hardening.yml"
|
||||
|
||||
|
||||
- name: Include common mail server configuration tasks
|
||||
include_tasks: "../tasks/configure_mail.yml"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user