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
# pseudo code of an lsof parser I'd like to have | |
require 'lsof_parser' | |
# -P : Do not resolve port names | |
# -n : Do not resolve hostnames | |
data = Lsof::Parser.new( :arguments => "-Pn" ) | |
data.each do |data| | |
data.pid | |
# => #<Lsof::Pid:23466:0x0000000126910> |
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
import sys | |
import requests | |
import json | |
# ip address is passed in as the first argument | |
ip = sys.argv[1] | |
# make a request to ipinfo.io containing the ip address | |
site_data = requests.get('http://ipinfo.io/' + ip).content |
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
import sys | |
import requests | |
import json | |
print sys | |
print '1' | |
print sys.argv | |
print '2' |
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
from ipdb import set_trace | |
import sys | |
import requests | |
import json | |
# set a breakpoint | |
set_trace() | |
# ip address is passed in as the first argument | |
ip = sys.argv[1] |
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
# FILE : ~/.bash_profile | |
function Flip_Table { | |
if [ $? -ne 0 ]; then | |
echo "[ ╯ ' □']╯ ︵ ┻━┻ )" | lolcat -F 0.5 | |
else | |
cur_dir=`pwd | awk -F '/' '{print $NF}'` | |
echo "𝛑猫 : $cur_dir" | lolcat -F 0.4 | |
fi | |
} |
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
# FILE : ~/.bash_profile | |
function Flip_Table { | |
if [ $? -ne 0 ]; then | |
flipr -f -l | |
else | |
cur_dir=`pwd | awk -F '/' '{print $NF}'` | |
echo "𝛑猫 : $cur_dir" | lolcat -F 0.4 | |
fi | |
} |
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 "benchmark/ips" | |
def fast | |
require 'packetfu' | |
require 'em-proxy' | |
require 'webrick' | |
require 'rubydns' | |
require 'colorize' | |
require 'json' | |
require 'net/dns' |
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
2016-08-11 17:32:18 | W | Failed login attempt 'admin' from IP 100.210.123.5 | |
2016-08-16 07:31:42 | W | Failed login attempt 'admin' from IP 13.208.250.62 | |
2016-08-16 07:31:45 | W | Failed login attempt 'admin' from IP 13.208.250.62 | |
2016-08-16 07:31:45 | W | Failed login attempt 'admin' from IP 13.208.250.62 | |
2016-08-16 07:31:47 | W | Failed login attempt 'admin' from IP 13.208.250.62 | |
2016-08-16 07:31:47 | W | Failed login attempt 'admin' from IP 13.208.250.62 | |
2016-08-16 07:31:50 | W | Failed login attempt 'admin' from IP 13.208.250.62 | |
2016-08-16 07:31:50 | W | Failed login attempt 'admin' from IP 13.208.250.62 | |
2016-08-16 07:31:52 | W | Failed login attempt 'admin' from IP 13.208.250.62 | |
2016-08-16 07:31:52 | W | Failed login attempt 'admin' from IP 13.208.250.62 |
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 'time' | |
# This CustomLogParser class is meant to help with | |
# the heavy lifting of sifting through the data | |
# you can find in a custom log file. | |
class CustomLogParser | |
attr_reader :data # parsed data | |
def initialize(args ={}) | |
@data = [] # initialized as an empty array |
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 CustomLogParser | |
# ... previous code | |
def timeline | |
return false unless any_data? | |
info = {} | |
@data.each do |d| | |
if info.keys.include?(d[:ip]) | |
info[d[:ip]][:new] = d[:time] |