Skip to content

Instantly share code, notes, and snippets.

@picatz
Last active November 6, 2016 00:40
Show Gist options
  • Save picatz/c9525cc5c4f5fca0a790671f01b6d4f0 to your computer and use it in GitHub Desktop.
Save picatz/c9525cc5c4f5fca0a790671f01b6d4f0 to your computer and use it in GitHub Desktop.
Example modified/extracted from PacketFu's example code
require 'packetfu'
iface = PacketFu::Utils.default_int
cap = PacketFu::Capture.new(:iface => iface, :start => true, :filter => "ip")
attack_patterns = ["^gotcha", "owned!*$", "^\x04[^\x00]{50}"]
loop do
cap.stream.each do |pkt|
packet = PacketFu::Packet.parse(pkt)
attack_patterns.each do |sig|
hit = packet.payload.scan(/#{sig}/i) || nil
puts "#{Time.now}: %s attacked %s [%s]" % [packet.ip_saddr, packet.ip_daddr, sig.inspect] unless hit.size.zero?
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment