Last active
November 6, 2016 00:40
-
-
Save picatz/c9525cc5c4f5fca0a790671f01b6d4f0 to your computer and use it in GitHub Desktop.
Example modified/extracted from PacketFu's example code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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