Initial release: ghost_protocol privacy toolkit
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
---
|
||||
# Provision an AWS EC2 instance for phantom deployment
|
||||
# Requires: aws_access_key, aws_secret_key variables
|
||||
|
||||
- name: Provision AWS EC2 Instance
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
vars:
|
||||
aws_region: "{{ region | default('us-east-1') }}"
|
||||
ec2_instance_type: "{{ instance_type | default('t3.micro') }}"
|
||||
ec2_ami: "{{ ami | default('') }}"
|
||||
ec2_key_name: "phantom-{{ deploy_id }}"
|
||||
ssh_key_path: "{{ ssh_key }}.pub"
|
||||
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
||||
AWS_DEFAULT_REGION: "{{ aws_region }}"
|
||||
|
||||
tasks:
|
||||
- name: Read SSH public key
|
||||
slurp:
|
||||
src: "{{ ssh_key_path }}"
|
||||
register: ssh_pubkey
|
||||
|
||||
- name: Import SSH key to AWS
|
||||
amazon.aws.ec2_key:
|
||||
name: "{{ ec2_key_name }}"
|
||||
key_material: "{{ ssh_pubkey.content | b64decode | trim }}"
|
||||
region: "{{ aws_region }}"
|
||||
|
||||
- name: Find latest Debian AMI (if not specified)
|
||||
amazon.aws.ec2_ami_info:
|
||||
region: "{{ aws_region }}"
|
||||
owners: ["136693071363"]
|
||||
filters:
|
||||
name: "debian-12-amd64-*"
|
||||
architecture: x86_64
|
||||
virtualization-type: hvm
|
||||
register: ami_results
|
||||
when: ec2_ami == ""
|
||||
|
||||
- name: Set AMI fact
|
||||
set_fact:
|
||||
ec2_ami: "{{ (ami_results.images | sort(attribute='creation_date') | last).image_id }}"
|
||||
when: ec2_ami == ""
|
||||
|
||||
- name: Create security group
|
||||
amazon.aws.ec2_security_group:
|
||||
name: "phantom-{{ deploy_id }}"
|
||||
description: "phantom deployment {{ deploy_id }}"
|
||||
region: "{{ aws_region }}"
|
||||
rules:
|
||||
- proto: tcp
|
||||
from_port: 22
|
||||
to_port: 22
|
||||
cidr_ip: 0.0.0.0/0
|
||||
- proto: tcp
|
||||
from_port: 80
|
||||
to_port: 80
|
||||
cidr_ip: 0.0.0.0/0
|
||||
- proto: tcp
|
||||
from_port: 443
|
||||
to_port: 443
|
||||
cidr_ip: 0.0.0.0/0
|
||||
register: sg_result
|
||||
|
||||
- name: Launch EC2 instance
|
||||
amazon.aws.ec2_instance:
|
||||
name: "phantom-{{ deploy_id }}"
|
||||
key_name: "{{ ec2_key_name }}"
|
||||
instance_type: "{{ ec2_instance_type }}"
|
||||
image_id: "{{ ec2_ami }}"
|
||||
region: "{{ aws_region }}"
|
||||
security_group: "{{ sg_result.group_id }}"
|
||||
wait: true
|
||||
state: running
|
||||
register: ec2_result
|
||||
|
||||
- name: Set target host fact
|
||||
set_fact:
|
||||
target_host: "{{ ec2_result.instances[0].public_ip_address }}"
|
||||
|
||||
- name: Display instance info
|
||||
debug:
|
||||
msg: |
|
||||
EC2 instance provisioned:
|
||||
ID: {{ ec2_result.instances[0].instance_id }}
|
||||
IP: {{ target_host }}
|
||||
Region: {{ aws_region }}
|
||||
Type: {{ ec2_instance_type }}
|
||||
|
||||
- name: Write provisioned host IP for phantom
|
||||
copy:
|
||||
content: "{{ target_host }}"
|
||||
dest: "{{ _host_output_file }}"
|
||||
when: _host_output_file is defined
|
||||
|
||||
- name: Wait for SSH
|
||||
wait_for:
|
||||
host: "{{ target_host }}"
|
||||
port: 22
|
||||
delay: 15
|
||||
timeout: 300
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
# Register a pre-provisioned FlokiNET server for phantom deployment
|
||||
# FlokiNET servers are provisioned manually via their control panel.
|
||||
# This playbook only validates SSH connectivity and prepares the server.
|
||||
|
||||
- name: Register FlokiNET Server
|
||||
hosts: all
|
||||
become: true
|
||||
gather_facts: false
|
||||
|
||||
tasks:
|
||||
- name: Ensure Python is available for Ansible
|
||||
raw: test -e /usr/bin/python3 || (apt-get update && apt-get install -y python3)
|
||||
changed_when: false
|
||||
|
||||
- name: Gather facts now that Python is available
|
||||
setup:
|
||||
|
||||
- name: Verify SSH connectivity
|
||||
ping:
|
||||
|
||||
- name: Display server info
|
||||
debug:
|
||||
msg: |
|
||||
FlokiNET server registered:
|
||||
Hostname: {{ ansible_hostname }}
|
||||
OS: {{ ansible_distribution }} {{ ansible_distribution_version }}
|
||||
IP: {{ ansible_default_ipv4.address | default(target_host) }}
|
||||
RAM: {{ ansible_memtotal_mb }}MB
|
||||
Cores: {{ ansible_processor_vcpus }}
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
# Provision a Linode instance for phantom deployment
|
||||
# Requires: LINODE_API_TOKEN or api_token variable
|
||||
|
||||
- name: Provision Linode Instance
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
vars:
|
||||
linode_token: "{{ api_token }}"
|
||||
linode_region: "{{ region | default('us-east') }}"
|
||||
linode_plan: "{{ plan | default('g6-nanode-1') }}"
|
||||
linode_image: "{{ image | default('linode/debian12') }}"
|
||||
linode_label: "phantom-{{ deploy_id }}"
|
||||
ssh_key_path: "{{ ssh_key }}.pub"
|
||||
|
||||
tasks:
|
||||
- name: Read SSH public key
|
||||
slurp:
|
||||
src: "{{ ssh_key_path }}"
|
||||
register: ssh_pubkey
|
||||
|
||||
- name: Create Linode instance
|
||||
uri:
|
||||
url: https://api.linode.com/v4/linode/instances
|
||||
method: POST
|
||||
headers:
|
||||
Authorization: "Bearer {{ linode_token }}"
|
||||
Content-Type: application/json
|
||||
body_format: json
|
||||
body:
|
||||
type: "{{ linode_plan }}"
|
||||
region: "{{ linode_region }}"
|
||||
image: "{{ linode_image }}"
|
||||
label: "{{ linode_label }}"
|
||||
authorized_keys:
|
||||
- "{{ ssh_pubkey.content | b64decode | trim }}"
|
||||
booted: true
|
||||
status_code: 200
|
||||
register: linode_result
|
||||
|
||||
- name: Set target host fact
|
||||
set_fact:
|
||||
target_host: "{{ linode_result.json.ipv4[0] }}"
|
||||
|
||||
- name: Display instance info
|
||||
debug:
|
||||
msg: |
|
||||
Linode provisioned:
|
||||
ID: {{ linode_result.json.id }}
|
||||
IP: {{ linode_result.json.ipv4[0] }}
|
||||
Region: {{ linode_region }}
|
||||
Plan: {{ linode_plan }}
|
||||
|
||||
- name: Write provisioned host IP for phantom
|
||||
copy:
|
||||
content: "{{ target_host }}"
|
||||
dest: "{{ _host_output_file }}"
|
||||
when: _host_output_file is defined
|
||||
|
||||
- name: Wait for SSH
|
||||
wait_for:
|
||||
host: "{{ target_host }}"
|
||||
port: 22
|
||||
delay: 10
|
||||
timeout: 300
|
||||
Reference in New Issue
Block a user