This file contains 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 becomes the default routeable interface | |
iface = PacketFu::Utils.default_int | |
# cap starts capturing packets on iface | |
cap = PacketFu::Capture.new(:iface => iface, :start => true) | |
# will parse packets providing summary data of packet contents | |
cap.stream.each do | packet | |
This file contains 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 becomes the default routeable interface | |
iface = PacketFu::Utils.default_int | |
# config will determine the ifconfig data for iface | |
config = PacketFu::Utils.ifconfig(iface) | |
# print out some of the relevant information | |
puts " iface: " + config[:iface] |
This file contains 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) | |
# create an empty hash that starts for our base stats | |
stats = Hash.new(0) | |
# a hash inside of stats for types, which also starts at 0 | |
stats[:types] = Hash.new(0) |
This file contains 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' | |
# get the default routable interface | |
iface = PacketFu::Utils.default_int | |
# Get my local ip | |
my_ip = PacketFu::Utils.ifconfig(iface)[:ip_saddr] | |
# Create a new capture on the en0 interface, just because I can | |
cap = PacketFu::Capture.new(:iface => 'en0') |
This file contains 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' | |
class SshStatistics | |
attr_accessor :stats | |
# initialize() is the method that is called | |
# when we create a new SshStatistics object. | |
# | |
# == Example | |
# |
This file contains 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| |
This file contains 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' | |
require 'pry' | |
iface = PacketFu::Utils.default_int | |
cap = PacketFu::Capture.new(:iface => iface, :start => true) | |
cap.stream.each do | packet | | |
# will dump you into a pry repl | |
binding.pry | |
end |
This file contains 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 'sinatra' | |
require 'json' | |
set :port, 80 | |
get '/time' do | |
content_type :json | |
{ :time => Time.now }.to_json | |
# => {"time":"2016-11-06 01:11:42 -0400"} | |
end |
This file contains 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 'fosl/parser' | |
pid = "27869" | |
parser = FOSL::Parser.new | |
data = parser.lsof("-p #{pid}") | |
# => example output ... | |
# data => {27869=> | |
# #<FOSL::Process:0x00000001c64480 | |
# @command="ruby", |
This file contains 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 'fosl/parser' | |
# -P : Do not resolve port names | |
# -n : Do not resolve hostnames | |
parser = FOSL::Parser.new | |
all_data = parser.lsof("-Pn") | |
# store statistics | |
stats = Hash.new(0) | |
stats[:users] = [] |
OlderNewer