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 / install-network-manager-l2tp.sh
Created September 7, 2018 21:12
Install network-manager-l2tp on linux distros from source (rough draft)
#!/bin/bash
# This script will install network-manager-l2tp on linux distros from source.
# Only instructions x86_64, per https://github.com/nm-l2tp/network-manager-l2tp
# Untested everywhere (i.e. this is a rough draft)
# Get the required files
git clone https://github.com/nm-l2tp/network-manager-l2tp.git
cd network-manager-l2tp
git checkout 1.2.2
#!/usr/bin/env python3
#-*- coding:utf-8 -*-
# Modified existing script for PyQt5 (https://stackoverflow.com/questions/14090353/)
from PyQt5 import QtCore
from PyQt5.QtWidgets import QWidget, QLineEdit, QPushButton, QHBoxLayout, \
QMainWindow, QApplication
class widgetB(QWidget):
procDone = QtCore.pyqtSignal(str)
@pocc
pocc / signal_strength.sh
Last active November 10, 2018 07:07
This one liner will show the average signal noise and signal strength of all packets in an 802.11 packet capture.
#!/bin/bash
tshark -r <YOUR_WIRELESS_CAPTURE> -T fields -e "radiotap.dbm_antsignal" -e "radiotap.dbm_antnoise" \
| awk '{ sum_signal += $1; sum_noise += $2; n++ } END { if (n > 0) print '\
'"\n802.11 Avgs (dbm)\n=================\nSignal: " sum_signal / n "\nNoise: " sum_noise / n ; }'
@pocc
pocc / install_wireshark.sh
Last active December 10, 2018 03:56
Install Wireshark from source on Ubuntu 16.04
# Built with Mint 17.3 based on Ubuntu 16.04
# Based on https://www.wireshark.org/docs/wsdg_html_chunked/ChSrcBuildFirstTime.html#_building_on_unix
# With additional library installations found via trial and error
# Install bcg729 (which is not installed by default)
curl -L -O https://github.com/~/1.0.4.tar.gz
tar xvzf 1.0.4.tar.gz
cd bcg729-1.0.4
cmake
make
@pocc
pocc / filter_combine.sh
Created December 11, 2018 06:18
Apply a Display Filter to multiple files and merge the packets into one file
#!/bin/bash
# In response to https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=14418
# First arg is filter, all other args are files
# Usage: ./filter_combine.sh 'icmp' file1.pcap file2.pcap file3.pcap
# Outputs `combined.pcapng`
FILTER=$1
FILES=${@:2}
i=0
TEMP_FILES=()
@pocc
pocc / nextstep.py
Created December 28, 2018 01:09
Recursive way to create troubleshooting trees, with examples
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""This program aims to provide tools to troubleshoot better
NOTE: Default option is yes to continue troubleshooting. No is for steps if
user has not done due diligence.
Assuming that categories only need to be chosen at the beginning and from
then on we can employ binary questions
"""
@pocc
pocc / mbms_crc_example.c
Created January 1, 2019 06:19
This function will compute the CRC of a hexstring
// Using code from http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html#ch5
// Using MBMS header bits from the pcap in wireshark bug#14875
// Expected output is 52 (0x34), which is the correct answer
#include <stdio.h>
int main(){
const int generator = 0x2f;
int crc = 0; /* start with 0 so first byte can be 'xored' in */
// 0x10043b000000000000 aligned to 6 bits (from pcap)
@pocc
pocc / meraki_api_generate.py
Created January 25, 2019 23:54
Automatically generate a Python Meraki API module from the Mearki API website
# -*- coding: utf-8 -*-
"""Generator for Meraki API python module"""
import requests
import json
import re
api_key = ''
base_url = 'https://api.meraki.com/api/v0/'
# Should work for get
function_text = """\ndef {0}({1}):
@pocc
pocc / compare_hash_tables.ps1
Created February 1, 2019 22:37
Compare Powershell hash tables recursively
# Compare Powershell hash tables using a helper function.
# Usage:
# PS> Import-Module ./compare_hash_tables.ps1
# PS> $hash1 = @{'1'='2'; '3'=@(@{'5'='8'; 'a'='b'},'7', 'c'); 'd'=@('e')}
# PS> $hash2 = @{'1'='1'; '3'=@(@{'5'='9'},'6'); 'd'=@('e','f')}
# PS> Compare-Hashes $hash1 $hash2
#
# : hash['3'] : list[0] : hash['5'] : <->
# -> Expected '8'
# -> Actually '9'
@pocc
pocc / derive.jl
Created March 2, 2019 19:45
Derive the provided function for x or for a specific value
# Evaluate a derivative of a single-variable function
# Assume last argument is value/var and all others are function
# Example:
# $ julia derive.jl x^2 + x + 1 1
# > derivative at 1:
# > 2.999999999960656
# $ julia derive.jl x^2 + x + 1 x
# > derivative:
# > 2 * 1 * x ^ (2 - 1) + 1
using Calculus