Skip to content

Instantly share code, notes, and snippets.

View dcode's full-sized avatar
💭
Hack the 🌎!

Derek Ditch dcode

💭
Hack the 🌎!
View GitHub Profile
@dcode
dcode / bro.conf
Last active August 29, 2015 14:20
Logstash filter for Bro logs
input {
file { path => ["/var/opt/bro/logs/current/*.log"] type => "bro" }
}
filter {
if [type] == "bro" {
bro { }
}
}
@dcode
dcode / gist:c5e748b0c60ba539a1c8
Created May 9, 2015 20:36
Some command line network hunting
# Notice tail
stdbuf -o0 tail -n+1 -F notice.log \
| stdbuf -o0 bro-cut -d ts note msg \
| awk -F'\t' '{ print "================\n" $1, $2"\n", $3 }'
# HTTP Tail
stdbuf -o0 tail -n+1 -F http.log \
| stdbuf -o0 bro-cut id.orig_h uri user_agent \
| awk -F'\t' '{ print "=================\n" $1, $2"\n", $3 }'
@dcode
dcode / bro-es.rb
Last active August 29, 2015 14:20
Bro ASCII logs in JSON
# This logstash config was created for the Logstash 1.5 beta, but I think should work on 1.4.x
# Rename it to .conf, I think. I put .rb for formatting in Gist
input {
file {
path => '/nsm/bro/logs/current/*.log'
codec => "json"
start_position => "beginning"
type => "bro"
# The @metadata field is for logstash internal tracking only
@dcode
dcode / gist:949ad498441b176bf684
Last active August 29, 2015 14:22
Shows all commits that happened last week
# Find all commits from last week since Sunday from current directory
find . -name .git -print -exec git --git-dir={} log --branches \
--pretty=format:"%ci|%D|%s%n" --since="$(date -v-1w -v-sun +%F)" \
2>/dev/null \; | grep -B1 -E "^[0-9]{4}" | grep -v -E "^$|--"
@dcode
dcode / gist:05b9e941df678a2fe0a7
Created June 23, 2015 13:33
Create a fake ethernet interface on Linux. This is useful for replaying PCAP.
# Create Fake ethernet interface
/sbin/modprobe dummy
sudo ip link set dev dummy0 up
@dcode
dcode / gist:ceeb4d577fe0d2293825
Created June 25, 2015 20:46
List all running modules and their params on Linux
cat /proc/modules | cut -f 1 -d " " | while read module; do \
echo "Module: $module"; \
if [ -d "/sys/module/$module/parameters" ]; then \
ls /sys/module/$module/parameters/ | while read parameter; do \
echo -n "Parameter: $parameter --> "; \
cat /sys/module/$module/parameters/$parameter; \
done; \
fi; \
echo; \
done
@dcode
dcode / pipe_magic.sh
Last active August 29, 2015 14:23
bro / jq wizardry in the shell
(cat files.log | grep EXTRACT | jbro | jq --slurp 'sort_by(.missing_bytes) | .[].conn_uids ' | jq --slurp 'flatten | unique | join("|") ' > /tmp/side.fifo & ); while read line </tmp/side.fifo; do cat conn.log | grep -E $line; break; done;
@dcode
dcode / build_bro_f22.sh
Last active August 29, 2015 14:24
Build Bro 2.3 on Fedora 22
# Build Bro from Source on Fedora 22
## Install runtime dependencies - These will be needed once the RPM is built
sudo dnf -y install libpcap openssl-libs bind-libs zlib bash python libcurl gawk GeoIP gperftools-libs
## Install the build dependencies
sudo dnf -y install @development-tools libpcap-devel openssl-devel bind-devel zlib-devel cmake git perl libcurl-devel GeoIP-devel python-devel gperftools-devel swig flex bison rpmdevtools gcc-c++
## Checkout code and build RPMs
git clone git://git.bro.org/bro
@dcode
dcode / build_bro-2.3_EL6.sh
Created July 20, 2015 20:37
Build Bro 2.3 on CentOS 6.6
# Enable EPEL
sudo yum -y install epel-release
# Install run-time deps
sudo yum -y install libpcap openssl bind-libs zlib bash python libcurl gawk GeoIP gperftools-libs
# Install compile-time deps
sudo yum -y install @development libpcap-devel openssl-devel bind-devel zlib-devel cmake git perl libcurl-devel GeoIP-devel python-devel gperftools-devel swig flex bison rpmdevtools gcc-c++
# Clone git repo (this is from Vagrant)
@dcode
dcode / filtered_bro_log_following.sh
Created July 21, 2015 15:00
Examples on how to stream some logs from the 'current' directory through a filter. You could use grep or awk to filter to specific lines
# Notice tail
stdbuf -o0 tail -n+1 -F notice.log \
| stdbuf -o0 bro-cut -d ts note msg \
| awk -F'\t' '{ print "================\n" $1, $2"\n", $3 }'
# HTTP Tail
stdbuf -o0 tail -n+1 -F http.log \
| stdbuf -o0 bro-cut id.orig_h uri user_agent \
| awk -F'\t' '{ print "=================\n" $1, $2"\n", $3 }'