Skip to content

Instantly share code, notes, and snippets.

@larrylv
Created April 27, 2016 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larrylv/5fbbcbc7db3085fe97e3f419d7fb9858 to your computer and use it in GitHub Desktop.
Save larrylv/5fbbcbc7db3085fe97e3f419d7fb9858 to your computer and use it in GitHub Desktop.
tcp-stack-blog
class Listener
def initialize(conn, config, dst_ip)
@conn = conn
@cap = PacketFu::Capture.new(
iface: config[:iface],
start: true,
filter: "tcp and dst #{config[:ip_saddr]} and src #{dst_ip}"
)
end
def listen
@cap.stream.each do |pkt|
state = @conn.handle(PacketFu::Packet.parse pkt)
return if state == Teeceepee::CLOSED_STATE
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment