From e901eb3febdd596b2fb08ffa2c5f5166f312ce2a Mon Sep 17 00:00:00 2001 From: Marvin Contessi Date: Wed, 1 Aug 2018 10:57:20 +0200 Subject: [PATCH 1/3] added aws terraform template --- gophish-main.tf | 112 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 gophish-main.tf diff --git a/gophish-main.tf b/gophish-main.tf new file mode 100644 index 00000000..7cea4666 --- /dev/null +++ b/gophish-main.tf @@ -0,0 +1,112 @@ +provider "aws" { + region = "eu-central-1" +} + +// details of the aws instance +resource "aws_instance" "example" { + ami = "ami-40d5672f" + instance_type = "t2.micro" + vpc_security_group_ids = ["${aws_security_group.instance.id}"] + key_name = "${aws_key_pair.auth.id}" + + tags { + Name = "phishing-machine" + } + + user_data = < config.json + sudo ./gophish + + +HEREDOC + +} + +// details of security groups +resource "aws_security_group" "instance" { + name = "phishing-machine" + description = "Phishing Campaign 2018 - Managed by Terraform" + ingress { + from_port = 3333 + to_port = 3333 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + ingress { + from_port = 8080 + to_port = 8080 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + ingress { + from_port = 443 + to_port = 443 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_key_pair" "auth" { + key_name = "${var.key_name}" + public_key = "${file(var.public_key_path)}" +} + +variable "public_key_path" { + description = "Enter the path to the SSH Public Key to add to AWS." + default = "~/.ssh/id_rsa.pub" +} + +variable "key_name" { + default = "example" // insert your keypair name here + description = "Desired name of AWS key pair" +} + + +// outputs ip when running "terraform apply" +output "public_ip" { + value = "${aws_instance.example.public_ip}" +} From 40254f5e5e3c090203a42a7889785eb8ee039baf Mon Sep 17 00:00:00 2001 From: Marvin Contessi Date: Fri, 31 Aug 2018 09:41:39 +0200 Subject: [PATCH 2/3] updated the wget request --- gophish-main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gophish-main.tf b/gophish-main.tf index 7cea4666..d3b033f8 100644 --- a/gophish-main.tf +++ b/gophish-main.tf @@ -20,9 +20,9 @@ resource "aws_instance" "example" { yum install unzip -y su ec2-user cd /home/ec2-user/ - wget https://github.com/gophish/gophish/releases/download/v0.6.0/gophish-v0.6.0-linux-64bit.zip - unzip gophish-v0.6.0-linux-64bit.zip - cd gophish-v0.6.0-linux-64bit + wget https://getgophish.com/releases/latest/linux/64 -O gophish-linux-64bit.zip + unzip gophish-linux-64bit.zip + cd gophish-linux-64bit sudo openssl req -newkey rsa:2048 -nodes -keyout gophish.key -x509 -days 365 -out gophish.crt -subj "/C=DE/ST=Example/L=Example/O=example/OU=Cyber" echo '{ "admin_server" : { From 98e81edf6f12f5cae0ac6dde3f97a622b69ef647 Mon Sep 17 00:00:00 2001 From: Marvin Contessi Date: Fri, 31 Aug 2018 09:42:03 +0200 Subject: [PATCH 3/3] removed region so that tf uses the env var --- gophish-main.tf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gophish-main.tf b/gophish-main.tf index d3b033f8..bd9007bc 100644 --- a/gophish-main.tf +++ b/gophish-main.tf @@ -1,6 +1,4 @@ -provider "aws" { - region = "eu-central-1" -} +provider "aws" {} // details of the aws instance resource "aws_instance" "example" {