Skip to content

Instantly share code, notes, and snippets.

@hexchain
hexchain / Naive-VPN.md
Last active May 30, 2018 — forked from klzgrad/Naive-VPN.md
朴素VPN:一个纯内核级静态隧道
View Naive-VPN.md

朴素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

@hexchain
hexchain / weechat_bot2human.py
Created Mar 17, 2016 — forked from bigeagle/weechat_bot2human.py
Replace IRC message nicknames with regex match from chat text
View weechat_bot2human.py
# -*- coding:utf-8 -*-
# Bot2Human
#
# Replaces messages from bots to humans
# typically used in channels that are connected with other IMs using bots
#
# For example, if a bot send messages from XMPP is like `[nick] content`,
# weechat would show `bot | [nick] content` which looks bad; this script
# make weecaht display `nick | content` so that the messages looks like
# normal IRC message
@hexchain
hexchain / 51-noto-color-emoji.conf.xml
Last active Jul 7, 2020
Emoji on Linux desktop. Use with aur/cairo-coloredemoji.
View 51-noto-color-emoji.conf.xml
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/conf.avail/51-noto-color-emoji.conf -->
<fontconfig>
<selectfont>
<acceptfont>
<pattern>
<patelt name="family"><string>Noto Color Emoji</string></patelt>
</pattern>
</acceptfont>
View weechatpreview.py
# weechat script to display image in terminal
# (tested in termite, which is based on vte-ng)
# requirements:
# * weechat (of course)
# * w3m (for w3mimgdisplay)
# * imlib2-webp (optional, for webp support)
#
# save this script as ~/.weechat/python/test.py and load using
# /python load test.py
# in weechat.
View gauth-restore
#!/usr/bin/env python3
import sqlite3
import sys
import subprocess
from urllib.parse import quote
def main():
if len(sys.argv) < 2:
View keybase.md

Keybase proof

I hereby claim:

  • I am hexchain on github.
  • I am hexchain (https://keybase.io/hexchain) on keybase.
  • I have a public key whose fingerprint is FBCC 1044 8F42 2D19 E752 01C3 D70E 8B08 E0BC 48DF

To claim this, I am signing this object:

View rating.html
<!doctype html>
<html>
<head>
<title>Starry Test</title>
<style>
.rating {
unicode-bidi: bidi-override;
direction: rtl;
}
@hexchain
hexchain / ssqr
Last active Dec 11, 2019
Generate QR code from Shadowsocks config json
View ssqr
#!/usr/bin/env python
from __future__ import print_function
from sh import qrencode
import base64
import json
import sys
View PKGBUILD
# $Id: PKGBUILD 249747 2015-10-24 17:16:42Z heftig $
# Maintainer: Ionut Biru <ibiru@archlinux.org>
pkgbase=pygobject
pkgname=(python-gobject python2-gobject pygobject-devel)
pkgver=3.18.2
pkgrel=1
arch=(i686 x86_64)
url="https://live.gnome.org/PyGObject"
license=(LGPL)
@hexchain
hexchain / cmgerrit-cherrypick-starred-changes.py
Last active Aug 29, 2015
Cherry-Pick starred changes (put in CyanogenMod source root)
View cmgerrit-cherrypick-starred-changes.py
#!/usr/bin/env python3
from __future__ import print_function
import requests
import glob
import json
import os
from lxml import etree
from requests.auth import HTTPDigestAuth