Skip to content

Instantly share code, notes, and snippets.

@sfan5
sfan5 / netfifo.c
Last active December 16, 2015 16:19
Creates two FIFO files that are piped to a network connection.
/* NetFIFO
* Creates two FIFO files that are piped to a network connection.
* Made by sfan5
* License: CC-BY-SA v3
*
* Example Usage:
* netfifo tcp google.com 80 ififo ofifo &
* echo -e "GET / HTTP/1.1 \r\n" > ififo
* cat ofifo
*/
@sfan5
sfan5 / socks5_serv.py
Last active December 16, 2015 22:59
A SOCKS 5 proxy server
#!/usr/bin/env python2
# SOCKS 5 server
# -*- coding: utf-8 -*-
import socket, struct, time, select, os
from thread import start_new_thread, allocate_lock
# Address to listen on
HOST = ""
# Port to listen on
PORT = 12345
@sfan5
sfan5 / readpng.py
Created June 7, 2013 22:05
Reads a .png file and outputs its sections
#!/usr/bin/env python2
import sys, binascii, struct
def islower(c):
return (c.upper() != c)
def countin(s, c):
i = 0
for b in s:
if b == c:
i += 1
return i
@sfan5
sfan5 / xteapipe.c
Last active December 19, 2015 17:59
De/Encrypts from stdin to stdout using XTEA in OFB mode
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
void xtea_encrypt(unsigned int num_rounds, uint32_t v[2], uint32_t const key[4]) {
unsigned int i;
uint32_t v0=v[0], v1=v[1], sum=0, delta=0x9E3779B9;
for (i=0; i < num_rounds; i++) {
v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]);
@sfan5
sfan5 / checkpae.sh
Last active December 20, 2015 10:59 — forked from arsdragonfly/checkpae.sh
Resolves the PlayerArgsEnd missing problem(prints the filenames that have it missing)
#!/bin/bash
# Put this into (worldname)/players folder and execute it
find . -type f -not -name "*.sh" | xargs grep -iL PlayerArgsEnd
@sfan5
sfan5 / binclock.py
Last active December 27, 2015 22:21
Binary Clock using PyGame; Shows month, day, hour, minute and second
import pygame, time
from pygame.locals import *
OFFCOLOR = (25,25,25)
ONCOLOR = (42,65,89)
BGCOLOR = (36,36,36)
FIELDSIZE = 25
def rect(s, c, r): # We need to use this because it isn't drawn for some unknown reason when using pygame.draw.rect
for xx in range(r[0], r[2]):
@sfan5
sfan5 / parse.js
Last active March 20, 2016 16:14
Download all your fav'ed @catgirls_bot pictures and their original images (where possible)
// Go to https://twitter.com/favorites and scoll all the way until there are no more fav'd @catgirls_bot tweets
// maybe like this:
// window.temp=function(){window.scrollTo(0,document.body.scrollHeight);setTimeout(window.temp,750)};window.temp()
// window.temp=function(){}; // stop like this
var _q = document.getElementById('stream-items-id');
var _i;
var _o = [];
for(_i = 0; _i < _q.children.length; _i++) {
var _e = _q.children[_i];
if(_e.children[0].getAttribute('data-screen-name') == 'catgirls_bot') {
@sfan5
sfan5 / 2gateway.sh
Created April 8, 2016 17:24
Support multiple gateways on one machine
#!/bin/bash -e
IFACE=wlp0s18f2u1
TBLN=10
# TBLN needs to be different for each interface
IPADDR=`ip addr show dev $IFACE | grep "inet " | awk '{print $2}' | cut -d '/' -f1`
IPSUBNET=`ip route show | grep "dev $IFACE" | grep "src $IPADDR" | awk '{print $1}'`
IPGATEWAY=`ip route | grep "default via" | grep "dev $IFACE" | awk '{print $3}'`
@sfan5
sfan5 / brnboot_brute.py
Last active May 2, 2016 15:25
Bruteforces brnboot command mode password (required either broken firmware (unbootable) or manual resets)
#!/usr/bin/env python2
import time
import serial
class PasswordGen(object):
def __init__(self):
self.charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
self.cur_pw = [0 for i in range(16)]
self.cur_i = 0
def restore(self, pw):
@sfan5
sfan5 / mkapng.py
Last active May 28, 2016 21:13
Creates an APNG from PNGs (all PNGs need to have the same IHDR checksum for this to work)
#!/usr/bin/env python
import sys
import struct
import binascii
def mkchunk(tp, data):
return struct.pack("!L", len(data)) + tp + data + struct.pack("!L", binascii.crc32(tp + data) & 0xffffffff)
def getchunk(f, tp):
f.seek(0)