Skip to content

Instantly share code, notes, and snippets.

View bugparty's full-sized avatar
🎯
Focusing

Bowen Han bugparty

🎯
Focusing
View GitHub Profile
@bugparty
bugparty / Attack.sol
Created February 2, 2018 21:42 — forked from anonymous/Attack.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.17-nightly.2017.9.11+commit.fbe24da1.js&optimize=false&gist=
contract AbstractVault {
address[] public authorizedUsers;
address public owner;
address public withdrawObserver;
address public additionalAuthorizedContract;
address public proposedAAA;
uint public lastUpdated;
bool[] public votes;
address [] public observerHistory;
modifier onlyAuthorized() {
@bugparty
bugparty / AndroidMockUtil.java
Created June 23, 2017 10:09 — forked from dpmedeiros/AndroidMockUtil.java
Mock main thread handler for use in Android unit tests (requires Mockito and PowerMock)
package com.dpmedeiros.androidtestsupportlibrary;
import android.os.Handler;
import android.os.Looper;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito;
import java.util.concurrent.Executors;
@bugparty
bugparty / Naive-VPN.md
Created November 27, 2016 12:28 — 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

@bugparty
bugparty / check_unicom_cache.rb
Created October 31, 2016 16:01 — forked from mangege/check_unicom_cache.rb
检查有效的联通缓存服务器ip
require 'uri'
require 'net/http'
require 'timeout'
def check_server(ip)
uri = URI('http://ip.mangege.com/')
Timeout::timeout(3) do
Net::HTTP.start(ip, 80) do |http|
request = Net::HTTP::Get.new uri

##路径截断与合并##

PathRemoveArgs 去除路径的参数

PathRemoveBackslash 去除路径最后的反斜杠 ""

PathAddBackslash 在路径最后加上反斜杠 ""

PathRemoveBlanks 去除路径前后的空格

#!/usr/bin/env python3.2
# Benjamin James Wright <[email protected]>
# Maximum Subarray
def max_subarray(L):
current_sum = 0
current_index = -1
best_sum = 0
best_start_index = -1
best_end_index = -1
package main
import (
"net/http"
"net/url"
"log"
"io/ioutil"
"regexp"
"fmt"
//"net/http/httputil"
@bugparty
bugparty / adhoc
Created September 13, 2013 00:50 — forked from anonymous/adhoc
#!/bin/bash
#####################################
#Author: Leon Lee #
#email: [email protected] #
#QQ: 730395591 #
#Version: 1.0 #
#Note: If you have some good ideas #
# or advice, please mail me^^ #
#####################################