Skip to content

Instantly share code, notes, and snippets.

View tawateer's full-sized avatar
Focusing

wateer tawateer

Focusing
  • Tencent
  • Beijing
View GitHub Profile
@tawateer
tawateer / iftop.py
Last active December 13, 2016 04:05 — forked from zhouqiang-cl/iftop.py
在机器上抓取到另一个网段的出入流量,基于 iftop,输出是 open-falcon 的数据收集格式。
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
@author: zhouqiang-cl@gmail.com
@date: 2016-12-12
抓取机器到另外一个机房的出入流量,并格式化输出. 包括到另外机房的每个ip的流量。
iftop 要使用较高的版本. centos 中建议 1.0pre4 以上.
"""
import subprocess
import socket
@tawateer
tawateer / http_base_for_openfalcon.py
Created December 13, 2016 03:31
http montior base for openfalcon
#!/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import time
import json
from urllib import urlencode
from io import BytesIO
@tawateer
tawateer / mysql_util.py
Last active December 13, 2016 03:30
Mysql util
#!/bin/env python
# -*- coding: utf-8 -*-
import sys
import MySQLdb
class MysqlConn(object):
def __init__(self, host, port, user, passwd, db=None):
@tawateer
tawateer / iptables.sh
Last active December 8, 2016 04:19
NAT 上控制访问外网的防火墙规则
#!/bin/bash
# 有两种权限:
# 1. 允许访问外网 WEB 端口(80, 443, 8080), 把 IP 加到 wl_web_ip 即可.
# 2. 允许访问外网所有流量, 基于 wl_all_ip, 把 IP 加到 wl_all_ip 即可.
iptables -F FORWARD
iptables -F BLOCK
iptables -F MON
@tawateer
tawateer / disk_table_and_fs.sh
Last active December 7, 2016 04:20
对大硬盘分区和创建文件系统
#!/bin/bash
disk="sda sdb sdc"
for i in $disk
do
j="/dev/${i}"
@tawateer
tawateer / ldap_op.py
Last active July 4, 2016 14:15
ldap example
#!/usr/bin/env python
import ldap
import base64
import hashlib
import binascii
import ldap.modlist as modlist
import subprocess
@tawateer
tawateer / kernel_conf.py
Last active July 3, 2016 02:28
配置内核参数
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
def shell(cmd):
""" 执行命令.
@tawateer
tawateer / iptables_example.sh
Last active June 13, 2016 06:59
iptables 例子
#!/bin/bash
accept_net="124.205.206.0/24 124.254.7.0/24 119.161.240.0/24 211.152.0.0/16 10.0.11.17/32 10.0.11.11/32 59.151.16.0/24 10.9.1.0/24"
/sbin/iptables -F
/sbin/iptables -Z
/sbin/iptables -X
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
#!/bin/env python
"""
https://github.com/juliensobrier/google-safe-browsing-lookup-python
"""
import safebrowsinglookup
API_KEY = ""
@tawateer
tawateer / dnscrypt-proxy.sh
Last active January 9, 2019 02:50
sniproxy + dnscrypt-proxy + dnscrypt-wrapper + dnsmasq 相关脚本
#!/bin/bash
sudo su -
wget http://download.dnscrypt.org/dnscrypt-proxy/dnscrypt-proxy-1.6.0.tar.gz
tar xvzf dnscrypt-proxy-1.6.0.tar.gz
cd dnscrypt-proxy-1.6.0
./configure
make
make install
cd ..