Skip to content

Instantly share code, notes, and snippets.

View p1-olm's full-sized avatar

Olivier Le Moal p1-olm

  • Nantes, France
View GitHub Profile
@p1-olm
p1-olm / wg_setup.sh
Last active February 12, 2018 11:16
#!/usr/bin/env bash
iface=$(ip -4 route list 0/0 | cut -d " " -f 5)
gateway=$(ip -4 route list 0/0 | cut -d " " -f 3)
ip=$(ip -4 route get $gateway | head -n 1 | cut -d " " -f 5)
# XXX check if gateway/ip in VPN range
set -v #echo on
ip address flush $iface
ip address add $ip/32 dev $iface
ip route add $gateway/32 dev $iface src $ip
@p1-olm
p1-olm / hexdump.py
Last active September 17, 2018 12:50
def hex_dump(pdu):
""" Useful routine to dump pdu, "xxd" way
"""
import string
length = 0x10
for i in range(0, len(pdu) // length + 1):
begin = i * length
end = (i + 1) * length
padding = " " * (length - len(pdu[begin:end])) * 3
bytes_chunk = "".join("{:02x} ".format(ord(c)) for c in pdu[begin:end])
from scapy.all import *
from subprocess import Popen, PIPE
from tempfile import mkdtemp
packets = rdpcap("/tmp/toconvert.pcap")
temp_pcaps = mkdtemp()
paths_pcaps = []
for i, pkt in enumerate(packets):
if pkt[3].load[2] == "\x0e": # type 14
nas_payload = pkt[3].load[16:]
@p1-olm
p1-olm / wireshark_custom_decode
Last active August 8, 2017 11:30
wireshark_custom_decode
https://wiki.wireshark.org/HowToDissectAnything?highlight=%28USER_DLT%29
echo -n "PAYLOAD GOES HERE" | xxd -p -r > /tmp/test.raw
OR
export raw bytes from wireshark
od -Ax -tx1 -v /tmp/test.raw | text2pcap -l 147 - test.pcap
Configure DLT-USER protocol as "nas-eps" (protocol field)
from libmich.formats.L3Mobile import *
data = "NAS-EPS PAYLOAD GOES HERE"
show(parse_L3(data.decode("hex")))
@p1-olm
p1-olm / subl
Last active June 12, 2017 10:19
Allow piping to Sublime Text on Linux. Doesn't interfere with normal use.
#!/bin/bash
# Allow piping to Sublime Text. Doesn't interfere with normal use.
# Is stdin a terminal?
if test -t 0; then
# Stdin is a terminal.
# Open sublime normally.
/opt/sublime_text/sublime_text "$@"
else
@p1-olm
p1-olm / woof3.py
Last active March 25, 2021 09:49
woof.py fork with Python3 support and PEP8 compliant (http://www.home.unix-ag.org/simon/woof.html)
#!/usr/bin/env python3
#
# woof -- an ad-hoc single file webserver
# Copyright (C) 2004-2009 Simon Budig <simon@budig.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
@p1-olm
p1-olm / android_configure.sh
Created January 6, 2017 15:07 — forked from nddrylliog/android_configure.sh
Cross-compile autotools library for Android / arm-linux-androideabi I stick that in ~/bin/, chmod +x, and then run it in place of "./configure" in my project. Then a make and make install later, the prefix contains libraries built for android. Neato eh?
#!/bin/sh
# I put all my dev stuff in here
export DEV_PREFIX=$HOME/Dev/
# Don't forget to adjust this to your NDK path
export ANDROID_NDK=${DEV_PREFIX}/android-ndk-r8d/
export CROSS_COMPILE=arm-linux-androideabi