Skip to content

Commit 57fb895

Browse files
Merge pull request #6 from alphagov/cp-fix
Remove copy paste error, small change to README
2 parents 151524a + 299b512 commit 57fb895

File tree

4 files changed

+57
-50
lines changed

4 files changed

+57
-50
lines changed

.secrets.baseline

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"exclude": {
3-
"files": null,
3+
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2020-03-26T09:57:13Z",
6+
"generated_at": "2020-05-11T09:18:09Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -49,13 +49,14 @@
4949
"terraform/cloudinit/kali-instance.yaml": [
5050
{
5151
"hashed_secret": "d87c448044defb778f33158d8ccf94a20531d600",
52+
"is_secret": false,
5253
"is_verified": false,
5354
"line_number": 9,
5455
"type": "Secret Keyword"
5556
}
5657
]
5758
},
58-
"version": "0.13.0",
59+
"version": "0.13.1",
5960
"word_list": {
6061
"file": null,
6162
"hash": null

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,29 @@ Within the AWS account you wish to deploy to.
2424

2525
- Assume the role of the aws account you wish to deploy to at your cli.
2626

27-
*Note that this has already been done for the security-testing aws account*
27+
*Note that this has already been done for the `security-vuln-testing` aws account*
2828

2929
### Deploy with the below commands
30-
- git clone git@github.com:alphagov/penetration-testing-instance.git
3130

32-
- cd penetration-testing-instance/terraform
31+
- Ensure you are using terraform `0.12.3`
3332

34-
- edit main.tf and place in your public ssh-key at ssh-pub-key-1.
35-
If you are working as a pair also set ssh-pub-key-2.
33+
- `git clone git@github.com:alphagov/penetration-testing-instance.git`
3634

37-
- terraform init; terraform plan
35+
- `cd penetration-testing-instance/terraform`
3836

39-
*AWS Vault: aws-vault exec <profile> -- terraform init; terraform plan*
37+
- edit main.tf and place in your public ssh-key at ssh-pub-key-{number}.
38+
39+
- `terraform init; terraform plan`
40+
41+
*AWS Vault: `aws-vault exec <profile> -- terraform init; terraform plan`*
4042

4143
- If the plan looks good then run:
42-
terraform apply
44+
`terraform apply`
4345

44-
- To obtain the public ip address run aws-vault exec <profile> -- aws ec2 describe-instances | grep 'GroupName\|PublicIp'
46+
- The public IP will be output by TF
4547

4648
- Once the instance is up, to access use:
47-
ssh pentester@<public-ip-address>
49+
`ssh pentester@<public-ip-address>`
4850

4951
## Cheatsheet to get started on some of the tooling
5052
CHEATSHEET FOR TOOLING

terraform/cloudinit/kali-instance.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ users:
1111
ssh_import_id: None
1212
lock_passwd: true
1313
ssh_authorized_keys:
14-
- ${ssh-pub-key-1}
15-
- ${ssh-pub-key-2}
14+
%{ for key in ssh-keys ~}
15+
- ${key}
16+
%{ endfor ~}
1617
write_files:
1718
- path: /usr/local/bin/empire
1819
permissions: '0755'

terraform/main.tf

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ provider "aws" {
1414
}
1515

1616
locals {
17-
# Set your SSH public keys here for who you want to be able to access the instance
18-
# Remove the existing keys
19-
ssh-pub-key-1 = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQChXVB0+ZEc2KB1147WHGbhSUGyB2xeLnwJ4CW9V9hWdTgGWMuiWOcgFc1BGGbQ2I6Be939/JzqmsNOlguB0Qq5OJgcHelgB2+qAqEb1I9gYwKFFoIOIpiG5WNNKfbY+C2OjW6zCy9n0bNdXuSDzG2becfeCtSurdoVQNwt54AEXNtQAjUqPk+T4pHpMdWpDIMamDw8PY8PG3hypr6ao5vy/vBOaIKezAGIsDnr8eVIVkaV/TCE9RRQLxpN/tXCowzRbAmIko7so5iKoQOXSzHLMk/dehDk4oQg8pdRG7n/QW3NXFg1KbS3STgUb/8uigwAVRWCEd9LysDaceUISZ2JOP2f692f/z2rA1gCQiM5qJBOTGzL980PfcnTcKA8LI7A//S+UdWEONThQlpnZf+aFTaL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+tf9oN32B40RypJH8ov7A2K/V45F3R3DblhI8n7H1l/JnbJwsgYAmQMLGqcXlCbre8xZ5qEyR+vPVGF9/2vdnF1Fke3bNuyx8vpdFz+Kx3zDXJ7G20R2sNziVOFnRK93Go/pBtpxpWrrR9sI5vpdI4Cjp7sxFbo7/lL/fipBLA1H5ieUo7b0vVDM8cdNt7aTtc6FmSmjT2T1x4ILAuKptVU68JTLZoEE29RwdCZgkjPkZuaBHF78c3vQXbp8p4mA3gqGG9SYgSoPIGDBY1YQCkBiUm+m4JA+5LmRto9AAZjRff1NbQvEdzFojMuBF4bWTSasteLZwkkMdbP8XP cardno:000606445046"
22-
# The office-ips below are set to the GDS office egress ips, this local var is used to whitelist inbound ssh connections
17+
# Set your SSH public keys here for who you want to be able to access the instance
18+
# Remove the existing keys
19+
ssh-keys = [
20+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQChXVB0+ZEc2KB1147WHGbhSUGyB2xeLnwJ4CW9V9hWdTgGWMuiWOcgFc1BGGbQ2I6Be939/JzqmsNOlguB0Qq5OJgcHelgB2+qAqEb1I9gYwKFFoIOIpiG5WNNKfbY+C2OjW6zCy9n0bNdXuSDzG2becfeCtSurdoVQNwt54AEXNtQAjUqPk+T4pHpMdWpDIMamDw8PY8PG3hypr6ao5vy/vBOaIKezAGIsDnr8eVIVkaV/TCE9RRQLxpN/tXCowzRbAmIko7so5iKoQOXSzHLMk/dehDk4oQg8pdRG7n/QW3NXFg1KbS3STgUb/8uigwAVRWCEd9LysDaceUISZ2JOP2f692f/z2rA1gCQiM5qJBOTGzL980PfcnTcKA8LI7A//S+UdWEONThQlpnZf+aFTaLHLvuBNO4awOoMorDkI7FMUvyGTHKJVHqebHwBoFMKghn9tzQ/GKK+o0zNgZ5nZaVGRRzRhxv/UueYVPPlRAf0w5GRPzx4vyOc7PE4M6amIDrIG8xojVFn8m3KwQumU78m297HzWtK3CSJSDrU1k2gpHdM/8AArRtYhIyPl7w/CaC+GrVMpG3I4r1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x4ILAuKptVU68JTLZoEE29RwdCZgkjPkZuaBHF78c3vQXbp8p4mA3gqGG9SYgSoPIGDBY1YQCkBiUm+m4JA+5LmRto9AAZjRff1NbQvEdzFojMuBF4bWTSasteLZwkkMdbP8XP cardno:000606445046"
23+
]
24+
# The office-ips below are set to the GDS office egress ips, this local var is used to whitelist inbound ssh connections
2325
office-ips = [
2426
"85.133.67.244/32",
2527
"213.86.153.212/32",
@@ -41,7 +43,7 @@ resource "aws_vpc" "vuln-tooling" {
4143
}
4244

4345
resource "aws_internet_gateway" "vuln-tooling-igw" {
44-
vpc_id = "${aws_vpc.vuln-tooling.id}"
46+
vpc_id = aws_vpc.vuln-tooling.id
4547

4648
tags = {
4749
Name = "Vulnerability Tooling Internet Gateway"
@@ -50,8 +52,8 @@ resource "aws_internet_gateway" "vuln-tooling-igw" {
5052
}
5153

5254
resource "aws_subnet" "vuln-tooling-subnet" {
53-
vpc_id = "${aws_vpc.vuln-tooling.id}"
54-
cidr_block = "10.0.1.0/24"
55+
vpc_id = aws_vpc.vuln-tooling.id
56+
cidr_block = "10.0.1.0/24"
5557
availability_zone = "eu-west-2a"
5658
map_public_ip_on_launch = true
5759

@@ -62,11 +64,11 @@ resource "aws_subnet" "vuln-tooling-subnet" {
6264
}
6365

6466
resource "aws_route_table" "vuln-tooling-route-table" {
65-
vpc_id = "${aws_vpc.vuln-tooling.id}"
67+
vpc_id = aws_vpc.vuln-tooling.id
6668

6769
route {
68-
cidr_block = "0.0.0.0/0"
69-
gateway_id = "${aws_internet_gateway.vuln-tooling-igw.id}"
70+
cidr_block = "0.0.0.0/0"
71+
gateway_id = aws_internet_gateway.vuln-tooling-igw.id
7072
}
7173

7274
tags = {
@@ -76,8 +78,8 @@ resource "aws_route_table" "vuln-tooling-route-table" {
7678
}
7779

7880
resource "aws_route_table_association" "vuln-tooling-association" {
79-
subnet_id = "${aws_subnet.vuln-tooling-subnet.id}"
80-
route_table_id = "${aws_route_table.vuln-tooling-route-table.id}"
81+
subnet_id = aws_subnet.vuln-tooling-subnet.id
82+
route_table_id = aws_route_table.vuln-tooling-route-table.id
8183
}
8284

8385
data "aws_ami" "vuln-tooling-kali-ami" {
@@ -100,22 +102,10 @@ data "aws_ami" "vuln-tooling-kali-ami" {
100102
}
101103
}
102104

103-
data "template_file" "kali_userdata" {
104-
template = "${file("cloudinit/kali-instance.yaml")}"
105-
106-
vars = {
107-
hostname = "kali-pentest-01"
108-
ssh-pub-key-1 = "${local.ssh-pub-key-1}"
109-
ssh-pub-key-2 = "${local.ssh-pub-key-2}"
110-
ssh-pub-key-2 = "${local.ssh-pub-key-3}"
111-
bootstrap-tools = "${file("cloudinit/bootstrap-tools.sh.tpl")}"
112-
}
113-
}
114-
115105
resource "aws_security_group" "kali-pentest-sg" {
116106
name = "kali-pentest-sg"
117107
description = "Kali PenTest Instance Security Group"
118-
vpc_id = "${aws_vpc.vuln-tooling.id}"
108+
vpc_id = aws_vpc.vuln-tooling.id
119109

120110
ingress {
121111
from_port = 22
@@ -125,9 +115,9 @@ resource "aws_security_group" "kali-pentest-sg" {
125115
}
126116

127117
egress {
128-
from_port = 0
129-
to_port = 0
130-
protocol = -1
118+
from_port = 0
119+
to_port = 0
120+
protocol = -1
131121
cidr_blocks = ["0.0.0.0/0"]
132122
}
133123

@@ -138,18 +128,31 @@ resource "aws_security_group" "kali-pentest-sg" {
138128
}
139129

140130
resource "aws_instance" "kali-pentest" {
141-
ami = "${data.aws_ami.vuln-tooling-kali-ami.id}"
131+
ami = data.aws_ami.vuln-tooling-kali-ami.id
142132
instance_type = "t2.medium"
143-
user_data = "${data.template_file.kali_userdata.rendered}"
144-
monitoring = "true"
145-
subnet_id = "${aws_subnet.vuln-tooling-subnet.id}"
133+
134+
user_data = templatefile(
135+
"${path.module}/cloudinit/kali-instance.yaml",
136+
{
137+
hostname = "kali-pentest-01"
138+
ssh-keys = local.ssh-keys
139+
bootstrap-tools = "${file("cloudinit/bootstrap-tools.sh.tpl")}"
140+
}
141+
)
142+
143+
monitoring = "true"
144+
subnet_id = aws_subnet.vuln-tooling-subnet.id
146145

147146
vpc_security_group_ids = [
148-
"${aws_security_group.kali-pentest-sg.id}",
147+
aws_security_group.kali-pentest-sg.id,
149148
]
150149

151150
tags = {
152151
Name = "Vulnerability Tooling Kali Pentest Instance"
153152
ManagedBy = "terraform"
154153
}
155154
}
155+
156+
output "instance_ip_addr" {
157+
value = aws_instance.kali-pentest.public_ip
158+
}

0 commit comments

Comments
 (0)