Skip to content

Instantly share code, notes, and snippets.

@danrl
danrl / gp.c
Created June 17, 2013 03:37
2013 def con ctf grandprix
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h>
@danrl
danrl / netstat_proposal_multi-line_output.txt
Created June 20, 2013 10:15
Proposed multi-line output for netstat.
Proposed multi-line output for netstat
======================================
Current Layout
--------------
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp6 0 0 2001:67c:26f4:64::55736 2001:67c:26f4:64::7:993 ESTABLISHED
Note: The current layout seems to cut off addresses.
Proposal #1 (RFC-compliant, one line, 80+ chars)
danrl@tunafish ~$ netstat -tanW
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State <-- [1]
tcp 0 0 0.0.0.0:5000 LISTEN
0.0.0.0:*
tcp6 0 0 :::5000 LISTEN
:::*
tcp6 0 0 2001:470:722d:10:4c6f:4b6d:dde0:1131:57366 ESTABLISHED
2a00:1450:4001:804::1008:443
tcp6 0 0 2001:470:722d:10:c9d:41ad:470e:81bf:32855 ESTABLISHED
@danrl
danrl / Makefile
Created September 24, 2013 15:29
a very generic makefile
# build config
TARGETS = bin1 bin2
INCLUDES = header.h
# project config
CC = gcc
CFLAGS += -Wall -Wextra -pedantic
LDFLAGS +=
# generic build instructions
@danrl
danrl / ipv4-filter.sh
Last active May 21, 2024 22:53
Very basic packet filters with non-atomic loading. Be careful!
#!/bin/bash
echo -n "loading ipv4 packet filter... "
### clear tables
iptables --flush
iptables --delete-chain
iptables --table mangle --flush
iptables --table mangle --delete-chain
@danrl
danrl / add_clean_exit_to_fake_router26.patch
Created March 5, 2015 21:15
THC-IPv6 add_clean_exit_to_fake_router26.patch
diff --git a/fake_router26.c b/fake_router26.c
index 2db4ac2..3e2e3be 100644
--- a/fake_router26.c
+++ b/fake_router26.c
@@ -7,14 +7,15 @@
#include <sys/resource.h>
#include <sys/wait.h>
#include <time.h>
+#include <signal.h>
#include <pcap.h>
@danrl
danrl / dynv6.sh
Last active August 5, 2021 12:40 — forked from corny/dynv6.sh
Update script for dynv6.com to set your IPv4 address and IPv6 prefix
#!/bin/sh -e
hostname=$1
device=$2
file=$HOME/.dynv6.addr6
[ -e $file ] && old=`cat $file`
if [ -z "$hostname" -o -z "$token" ]; then
echo "Usage: token=<your-authentication-token> [netmask=64] $0 your-name.dynv6.net [device]"
exit 1
fi
#include <ESP8266WiFi.h>
#include <MQTTClient.h>
#include "DHT.h"
const char *wifi_ssid = "wifi";
const char *wifi_password = "secret";
const char *mqtt_server = "broker.shiftr.io";
const char *mqtt_id = "my_first_node";
const char *mqtt_user = "login";
@danrl
danrl / switch-cluster.sh
Created September 5, 2017 15:29
Google Cloud Platform Kubernetes cluster switcher
#!/bin/bash
# caution: quick hack!
# -- project selection
PROJECT_IDS=()
PROJECT_NAMES=()
IFS_ORIG=$IFS
package main
import (
"flag"
"io/ioutil"
"log"
"os"
"github.com/nlopes/slack"
)