Skip to content

Instantly share code, notes, and snippets.

View coconut49's full-sized avatar
🐰
Focusing

49 coconut49

🐰
Focusing
View GitHub Profile
@coconut49
coconut49 / main.go
Created August 21, 2019 03:23
Golang SSL Pinning
package main
import (
"context"
"crypto/sha256"
"crypto/tls"
"crypto/x509"
"encoding/pem"
"errors"
"fmt"
@coconut49
coconut49 / SimpleHTTPServerWithUpload.py
Created September 9, 2018 09:54 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@coconut49
coconut49 / 85-yubikey-screen-lock.rules
Last active November 4, 2017 18:19
a tiny script to auto lock and unlock gnome session
SUBSYSTEM=="usb", ACTION=="remove", ENV{ID_VENDOR_ID}=="1050", ENV{ID_MODEL_ID}="0407", RUN+="/usr/local/bin/yubikeylocker.sh"
SUBSYSTEM=="usb", ACTION=="add", ENV{ID_VENDOR_ID}=="1050", ENV{ID_MODEL_ID}=="0407", RUN+="/usr/local/bin/yubikeylocker.sh"
@coconut49
coconut49 / bird.conf
Created October 24, 2017 13:56
school ospf bird
router id 33.44.0.1;
protocol device {
scan time 10;
}
protocol kernel {
metric 64; # Use explicit kernel route metric to avoid collisions
# with non-BIRD routes in the kernel routing table
import none;
@coconut49
coconut49 / gpg-agent-forward.sh
Created May 15, 2017 07:10 — forked from dtaylor84/gpg-agent-forward.sh
Cygwin GPG Agent Forwarding Script (for use with Gpg4Win 3, requires openssh and ssh-pageant)
#!/bin/bash -e
remote="$1@$2"
echo -ne '\e]0;wait... '"$remote"'\a'
eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME")
localdir="$(cygpath -u "$APPDATA")/gnupg"
extrasock="$localdir/S.gpg-agent.extra" # file containing "PORT\nNONCE"
rdir='$HOME/.gnupg' # remote prefix
rinsock="$rdir/S.gpg-agent" # listen on this socket on server
@coconut49
coconut49 / timeout.py
Last active December 15, 2017 15:22
直接用,但不会抛异常,稳如狗
from contextlib import contextmanager
import signal
@contextmanager
def timeout(seconds=3):
class TimeoutError(Exception):
pass
def handler(*args,**kwargs):
print("[-] Timeout!")
raise TimeoutError
@coconut49
coconut49 / retry.py
Last active December 15, 2017 15:22
def ignore_error_and_retry(times=3):
def real_decorator(fn):
def warpper(*args, **kwargs):
try:
fn(*args, **kwargs)
except Exception as e:
print(str(e))
if not hasattr(warpper, "counter"):
warpper.counter = 1
else:
@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
}
#!/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 / 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