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
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 |
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' | |
config = PacketFu::Utils.whoami? | |
synpkt = PacketFu::TCPPacket.new(config: config, flavor: "Linux") | |
synpkt.ip_daddr = "216.58.221.142" # ip of google.com | |
synpkt.tcp_dst = 80 # port of google.com | |
synpkt.tcp_flags.syn = 1 # SYN | |
synpkt.recalc |
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' | |
cap = PacketFu::Capture.new( | |
iface: config[:iface], | |
start: true, | |
filter: "tcp and src 216.58.221.142" | |
) | |
cap.stream.each do |pkt| | |
# parse pkt and decide what to do next |
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 "minitest/autorun" | |
require "builder" | |
class Converter | |
XML_DECLARATION = %q(<?xml version="1.0" encoding="UTF-8"?>) | |
def self.to_xml(h) | |
raise unless h.kind_of? Hash | |
h.inject("") { |s, (k, v)| s += node_with(k, v) } |