Skip to content

Instantly share code, notes, and snippets.

@mayli
mayli / promise.py
Created March 19, 2016 01:30
Promise in Python?
#!/usr/bin/evn python2
import json
import logging
logging.basicConfig(level=logging.DEBUG)
class Promise(object):
def __init__(self, function=lambda: None, prev=None):
super(Promise, self).__init__()
self.function = function
self.prev = prev
@mayli
mayli / candycrush.py
Created May 21, 2016 00:30
Candy Crush Mitm Hack (maybe no longer working)
import json
def response(context, flow):
path = flow.response.request.path
if 'lol' in path:
flow.response.code = 200
flow.response.msg = 'OK'
flow.response.content = 'Good job!'+log
elif 'getMessages' in path or 'poll' in path:
@mayli
mayli / malloc_hook.c
Created May 21, 2016 00:37
malloc wrapper
/* Prototypes for __malloc_hook, __free_hook */
#include <malloc.h>
static void *old_malloc_hook;
static void *old_free_hook;
/* Prototypes for our hooks. */
static void my_init_hook (void);
static void *my_malloc_hook (size_t, const void *);
static void my_free_hook (void*, const void *);
@mayli
mayli / socat
Created July 15, 2016 00:43
/etc/init.d/socat
#!/bin/bash
### BEGIN INIT INFO
# Provides: socat
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: socat service
### END INIT INFO
@mayli
mayli / bin200.txt
Created October 28, 2016 20:57
gdb bin200
gdb ./bin200
set follow-fork-mode child
break main
break *0x08048df6 # lea
run 10000
set *(unsigned char*)0x8048bdd = 0x74 # break on main, jne -> je
step
# start a new shell and `echo test | nc localhost 10000`
@mayli
mayli / JavaLoadBalancer.java
Created October 30, 2016 06:49
Java LoadBalancer - Threaded
package com.veryamt;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
@mayli
mayli / squid-with-data-compression.md
Created November 13, 2016 05:29
Using squid and data compression proxy to reduce traffic for cat pictures

Squid

Squid is a HTTP(S) caching proxy to reduce bandwidth and improves response times.

data compression proxy

Data compression proxy is a http proxy by google aimming to reduce cellular data usage by gzip and webp (Yes, it will compress jpg, png and gif to webp).

Squid + data compression proxy

root@b59fcaec2f1c:/# nginx -V
nginx version: nginx/1.12.0
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.1t 3 May 2016
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module
@mayli
mayli / minetest mods
Last active April 29, 2017 07:33
sf1.hashbang.sh:30000
sf1.hashbang.sh:30000
- https://github.com/Calinou/moreblocks/archive/master.zip
- https://github.com/sapier/animals_modpack/archive/2.5.0.zip
- https://github.com/kaeza/minetest-irc.git
- https://github.com/downloads/xyzz/minetest-mods/sethome.zip
### Keybase proof
I hereby claim:
* I am mayli on github.
* I am mayli (https://keybase.io/mayli) on keybase.
* I have a public key ASB--StcOMM9xLEveX6c6_gz6JqmhfnTJU9HNTaxtQ-tjwo
To claim this, I am signing this object: