Skip to content

Instantly share code, notes, and snippets.

View chtzvt's full-sized avatar
🌻
‍To create a little flower is the labor of ages.

Charlton Trezevant chtzvt

🌻
‍To create a little flower is the labor of ages.
View GitHub Profile
@chtzvt
chtzvt / banmi.js
Last active May 6, 2019 20:00
banmi.js is a simple module for implementing rate-limited lockouts
// banmi.js - 2.0
// A simple module for rate-limited lockouts
// (c) 2019 Charlton Trezevant
// MIT License
var Banmi = {};
// Initial ban length, which is used to calculate the scaling ban length per
// the total number of failed attempts
Banmi.initialBanLength = 120;
@chtzvt
chtzvt / cloudflare_origin_whitelist.sh
Created January 5, 2019 05:42
Running a web server behind cloudflare? Run this at startup to apply the freshest firewall rules for their network, automagically :)
# For railgun- allow incoming connections on port 2408 from Cloudflare's ip ranges
echo 'Applying latest firewall configuration for Cloudflare Railgun...'
for i in `curl https://www.cloudflare.com/ips-v4`;do iptables -I INPUT -p tcp -s $i --dport 2408 -j ACCEPT; done;
# For regular 'ol communication over HTTP(S), which should still be coming only via cloudflare
echo 'Applying latest firewall configuration for incoming HTTP traffic from Cloudflare...'
for i in `curl https://www.cloudflare.com/ips-v4`;do iptables -I INPUT -p tcp -s $i --dport 80 -j ACCEPT; done;
echo 'Applying latest firewall configuration for incoming HTTP traffic from Cloudflare...'
for i in `curl https://www.cloudflare.com/ips-v4`;do iptables -I INPUT -p tcp -s $i --dport 443 -j ACCEPT; done;
# Now that we've defined our whitelists, let's block out everyone else from talking to ports 2408, 80, and 443
@chtzvt
chtzvt / bootstrap.sh
Last active November 1, 2021 16:07
Happy (Go)lidays!
apt update ; apt -y install golang-go htop nload
mkdir go
export GOPATH=/root/go
go get golang.org/x/net/ipv6
go get golang.org/x/net/icmp
curl -o ~/golidays.go https://gist.githubusercontent.com/ctrezevant/752fb5a4f1814f779db85e4c75bf5124/raw/ecb171ccef2decf83c4e8446c5ae3942221e17a4/golidays.go
go build -o ~/golidays ~/golidays.go
echo "Done!"
@chtzvt
chtzvt / debugf.h
Last active August 15, 2023 21:06
A tiny little macro to help debug your C code.
// debugf.h
// Charlton Trezevant - 2018
// MIT license
/* USAGE:
* To use this macro, simply paste it into your source file (you may also
* include debugf.h if you have many source files). Doing this will define
* the function debugf(), which acts as a thin wrapper around fprintf() with
* a little added pizazz.
*
@chtzvt
chtzvt / flightspy.sh
Created November 20, 2018 05:33
Gather interesting telemetry data from your Southwest flight!
#! /usr/bin/env bash
# The oneliner below will gather the latest telemetry data about your Southwest flight every two seconds.
# Each response is stored as a text file in JSON format, with the name of the file being the current time.
# I recommend running this in a directory you've created for this purpose.
watch -n 2 -x bash -c 'curl -o $(date +%T).json http://southwestwifi.com/current.json'
@chtzvt
chtzvt / checksum.java
Created October 10, 2018 05:29
Old project: text checksum calculator
/*
The Checksum class calculates a checksum for the text in a given file.
Usage:
java checksum <file name> <checksum size>
*/
import java.util.*;
import java.io.*;
@chtzvt
chtzvt / vigenere.java
Created October 10, 2018 05:22
Old project: A Vigenere cipher implementation in Java
/*
The Vigenere class implements a classical Vigenere cipher, which
operates with a block size of 512 characters.
Usage:
java Vigenere path/to/key.txt path/to/plain.txt
I haven't been able to confirm it, but I'm reasonably confident that
I've inadverdently golfed my way into the smallest possible Vigenere
@chtzvt
chtzvt / protosampler.go
Created September 30, 2018 16:57
CSAW Quals 2018 - Not Protobuf
// Package csaw_protoSampler provides a mechanism for sampling client traffic and server responses
package main
import (
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
"math/rand"
@chtzvt
chtzvt / pihole_dns_redirect_edgeOS.conf
Created August 17, 2018 03:59
Don't let devices use their own DNS servers- redirect those queries to PiHole instead! Configuration snippet for EdgeOS/Vyatta
# Redirect outbound DNS requests to an internal DNS server (for EdgeOS/Vyatta)
# I adapted this configuration from https://old.reddit.com/r/pihole/comments/930g2z/psa_google_services_including_ads_and_others_try/e3t0rqu/?st=jkxfpzdv&sh=370942ba, but I had to make some tweaks,
# because the config in the comment will cause a massive flood of DNS requests that'll bring down your network if you don't filter destinations appropriately (as I've done below).
service {
nat {
rule 1 {
description "Redirect Outbound DNS Queries to PiHole Internally"
destination {
address !your.router's.ip.address
@chtzvt
chtzvt / biglist.md
Created March 25, 2018 19:01
Payton got a new mac! Here are some useful services and apps for it.

💯 🎉 Big Fun List of Tools and Apps 🎉 💯

Development Tools

GitHub Student Pack - A bunch of free stuff :)

GitHub Desktop - Graphical Git client, useful to help you get familiar with Git (until you eventually jump to the CLI)

Homebrew - A package manager for OS X (SUPER important to have)