-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathaws_security_group.tf
108 lines (84 loc) · 2 KB
/
aws_security_group.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#Security Groups
// For Kali in public subnet: Allow ssh/http/https/51820 (Wireguard)
resource "aws_security_group" "SecurityGroup-Kali" {
name = "SecurityGroup-Kali"
description = "allows ssh and http"
vpc_id = aws_vpc.VPC.id
ingress {
from_port = 51820 // wireguard vpn
to_port = 51820
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22 // ssh
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 8800 // For reverse shells
to_port = 8899
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 80 // http
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443 // https
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = -1
to_port = -1
protocol = "icmp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0 // allow all
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
depends_on = [ aws_vpc.VPC ]
tags = {
Name = "SecurityGroup-Kali"
}
}
// For Vulnerable machines in private subnet: allow all
resource "aws_security_group" "SecurityGroup-VulnerableMachines" {
name = "SecurityGroup-VulnerableMachines"
description = "Allow only from Public Subnet"
vpc_id = aws_vpc.VPC.id
ingress {
from_port = 0
to_port = 0
protocol = -1
cidr_blocks = [aws_subnet.publicSubnet.cidr_block]
}
ingress {
from_port = -1
to_port = -1
protocol = "icmp"
cidr_blocks = [aws_subnet.publicSubnet.cidr_block]
}
egress {
from_port = 0
to_port = 0
protocol = -1
cidr_blocks = ["0.0.0.0/0"]
}
depends_on = [
aws_vpc.VPC,
aws_security_group.SecurityGroup-Kali,
]
tags = {
Name = "SecurityGroup-VulnerableMachines"
}
}