Skip to content

Instantly share code, notes, and snippets.

@luelista
luelista / fix-remote-addr.php
Last active September 21, 2018 19:38
Scripts for fixing the REMOTE_ADDR when working with Cloudflare's reverse proxy, and automatically fetching the cloudflare net ranges
<?php
// Include this in your scripts where REMOTE_ADDR is used
function check_ip_range($ip, $rangeFile) {
$bin = inet_pton($ip);
$adrlen = strlen($bin);
if ($adrlen == 16) { //IPv6
$rangeFile.=".ipv6";
} else {
$rangeFile.=".ipv4";
# Definitions from the exercise
avg_packet_size = 400
edge_def = """
Edge Dist C_bps
AB 1 20000
BC 3 10000
AD 2 20000
BE 5 20000
CE 2 30000
@luelista
luelista / simplehttprequest.js
Created January 11, 2018 14:30
Simple HTTP request wrapper for XMLHttpRequest
function http(url, method, data){
return new Promise(function(resolve, reject) {
var xhr;
if(method == undefined) method = data ? "POST" : "GET";
try {
xhr = new XMLHttpRequest();
} catch (e) {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
mikrotik rooten
wget -c https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/mikrotik/openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf
wget -c https://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/mikrotik/openwrt-15.05-ar71xx-mikrotik-vmlinux-lzma.elf
wget -c https://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/mikrotik/openwrt-15.05-ar71xx-mikrotik-DefaultNoWifi-rootfs.tar.gz
ln -s openwrt-15.05-ar71xx-mikrotik-vmlinux-lzma.elf openwrt-ar71xx-mikrotik-vmlinux-lzma.elf
ln -s openwrt-15.05-ar71xx-mikrotik-DefaultNoWifi-rootfs.tar.gz openwrt-ar71xx-mikrotik-rootfs.tar.gz
wget https://busybox.net/downloads/binaries/1.21.1/busybox-mips
python -m http.server &
#include <openssl/blowfish.h>
#include <openssl/md5.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#define TOKENS "\r \n "
#define DIRECTION 1
#define SRCDATA 2
@luelista
luelista / android_MITM_system_trust_store.sh
Last active September 7, 2017 14:51
generate certificate for android MITM and put it in system trust store
openssl genrsa -out rootCA.key 2048 -nodes
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
openssl pkcs12 -export -in rootCA.pem -out rootCA.pkcs12 -inkey rootCA.key -name "fooCA"
certhash=$(openssl x509 -in rootCA.pem -subject_hash_old -noout)
cat rootCA.pem > $certhash.0
openssl x509 -inform PEM -text -in rootCA.pem -out /dev/null >> $certhash.0
@luelista
luelista / rpsls.sh
Created June 1, 2017 14:44
Rock Paper Scissors Lizard Spock
#!/bin/sh
CHOICES="Rock Paper Scissors Lizard Spock"
check_rule() {
user="$1"; computer="$2"; draw="yes"
while read rulestr ; do
rule="$rulestr"
winner="${rule%% *}"; rule="${rule#* }"
verb="${rule%% *}"; rule="${rule#* }"
#!/bin/bash
if [[ $EUID != 0 ]] ; then
echo This must be run as root!
exit 1
fi
for xhci in /sys/bus/pci/drivers/?hci_hcd ; do
if ! cd $xhci ; then
def drawbars(img, width, height):
x=0
while x<width:
img.paste((255,0,0), (x,0,x+1,height))
x+=2
img.paste((255,0,0), (x,0,x+3,height))
x+=6
img.paste((0,255,0), (x,0,x+1,height))
x+=2
@luelista
luelista / adr_land.sql
Created March 5, 2016 15:13
MySQL table with list of all (most?) countries of the world
-- --------------------------------------------------------
-- Host: xx
-- Server Version: xx
-- Server Betriebssystem: xx
-- HeidiSQL Version: 9.3.0.4984
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;