Merge remote-tracking branch 'flapflap/de-network_configuration'
[tails-test.git] / features / step_definitions / dhcp.rb
blob78ee8f2d40b9ddd7c10baa653010c5a522c7f908
1 Then /^the hostname should not have been leaked on the network$/ do
2   next if @skip_steps_while_restoring_background
3   hostname = @vm.execute("hostname").stdout.chomp
4   packets = PacketFu::PcapFile.new.file_to_array(:filename => @sniffer.pcap_file)
5   packets.each do |p|
6     # if PacketFu::TCPPacket.can_parse?(p)
7     #   ipv4_tcp_packets << PacketFu::TCPPacket.parse(p)
8     if PacketFu::IPPacket.can_parse?(p)
9       payload = PacketFu::IPPacket.parse(p).payload
10     elsif PacketFu::IPv6Packet.can_parse?(p)
11       payload = PacketFu::IPv6Packet.parse(p).payload
12     else
13       save_pcap_file
14       raise "Found something in the pcap file that either is non-IP, or cannot be parsed"
15     end
16     if payload.match(hostname)
17       raise "Hostname leak detected"
18     end
19   end
20 end