Skip to content

Instantly share code, notes, and snippets.

View StoneMoe's full-sized avatar

Lake Chan StoneMoe

View GitHub Profile
function ocr() {
var image = document.querySelector("#myimg6"); // 取验证码
var canvas = document.createElement('canvas');
var ctx = canvas.getContext("2d");
var numbers = [ //0-9和a-z的明暗值
"0",
"0",
"1100001111100000011110011000110011110011111111001111111001111111001111111001111111001111111001111111000000001100000000011111111111111111111111111111111111111111",
"1100001111000000011100111100111111110011111110001111000001111100000111111110001111111100111111110011000000011110000011111111111111111111111111111111111111111111",
"1111000111111100011111100001111111100111110010011110011001110011100111000000001100000000111111100111111000001111100000011111111111111111111111111111111111111111",
@StoneMoe
StoneMoe / Naive-VPN.md
Created March 19, 2017 12:25 — forked from klzgrad/Naive-VPN.md
朴素VPN:一个纯内核级静态隧道

朴素VPN:一个纯内核级静态隧道

由于路由管控系统的建立,实时动态黑洞路由已成为最有效的封锁手段,TCP连接重置和DNS污染成为次要手段,利用漏洞的穿墙方法已不再具有普遍意义。对此应对方法是多样化协议的VPN来抵抗识别。这里介绍一种太简单、有时很朴素的“穷人VPN”。

朴素VPN只需要一次内核配置(Linux内核),即可永久稳定运行,不需要任何用户态守护进程。所有流量转换和加密全部由内核完成,原生性能,开销几乎没有。静态配置,避免动态握手和参数协商产生指纹特征导致被识别。并且支持NAT,移动的内网用户可以使用此方法。支持广泛,基于L2TPv3标准,Linux内核3.2+都有支持,其他操作系统原则上也能支持。但有两个局限:需要root权限;一个隧道只支持一个用户。

朴素VPN利用UDP封装的静态L2TP隧道实现VPN,内核XFRM实现静态IPsec。实际上IP-in-IP隧道即可实现VPN,但是这种协议无法穿越NAT,因此必须利用UDP封装。内核3.18将支持Foo-over-UDP,在UDP里面直接封装IP,与静态的L2TP-over-UDP很类似。

创建一个朴素VPN

@StoneMoe
StoneMoe / init.bat
Created April 12, 2017 15:49
Add to Cmder init.bat to support utf-8
@chcp 65001 > nul
@set PYTHONIOENCODING=utf-8
@StoneMoe
StoneMoe / git_autodeploy.sh
Last active June 4, 2017 20:50
Setup wizard for auto deploy your latest code via git
#!/usr/bin/env bash
# Tested on Debian 8.3
echo "============================================="
echo "Git auto deploy setup wizard"
echo "This script will create a auto-deploy project"
echo "============================================="
echo "Input a unique name for this project"
printf "This will also be directory name:"
@StoneMoe
StoneMoe / eventlet_patcher.py
Created March 7, 2018 11:33
Monkey patch for eventlet wsgi environ string bug
def eventlet_patcher():
# Ref: https://github.com/eventlet/eventlet/pull/467
# Ref: https://github.com/eventlet/eventlet/issues/468
from eventlet.wsgi import HttpProtocol
def new_get_environ(self):
env = self.server.get_environ()
env['REQUEST_METHOD'] = self.command
env['SCRIPT_NAME'] = ''
@StoneMoe
StoneMoe / tmux.md
Created January 8, 2019 06:19 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@StoneMoe
StoneMoe / python_engineio_patcher.py
Last active January 15, 2019 05:29
Monkey patch for Python-EngineIO JSONP-Polling support
# For Python-EngineIO 2.0.2
def engine_io_patcher():
from engineio.payload import Payload as eio_Payload
from engineio.server import Server as eio_Server
original_handle_request = eio_Server.handle_request
def new_eioserv__ok(self, packets=None, headers=None, b64=False, jsonp_seq=None):
"""response generator."""
if packets is not None:
if headers is None:
@StoneMoe
StoneMoe / README.md
Created September 25, 2019 10:23 — forked from denji/README.md
Simple Sentry docker-compose.yml
  1. Download docker-compose.yml to dir named sentry
  2. Change SENTRY_SECRET_KEY to random 32 char string
  3. Run docker-compose up -d
  4. Run docker-compose exec sentry sentry upgrade to setup database and create admin user
  5. (Optional) Run docker-compose exec sentry pip install sentry-slack if you want slack plugin, it can be done later
  6. Run docker-compose restart sentry
  7. Sentry is now running on public port 9000
@StoneMoe
StoneMoe / supervisor.conf
Created September 26, 2019 14:50 — forked from hezhao/myapp.conf
Example supervisor config file /etc/supervisor/conf.d/myapp.conf
[program:myapp]
autostart = true
autorestart = true
command = python /home/pi/myapp.py
environment=SECRET_ID="secret_id",SECRET_KEY="secret_key_avoiding_%_chars"
stdout_logfile = /home/pi/stdout.log
stderr_logfile = /home/pi/stderr.log
startretries = 3
user = pi
@StoneMoe
StoneMoe / traceicmpsoftirq.py
Created December 19, 2019 11:07 — forked from iAklis/traceicmpsoftirq.py
ICMP packet tracer using BCC
#!/usr/bin/python
bpf_text = """
#include <linux/ptrace.h>
#include <linux/sched.h> /* For TASK_COMM_LEN */
#include <linux/icmp.h>
#include <linux/netdevice.h>
struct probe_icmp_data_t
{
u64 timestamp_ns;
u32 tgid;