Skip to content

Commit

Permalink
add contentctl
Browse files Browse the repository at this point in the history
  • Loading branch information
P4T12ICK committed Jun 22, 2023
2 parents 2d9414f + 602f568 commit f320ea7
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 50 deletions.
9 changes: 6 additions & 3 deletions configs/attack_range_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ splunk_server:
s3_bucket_url: "https://attack-range-appbinaries.s3-us-west-2.amazonaws.com"
# S3 bucket containing the Splunk Apps which will be installed in Attack Range

splunk_url: "https://download.splunk.com/products/splunk/releases/9.0.2/linux/splunk-9.0.2-17e00c557dc1-Linux-x86_64.tgz"
splunk_url: "https://download.splunk.com/products/splunk/releases/9.0.5/linux/splunk-9.0.5-e9494146ae5c-Linux-x86_64.tgz"
# Url to download Splunk Enterprise

splunk_uf_url: "https://download.splunk.com/products/universalforwarder/releases/9.0.2/linux/splunkforwarder-9.0.2-17e00c557dc1-linux-2.6-amd64.deb"
splunk_uf_url: "https://download.splunk.com/products/universalforwarder/releases/9.0.5/linux/splunkforwarder-9.0.5-e9494146ae5c-linux-2.6-amd64.deb"
# Url to download Splunk Universal Forwarder Linux

splunk_uf_win_url: "https://download.splunk.com/products/universalforwarder/releases/9.0.2/windows/splunkforwarder-9.0.2-17e00c557dc1-x64-release.msi"
splunk_uf_win_url: "https://download.splunk.com/products/universalforwarder/releases/9.0.5/windows/splunkforwarder-9.0.5-e9494146ae5c-x64-release.msi"
# Url to download Splunk Universal Forwarder Windows

byo_splunk: "0"
Expand Down Expand Up @@ -174,6 +174,9 @@ windows_servers_default:
bad_blood: "0"
# Install Bad Blood. More inforamtion in chapter Bad Blood under Attack Range Features.

aurora_agent: "0"
# Install Aurora Agent

linux_servers_default:
hostname: ar-linux
# Define the hostname for the Linux Server
Expand Down
4 changes: 2 additions & 2 deletions modules/ansible/roles/atomic_red_team/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# debug:
# var: ansible_facts

- include_tasks: "install_art_windows.yml"
when: ansible_distribution is match "Microsoft Windows"
# - include_tasks: "install_art_windows.yml"
# when: ansible_distribution is match "Microsoft Windows"

- include_tasks: "run_art_linux.yml"
with_items: "{{ techniques }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
- name: Run Atomic Red Team
become: true
shell: |
pwsh -Command 'IEX (IWR https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicsfolder.ps1 -UseBasicParsing);
Install-AtomicsFolder -Force;
IEX (IWR https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicredteam.ps1);
Install-AtomicRedTeam -Force; Invoke-AtomicTest "{{ technique }}" -GetPrereqs;
pwsh -Command 'Invoke-AtomicTest "{{ technique }}" -GetPrereqs;
Invoke-AtomicTest "{{ technique }}";
Invoke-AtomicTest "{{ technique }}" -Cleanup'
register: output_art
Expand Down
6 changes: 3 additions & 3 deletions modules/aws_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def packer(self, image_name) -> None:
self.config['general']['use_prebuilt_images_with_packer'] = "0"

if image_name.startswith("splunk"):
only_cmd_arg = "amazon-ebs.splunk-ubuntu-18-04"
only_cmd_arg = "amazon-ebs.splunk-ubuntu"
path_packer_file = "packer/splunk_server/splunk_aws.pkr.hcl"
command = ["packer", "build", "-force",
"-var", "general=" + json.dumps(self.config["general"]),
Expand Down Expand Up @@ -181,7 +181,7 @@ def packer(self, image_name) -> None:
"-only=" + only_cmd_arg, path_packer_file]

elif image_name.startswith("linux"):
only_cmd_arg = "amazon-ebs.ubuntu-18-04"
only_cmd_arg = "amazon-ebs.ubuntu"
path_packer_file = "packer/linux_server/linux_aws.pkr.hcl"
command = ["packer", "build", "-force",
"-var", "general=" + json.dumps(self.config["general"]),
Expand All @@ -200,7 +200,7 @@ def packer(self, image_name) -> None:
"-only=" + only_cmd_arg, path_packer_file]

elif image_name.startswith("zeek"):
only_cmd_arg = "amazon-ebs.ubuntu-18-04"
only_cmd_arg = "amazon-ebs.ubuntu"
path_packer_file = "packer/zeek_server/zeek_aws.pkr.hcl"
command = ["packer", "build", "-force",
"-var", "general=" + json.dumps(self.config["general"]),
Expand Down
4 changes: 2 additions & 2 deletions modules/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def create_key_pair_aws(region):
epoch_time = str(int(time.time()))
ssh_key_name = getpass.getuser() + "-" + epoch_time[-5:] + ".key"
# create ssh keys
response = client.create_key_pair(KeyName=str(ssh_key_name)[:-4])
response = client.create_key_pair(KeyType='ed25519', KeyName=str(ssh_key_name)[:-4])
with open(ssh_key_name, "w") as ssh_key:
ssh_key.write(response['KeyMaterial'])
os.chmod(ssh_key_name, 0o600)
Expand Down Expand Up @@ -387,7 +387,7 @@ def new(config):
if configuration['general']['cloud_provider'] == "aws":
configuration['aws']['region'] = answers['region']
else:
configuration['azure']['region'] = answers['region']
configuration['azure']['location'] = answers['region']
else:
if configuration['general']['cloud_provider'] == "aws":
configuration['aws']['region'] = 'eu-central-1'
Expand Down
2 changes: 2 additions & 0 deletions packer/ansible/linux_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
- role: linux_osquery
when: use_prebuilt_images_with_packer == "0"
- role: linux_sysmon
when: use_prebuilt_images_with_packer == "0"
- role: linux_install_art
when: use_prebuilt_images_with_packer == "0"
6 changes: 3 additions & 3 deletions packer/ansible/roles/guacamole/tasks/guacamole_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

- name: Download Guacamole Client
get_url:
url: https://archive.apache.org/dist/guacamole/1.5.0/binary/guacamole-1.5.0.war
dest: /tmp/guacamole-1.5.0.war
url: https://archive.apache.org/dist/guacamole/1.5.2/binary/guacamole-1.5.2.war
dest: /tmp/guacamole-1.5.2.war

- name: Move .war
copy: remote_src=True src=/tmp/guacamole-1.5.0.war dest=/etc/guacamole/guacamole.war
copy: remote_src=True src=/tmp/guacamole-1.5.2.war dest=/etc/guacamole/guacamole.war

- name: link guacamole.war
shell:
Expand Down
8 changes: 4 additions & 4 deletions packer/ansible/roles/guacamole/tasks/guacamole_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

- name: Download Guacamole
get_url:
url: https://archive.apache.org/dist/guacamole/1.5.0/source/guacamole-server-1.5.0.tar.gz
dest: /tmp/guacamole-server-1.5.0.tar.gz
url: https://archive.apache.org/dist/guacamole/1.5.2/source/guacamole-server-1.5.2.tar.gz
dest: /tmp/guacamole-server-1.5.2.tar.gz

- name: Extract the source tarball after download
shell:
cmd: |
tar -xzf /tmp/guacamole-server-1.5.0.tar.gz -C /tmp/
tar -xzf /tmp/guacamole-server-1.5.2.tar.gz -C /tmp/
- name: Configure and install Guacamole
shell:
Expand All @@ -17,7 +17,7 @@
make
sudo make install
sudo ldconfig
chdir: /tmp/guacamole-server-1.5.0
chdir: /tmp/guacamole-server-1.5.2

- name: System daemon reload
become: true
Expand Down
1 change: 1 addition & 0 deletions packer/ansible/roles/linux_common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- include: update_packages.yml
- include: disable-dnssec.yml
- include: disable-autoupgrade.yml
- include: update_sshd_config.yml
15 changes: 15 additions & 0 deletions packer/ansible/roles/linux_common/tasks/update_sshd_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---

- name: Configure sshd
lineinfile:
path: "/etc/ssh/sshd_config"
line: "{{item.key}} {{item.value}}"
loop:
- { key: "HostKeyAlgorithms", value: "+ssh-rsa" }
- { key: "PubkeyAcceptedKeyTypes", value: "+ssh-rsa" }

- name: Restart SSHd
become: true
service:
name: sshd
state: restarted
13 changes: 13 additions & 0 deletions packer/ansible/roles/linux_install_art/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

- name: Run Atomic Red Team
become: true
shell: |
pwsh -Command 'IEX (IWR https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicsfolder.ps1 -UseBasicParsing);
Install-AtomicsFolder -Force;
IEX (IWR https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicredteam.ps1);
Install-AtomicRedTeam -Force'
register: output_art

- debug:
var: output_art.stdout_lines
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
export OSQUERY_KEY=1484120AC4E9F8A1A577AEEE97A80C63C9D8B80B
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $OSQUERY_KEY
sudo add-apt-repository 'deb [arch=amd64] https://pkg.osquery.io/deb deb main'
sudo add-apt-repository --yes 'deb [arch=amd64] https://pkg.osquery.io/deb deb main'
sudo apt-get update
sudo apt-get install osquery
2 changes: 1 addition & 1 deletion packer/ansible/roles/linux_osquery/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

- name: restart splunk
become: true
command: "/opt/splunkforwarder/bin/splunk restart"
command: "systemctl restart SplunkForwarder"
2 changes: 1 addition & 1 deletion packer/ansible/roles/linux_sysmon/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

- name: restart splunk
become: true
command: "/opt/splunkforwarder/bin/splunk restart"
command: "systemctl restart SplunkForwarder"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
export OSQUERY_KEY=1484120AC4E9F8A1A577AEEE97A80C63C9D8B80B
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $OSQUERY_KEY
sudo add-apt-repository 'deb [arch=amd64] https://pkg.osquery.io/deb deb main'
sudo add-apt-repository --yes 'deb [arch=amd64] https://pkg.osquery.io/deb deb main'
sudo apt-get update
sudo apt-get install osquery
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---

- name: Enable strong dotnet crypto
win_regedit:
key: "{{ item }}"
value: SchUseStrongCrypto
datatype: dword
data: 1
with_items:
- "HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319"
- "HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319"

- name: Check installed providers
win_shell: Get-PackageProvider -ListAvailable
register: providers

- name: Install NuGet Provider
win_shell: |
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
when: providers.stdout is not search("NuGet")

- name: Install Atomic Red Team
win_shell: |
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -Value 2
IEX (IWR https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicredteam.ps1)
Install-AtomicRedTeam -Force
IEX (IWR 'https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicsfolder.ps1' -UseBasicParsing)
Install-AtomicsFolder -Force -RepoOwner "{{ atomic_red_team_repo }}" -Branch "{{ atomic_red_team_branch }}"
register: install_art

- debug:
var: install_art

- name: Download Latest PurpleSharp Binary
win_shell: |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Ssl3
[Net.ServicePointManager]::SecurityProtocol = 'Tls, Tls11, Tls12, Ssl3'
If (-not (Test-Path c:\Tools\PurpleSharp)) { New-Item -Path c:\Tools\ -Name PurpleSharp -ItemType directory }
$tag = (Invoke-WebRequest 'https://api.github.com/repos/mvelazc0/PurpleSharp/releases' -UseBasicParsing | ConvertFrom-Json)[0].tag_name
$purplesharpDownloadUrl = 'https://github.com/mvelazc0/PurpleSharp/releases/download/' + $tag + '/PurpleSharp_x64.exe'
If (-not (Test-Path c:\Tools\PurpleSharp\PurpleSharp.exe)) { Invoke-WebRequest -Uri $purplesharpDownloadUrl -OutFile c:\Tools\PurpleSharp\PurpleSharp.exe }
4 changes: 3 additions & 1 deletion packer/ansible/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- role: windows_universal_forwarder
when: use_prebuilt_images_with_packer == "0"
- role: windows_aurora_agent
when: use_prebuilt_images_with_packer == "0"
when: (use_prebuilt_images_with_packer == "0") and (aurora_agent == "1")
- role: sysmon
when: use_prebuilt_images_with_packer == "0"
- role: windows_install_attack_simulation
when: use_prebuilt_images_with_packer == "0"
9 changes: 5 additions & 4 deletions packer/linux_server/linux_aws.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ variable "splunk_server" {

data "amazon-ami" "ubuntu-ami" {
filters = {
name = "*ubuntu-focal-20.04-amd64-server-*"
name = "*ubuntu-jammy-22.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}

source "amazon-ebs" "ubuntu-18-04" {
source "amazon-ebs" "ubuntu" {
ami_name = "linux-v${replace(var.general.version, ".", "-")}"
region = var.aws.region
instance_type = "t3.xlarge"
Expand All @@ -56,13 +56,14 @@ source "amazon-ebs" "ubuntu-18-04" {
build {

sources = [
"source.amazon-ebs.ubuntu-18-04"
"source.amazon-ebs.ubuntu"
]

provisioner "ansible" {
extra_arguments = ["--extra-vars", "${join(" ", [for key, value in var.splunk_server : "${key}=\"${value}\""])} ${join(" ", [for key, value in var.general : "${key}=\"${value}\""])}"]
extra_arguments = ["--scp-extra-args", "'-O'", "--extra-vars", "${join(" ", [for key, value in var.splunk_server : "${key}=\"${value}\""])} ${join(" ", [for key, value in var.general : "${key}=\"${value}\""])}"]
playbook_file = "packer/ansible/linux_server.yml"
user = "ubuntu"
ansible_ssh_extra_args = ["-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa"]
}

}
5 changes: 3 additions & 2 deletions packer/nginx_server/nginx_aws.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ variable "splunk_server" {

data "amazon-ami" "nginx-ami" {
filters = {
name = "*ubuntu-bionic-18.04-amd64-server-*"
name = "*ubuntu-jammy-22.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
Expand Down Expand Up @@ -61,9 +61,10 @@ build {
]

provisioner "ansible" {
extra_arguments = ["--extra-vars", "${join(" ", [for key, value in var.splunk_server : "${key}=\"${value}\""])} ${join(" ", [for key, value in var.general : "${key}=\"${value}\""])}"]
extra_arguments = ["--scp-extra-args", "'-O'", "--extra-vars", "${join(" ", [for key, value in var.splunk_server : "${key}=\"${value}\""])} ${join(" ", [for key, value in var.general : "${key}=\"${value}\""])}"]
playbook_file = "packer/ansible/nginx_web_proxy.yml"
user = "ubuntu"
ansible_ssh_extra_args = ["-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa"]
}

}
9 changes: 5 additions & 4 deletions packer/splunk_server/splunk_aws.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ variable "splunk_server" {

data "amazon-ami" "ubuntu-ami" {
filters = {
name = "*ubuntu-focal-20.04-amd64-server-*"
name = "*ubuntu-jammy-22.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}

source "amazon-ebs" "splunk-ubuntu-18-04" {
source "amazon-ebs" "splunk-ubuntu" {
ami_name = "splunk-v${replace(var.general.version, ".", "-")}"
region = var.aws.region
instance_type = "t3.2xlarge"
Expand All @@ -58,13 +58,14 @@ source "amazon-ebs" "splunk-ubuntu-18-04" {
build {

sources = [
"source.amazon-ebs.splunk-ubuntu-18-04"
"source.amazon-ebs.splunk-ubuntu"
]

provisioner "ansible" {
extra_arguments = ["--extra-vars", "${join(" ", [for key, value in var.splunk_server : "${key}=\"${value}\""])} ${join(" ", [for key, value in var.general : "${key}=\"${value}\""])}"]
extra_arguments = ["--scp-extra-args", "'-O'", "--extra-vars", "${join(" ", [for key, value in var.splunk_server : "${key}=\"${value}\""])} ${join(" ", [for key, value in var.general : "${key}=\"${value}\""])}"]
playbook_file = "packer/ansible/splunk_server.yml"
user = "ubuntu"
ansible_ssh_extra_args = ["-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa"]
}

}
7 changes: 4 additions & 3 deletions packer/zeek_server/zeek_aws.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data "amazon-ami" "ubuntu-ami" {
owners = ["099720109477"]
}

source "amazon-ebs" "ubuntu-18-04" {
source "amazon-ebs" "ubuntu" {
ami_name = "zeek-v${replace(var.general.version, ".", "-")}"
region = var.aws.region
instance_type = "t3.xlarge"
Expand All @@ -56,13 +56,14 @@ source "amazon-ebs" "ubuntu-18-04" {
build {

sources = [
"source.amazon-ebs.ubuntu-18-04"
"source.amazon-ebs.ubuntu"
]

provisioner "ansible" {
extra_arguments = ["--extra-vars", "${join(" ", [for key, value in var.splunk_server : "${key}=\"${value}\""])} ${join(" ", [for key, value in var.general : "${key}=\"${value}\""])}"]
extra_arguments = ["--scp-extra-args", "'-O'", "--extra-vars", "${join(" ", [for key, value in var.splunk_server : "${key}=\"${value}\""])} ${join(" ", [for key, value in var.general : "${key}=\"${value}\""])}"]
playbook_file = "packer/ansible/zeek.yml"
user = "ubuntu"
ansible_ssh_extra_args = ["-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa"]
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
shell: '/opt/splunkforwarder/bin/splunk set servername {{ hostname }} -auth admin:{{ attack_range_password }}'
become: yes

- name: Restart Splunk
shell: '/opt/splunkforwarder/bin/splunk restart'
become: yes
- name: restart splunk
become: true
command: "systemctl restart SplunkForwarder"
Loading

0 comments on commit f320ea7

Please sign in to comment.