Skip to content

Instantly share code, notes, and snippets.

View coconut49's full-sized avatar
🐰
Focusing

49 coconut49

🐰
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am zfox49 on github.
  • I am zfox49 (https://keybase.io/zfox49) on keybase.
  • I have a public key whose fingerprint is 3216 55FD F882 A8C1 E294 09F3 9285 232B 68DC 5B97

To claim this, I am signing this object:

@coconut49
coconut49 / hosts
Created July 24, 2016 11:04
OneNote Hosts For China With Microsoft HongKong CDN
204.79.197.212 onedrive.live.com
204.79.197.212 skyapi.onedrive.live.com
204.79.197.212 d.docs.live.net
204.79.197.212 dm2304files.storage.live.com
204.79.197.212 ocws.officeapps.live.com
40.74.129.10 www.onenote.com
104.210.40.87 nexus.officeapps.live.com
204.79.197.212 ocos-office365-s2s.msedge.net
204.79.197.212 directory.services.live.com
204.79.197.212 docs.live.net
import iptools
with open("chn.txt") as f,open("proxifier.txt",mode="w") as o:
line = f.readline()
while line:
ip,netmask = line.split(" ")
print("Now Processing IP: "+str(ip)+" Netmask: "+str(netmask))
ipstart,ipend=iptools.ipv4.subnet2block(str(ip)+"/"+str(netmask))
o.writelines(ipstart+"-"+ipend+"\n")
line = f.readline()
import iptools
with open("chn.txt") as f,open("chnroute-ipip.txt",mode="w") as o:
line = f.readline()
while line:
ip,netmask = line.split(" ")
print("Now Processing IP: "+str(ip)+" Netmask: "+str(netmask))
cidr = iptools.ipv4.netmask2prefix(str(netmask))
o.writelines("prefixcmd "+str(ip)+"/"+str(cidr)+" suffixcmd\n")
line = f.readline()
@coconut49
coconut49 / unicode_escape.py
Created September 9, 2016 07:39 — forked from omsobliga/unicode_escape.py
Python 在什么情况下会输出 Unicode 字符串
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" 测试 Python 在什么情况下会输出 Unicode 字符串
需要首先理解在 Python 中 Unicode 类型和 Unicode 字符串指的不是同一个东西。
Unicode 字符串是 str 类型,但它的值的表现形式是 Unicode 编码形式。
"""
def printt(str):
@coconut49
coconut49 / 0_reuse_code.js
Created November 3, 2016 05:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@coconut49
coconut49 / updateTorIP.py
Last active December 15, 2017 15:22
a python function, ask Tor change to a new IP. Usually use for small spider.
import requests
import socket
def updateTorIP(host="127.0.0.1", port=9051, passwd="mypassword", torProxy="socks5://127.0.0.1:9050"):
if torProxy:
proxies = {
"http": torProxy,
"https": torProxy,
}
else:
@coconut49
coconut49 / GPG中AES.RSA加密的怪异问题.md
Created December 31, 2016 13:40
GPG AES/RSA 加密的怪异问题.md

先说结论: gpg 会自动判断文件大小如果文件体积过大,则生成一个 一次性密钥并用 rsa 加密,然后用一次性密钥跑 aes 加密整个大文件。故当需要用 gpg 加密文件的时候不需要考虑文件大小直接加密即可 #加密文件

RSA4096 加密文件

➜ test time gpg -e 1.mp4 gpg2 -e 1.mp4 32.41s user 1.96s system 97% cpu 35.231 total

AES128 加密文件口令长度 7 位

➜ test time gpg -o 1.mp4.aes -c 1.mp4 gpg2 -o 1.mp4.aes -c 1.mp4 33.13s user 1.74s system 88% cpu 39.578 total

#!/bin/bash
function gen {
dd if=/dev/urandom bs=1 count=10000 2>/dev/null | tr -dc a-f0-9 | fold -w $1 | sed 's/^/0x/' | head -n 1
}
spi=`gen 8`
reqid=`gen 8`
auth_key=`gen 64`
enc_key=`gen 64`
@coconut49
coconut49 / ipsecctl
Last active February 6, 2017 16:13 — forked from shankerwangmiao/ipsecctl
微小改动坏人 ipsecctl 使用 gretap 替代 ipip
#!/bin/bash
function load_var {
eval $(cat ${1} <( echo -e '\nset -o posix;set\n') | env - bash --noprofile --norc --posix | sed 's/^/'$2'_/')
if [ -n "$IF_IPSEC6" ]; then
PEER_ENDPOINT=$PEER_ENDPOINT6
SELF_ENDPOINT=$SELF_ENDPOINT6
fi
}