Skip to content

Instantly share code, notes, and snippets.

@ihciah
ihciah / NetworkAutofix.sh
Last active January 10, 2019 20:45
NetworkAutofix
#!/bin/bash
#This script is used for testing network, if it is down then restart service.
INNER_NETWORK_CHECK_IP='10.141.247.181 10.108.255.249';
INNER_NETWORK_PING_COUNT=5;
INNER_NETWORK_MAX_FAIL=5;
INNER_NETWORK_FAIL_SLEEP=10;
INNER_NETWORK_TIMEOUT=50;
IPV6_NETWORK_CHECK_IP='l6.ihc.im www.ipv6.fudan.edu.cn';
@ihciah
ihciah / README.md
Last active June 8, 2018 08:14
AWS used bandwidth query script (Mainly used for query free bandwidth)

You should pip install boto3 first.

Go to IAM Management Console to create access key.

Also, you should modify the instance_id and region_name in the script above.

Then, you can call get_used_bandwidth() to get used bandwidth in Byte, or just run the script to get it in GB.

@ihciah
ihciah / set_route.py
Last active February 13, 2020 12:53
Set route script for tinc on windows
#!/bin/python
# -*- coding: utf-8 -*-
# I found the interface id is not a fixed value...
import subprocess
INTERFACE = "tincvpn"
ROUTE = "route add 10.0.0.0 mask 255.0.0.0 192.168.102.199 metric 1 if %s"
def get_interface_id():
interfaces = subprocess.check_output("netsh int ipv4 show interfaces")
@ihciah
ihciah / sugar-trigger.py
Created August 9, 2017 06:03
Tinc Remote Start Script
#!/usr/bin/python
# __author__="ihciah"
# Call this script in ddns script
import hmac, base64, struct, hashlib, time, requests, sys
CONNECT_KEY = "ABCDABCDABCDABCD"
START_ADDRESS = "https://inner-proxy-server.ihc.im:23333/start-tinc"
STOP_ADDRESS = "https://inner-proxy-server.ihc.im:23333/stop-tinc"
CONNECT_ADDRESS = {"START": START_ADDRESS, "STOP": STOP_ADDRESS}
@ihciah
ihciah / dns.py
Last active August 11, 2017 18:34
Simple Dynamic DNS Server
#!/usr/bin/python
# __author__="ihciah"
# Need twisted and pyopenssl
from twisted.web import resource
from twisted.web import server as webserver
from twisted.internet import reactor, defer
from twisted.names import client, dns, error, server
from OpenSSL.SSL import Context, TLSv1_METHOD
import hmac, base64, struct, hashlib, time
@ihciah
ihciah / if-down-reboot.sh
Created August 8, 2017 04:32
if-down-reboot.sh
#!/bin/bash
#This script is used for testing network, if it is down then reboot.
while :
do
/bin/ping 223.6.6.6 -c 10 | /bin/grep ttl && echo "Fine." || /sbin/reboot;
/bin/sleep 20;
done;
@ihciah
ihciah / naughtyc0w.c
Created March 10, 2017 09:35 — forked from mak/naughtyc0w.c
exploit for CVE-2016-5195 nothing fancy
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/uio.h>
#include <sys/wait.h>
@ihciah
ihciah / subtitle_downloader.py
Last active March 5, 2023 10:33
Xunlei subtitle downloader
#!/usr/bin/python
# -*- coding: utf-8 -*-
# __author__ = 'ihciah'
# cid_hash_file function from https://github.com/binux/lixian.xunlei/blob/master/libs/tools.py
# Gist: https://gist.github.com/ihciah/30eda05ca36ee9f9f190067538b0ae04
import hashlib
import inotify.adapters
import os
import sys
@ihciah
ihciah / cidhash
Created November 16, 2016 17:18
Xunlei CID HASH tool
#!/usr/bin/python
#__author__ = ['binux', 'ihciah']
import hashlib
import os
import sys
def cid_hash_file(path):
h = hashlib.sha1()
size = os.path.getsize(path)
@ihciah
ihciah / pt.py
Created September 7, 2016 12:23
FDU PT autologin
# -*- coding: utf-8 -*-
# FDU PT autologin script
import requests
import time
import re
import hashlib
ptusername = "ihciah"
ptuserinfo = "xxxxxxxxxxxxxxxxxxxxx"