Skip to content

Instantly share code, notes, and snippets.

View bearice's full-sized avatar
🐻

Bearice Ren bearice

🐻
View GitHub Profile
_ = require 'underscore'
class Board
constructor: (@width=10,@height=10,@mine_count=10) ->
@cells = []
for i in [0..@width*@height-1]
@cells.push {x: i % @width, y: Math.floor(i / @width), c:'x', g:'x', b:false, v:false}
tmp = _.sample(@cells, @mine_count)
_.each tmp,(c) ->
@bearice
bearice / gist:8f87eb1f87bed8b3b4ee
Last active August 29, 2015 14:07
TCP TraceRoute of MITM attack on www.icloud.com
# captured packets ->https://www.cloudshark.org/captures/03a6b0593436
bearice@Bearice-Mac-Air-Haswell ~
%tcptraceroute 23.59.94.46 443 !26471 [9:23:19]
Selected device en0, address 192.168.100.16, port 52406 for outgoing packets
Tracing the path to 23.59.94.46 on TCP port 443 (https), 30 hops max
1 192.168.100.254 1.737 ms 0.793 ms 0.798 ms
2 111.192.144.1 2.893 ms 2.967 ms 2.422 ms
3 61.51.246.25 2.913 ms 2.893 ms 3.968 ms
4 124.65.61.157 4.824 ms 2.658 ms 3.902 ms

DAEMONTOOLS: http://cr.yp.to/daemontools.html

安装

apt-get install daemontools-run

安装之后使用 nohup setsid svscanboot >/dev/null 2>&1 启动(只需要安装后第一次启动,以后会随着系统自动启动)

新建服务

公网机器:
ip tunnel add tunnel0 remote {对方内网地址} local {本机内网地址} mode ipip
ifconfig tunnel0 192.168.123.1/24
ifconfig tunnel0 up
iptables -t nat -A POSTROUTING -s 192.168.123.0/24 -j MASQUERADE
内网机器:
ip tunnel add tunnel0 remote {对方内网地址} local {本机内网地址} mode ipip
ifconfig tunnel0 192.168.123.2/24
@bearice
bearice / gist:e2dd5d4245472e1b3992
Last active August 29, 2015 14:18
openssl bug
bearice@master ~%openssl x509 -text < r
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=JimuBox CA, O=Jimubox.com, OU=System Administrators, ST=Beijing, C=CN, L=Beijing/emailAddress=sa@jimubox.com
Validity
Not Before: Mar 20 03:29:19 2014 GMT
Not After : Mar 17 03:29:19 2024 GMT
#!/bin/bash
function get(){
echo "GET $1" >&2
curl -H"User-Agent: ADSL t\355 s\371 q\354/1.1 (iPad; iOS 7.1.1; Scale/2.00)" \
-H'Accept-Language: en;q=1, zh-Hans;q=0.9, fr;q=0.8, de;q=0.7, ja;q=0.6, nl;q=0.5' \
-s $1
}
vars=$(get 'http://bj.wokuan.cn/web/startenrequest.php' | perl -ne'print $1 if /((\w+=\w+\&)+\w+=\w+)/' | tr '&' "\n")
fs = require 'fs'
request = require 'request'
rp = require 'request-promise'
errors = require 'request-promise/errors'
JSONStream = require 'JSONStream'
http = require 'http'
cluster = require 'cluster'
http.globalAgent = new http.Agent
keepAlive: false
maxSockets: Infinity
@bearice
bearice / time_utils.erl
Created August 24, 2011 06:54
strftime for erlang
-module(time_utils).
-author("Bearice Ren <bearice@gmail.com>").
-export([strftime/2]).
strftime(Fmt,{_,_,_}=Time)->
strftime(Fmt,calendar:now_to_datetime(Time));
strftime(Fmt,{_,_}=Time)->
lists:reverse(strftime(str,Fmt,Time,[])).
@bearice
bearice / jquery.dnd.js
Created October 19, 2011 03:04
jQuery plugin for <del>Dungeon and Dragons</del> Drag and Drop Event
/**
* jQuery plugin for <del>Dungeon and Dragons</del> Drag and Drop Event
*/
(function($){
$.fn.dragAndDropFiles = function(options){
if(typeof(window.FileReader)=== 'undefined')return;
var defaults = {
MIME : ["image/png","image/jpeg","image/bmp"],
//accept = function(e){},
//cancel = function(e){},
bearice@Bearice-Mac-Air ~
%dig fanfou.icybear.net !693 [20:07:21]
; <<>> DiG 9.7.3-P3 <<>> fanfou.icybear.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2591
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 8
;; QUESTION SECTION: