Skip to content

Instantly share code, notes, and snippets.

View pocc's full-sized avatar
🏠
Working from home

Ross Jacobs pocc

🏠
Working from home
View GitHub Profile
@pocc
pocc / XORCipher.js
Created December 5, 2019 22:15 — forked from sukima/XORCipher.js
A Super simple encryption cipher using XOR and Base64 in JavaScript
// XORCipher - Super simple encryption using XOR and Base64
//
// Depends on [Underscore](http://underscorejs.org/).
//
// As a warning, this is **not** a secure encryption algorythm. It uses a very
// simplistic keystore and will be easy to crack.
//
// The Base64 algorythm is a modification of the one used in phpjs.org
// * http://phpjs.org/functions/base64_encode/
// * http://phpjs.org/functions/base64_decode/
@pocc
pocc / parse_pcap_parts.py
Created August 9, 2019 22:05
This script will print the header, packet headers, packets, and the footer for any format.
"""This script will print the header, packet headers, packets, and the footer for any format."""
import subprocess as sp
import re
import os
def create_pcap():
if not os.path.exists("temp.pcapng"):
sp.call(["tshark", "-w", "temp.pcapng", "-c", "3"])
return "temp.pcapng"
@pocc
pocc / verify_wireshark_configs.py
Created August 7, 2019 22:32
Check the validity of your Wireshark config files after editing them.
"""Check the validity of your Wireshark config files after editing them.
Part of https://tshark.dev/packetcraft/config_files. Ross Jacobs, 2019-08-07.
"""
import re
import os
def gen_regexes():
"""Generate the regex dictionary."""
ws = r'\s+' # whitespace
@pocc
pocc / channel_test.go
Last active May 26, 2019 21:13
Find channel IO overhead
/* Benchmarks summing serially and then with channels
* to time how much overhead channel reads have.
* To run: `go test -bench . channel_test.go`
*/
package channel_test
import (
"sync"
"testing"
)
@pocc
pocc / .pre-commit-config.yaml
Created April 19, 2019 15:15
Initial pre-commit (likely has errors)
# Ross Jacobs pre-commit file
exclude: ''
fail_fast: false
minimum_pre_commit_version: 0
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0 # Use the ref you want to point at
hooks:
# Checks
- id: check-added-large-files
@pocc
pocc / reshark.py
Last active April 10, 2019 18:27
Filters packets by a regex applied to a display filter
#!/usr/bin/env python3
# Desc:
# Create a pcap where the output of a display filter matches
# a given regex. Generates a file named re_<pcap in name>
# tshark MUST be on the path for this to work
#
# Usage:
# Using the `arp-storm.pcap` from https://wiki.wireshark.org/SampleCaptures
# To match all packets whose seconds part of the timestamp ends in 3:
#
@pocc
pocc / build_wireshark.sh
Created April 8, 2019 16:38
Build Wireshark 3.0.0 on Ubuntu 18.04
cd /tmp
wget https://www.wireshark.org/download/src/wireshark-3.0.0.tar.xz
tar -xzf wireshark-3.0.0.tar.xz
cd wireshark-3.0.0
sudo apt update && sudo apt dist-upgrade
sudo apt install cmake libglib2.0-dev libgcrypt20-dev flex bison byacc libpcap-dev qtbase5-dev libssh-dev libsystemd-dev qtmultimedia5-dev libqt5svg5-dev qttools5-dev
cmake .
make
@pocc
pocc / octave.py
Last active April 7, 2019 21:25
Play a full octave using pysine
# Play all notes between 440-880hz, inclusive
from pysine import sine
def get_freq(key):
# For a given piano key, return the frequency
# Taken from https://en.wikipedia.org/wiki/Piano_key_frequencies
return 2**((key-49)/12) * 440
for key in range(49, 62):
freq = get_freq(key)
@pocc
pocc / wsl_tshark.sh
Last active March 23, 2021 02:50
Use WSL tshark to colorize output and Windows tshark for everything else
#!/usr/bin/env bash
# Copyright 2019 Ross Jacobs
#
# tshark --color on Windows is limited to 16 colors vs 24-bit "true color"
# on other platforms. This script uses both WSL and Windows tshark in
# order to get color parity on Windows.
#
# Install:
# Add this function to your WSL ~/.bashrc and then `source ~/.bashrc`
#
@pocc
pocc / scapy_example.py
Created March 28, 2019 01:34
Send udp/tcp/icmp pings in Scapy to top 50 websites and watch those packets appear in a Wireshark live capture
#!/usr/bin/env python3
# Run `tail -f -n +1 /tmp/scapy.pcap | wireshark -k -i -` in another terminal
import re
import requests
from scapy.all import *
LIVE_PCAP="/tmp/scapy.pcap"
def top_50_websites():