Skip to content

Instantly share code, notes, and snippets.

Tyr Chen Ctyr

Block or report user

Report or block Ctyr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Ctyr
Ctyr / wc.py
Created Feb 20, 2015
wc for python
View wc.py
import sys
totol_lines=totol_words=totol_characters=0
for loop in sys.argv[1:]:
pfile=open(loop,'rU')
lines=words=characters=0
for eve_line in pfile:
lines+=1
words+=len(eve_line.split())
characters+=len(eve_line)
print "%d\t%d\t%d\t%s"%(lines,words,characters,loop)
@Ctyr
Ctyr / random_mac.sh
Created Feb 20, 2015
generet random legel mac address
View random_mac.sh
#!/bin/bash
#Description:this program automatically generates random legal mac address
#Ver.2.0 2014-10-26
#Author:Tyr
#Usage:./random_mac.sh [num]
i=0
while [ "$i" -lt "$1" ]
do
random=$(hexdump -n6 -e '/1 ":%02x"' /dev/urandom)
if echo $random | grep -q '*';then
@Ctyr
Ctyr / record-wan-ip.sh
Created Feb 20, 2015
record wan ip address for openwrt
View record-wan-ip.sh
#!/bin/ash
#description:log the daily pppoe-wan ip address
#2014-12-2
#Tyr
log_file=/mnt/sda3/log/wan-ip.log
. /lib/functions/network.sh
network_get_ipaddr ip wan
@Ctyr
Ctyr / catch-ps-of-adbyby.sh
Last active Aug 29, 2015
monitor ps of adbyby for openwrt.
View catch-ps-of-adbyby.sh
#!/bin/bash
log_file=/mnt/sda3/log/adbyby.log
echo "
To:blog@chenhd.com
From:openwrt@chenhd.com
Subject:Netgear 3800 overload warning
I'm sorry to tell you the overload up to 5.
" > /tmp/mail.txt
@Ctyr
Ctyr / dnsmasq-config-for-gfw.sh
Created Feb 20, 2015
dnsmasq configuration for gfw,support google,facebook,twitter and youtube.
View dnsmasq-config-for-gfw.sh
#Google and Youtube
server=/.google.com/127.0.0.1#5300
server=/.google.com.hk/127.0.0.1#5300
server=/.gstatic.com/127.0.0.1#5300
server=/.ggpht.com/127.0.0.1#5300
server=/.googleusercontent.com/127.0.0.1#5300
server=/.appspot.com/127.0.0.1#5300
server=/.googlecode.com/127.0.0.1#5300
server=/.googleapis.com/127.0.0.1#5300
server=/.gmail.com/127.0.0.1#5300
View ghost.c
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
char canary[sizeof(CANARY)];
} temp = { "buffer", CANARY };
@Ctyr
Ctyr / log-failure.sh
Last active Aug 29, 2015
analyse pam failure
View log-failure.sh
#!/bin/bash
#description:log failure information
#2014-11-?
#2014-11-21 change:just send today log,not the whole log
cat /var/log/auth.log | grep failure >> /home/log/pam.failure
cat /var/log/auth.log | grep failure > /tmp/log/pam.failure
test=`cat /tmp/log/pam.failure`
if [ -n "$test" ];then
mutt -s "ECS-pam failure" mail@email.com < /tmp/log/pam.failure
fi
@Ctyr
Ctyr / serverlog.sh
Last active Aug 29, 2015
server log information
View serverlog.sh
#!/bin/bash
#description:analyse web server log.
#ver 0.1
#2014/11/20 Tyr analyse auth,message,apache,ssh,vsftpd
echo "
"
echo -e "=======================系统信息===========================
内核版本: `uname -a`
CPU信息: `cat /proc/cpuinfo | egrep "model name|cpu MHz|Processor"|cut -d : -f2`
View auto-index-copy.sh
#!/bin/bash
#=================匹配样式===============
pattern="^Internet Explorer [0-9]+$|^Windows Server (2003|2008|2008 R2|2012 and Windows Server 2012 R2)$|^Windows Vista$|^Windows 7$|^Windows 8 and Windows 8.1$|^Server Core installation option$|^ASP.NET MVC [2-5]\.[0-1]$|^Microsoft Office 20(07|10)$|^Microsoft Office for Mac$|^Other Microsoft Office Software$|^Microsoft SharePoint Server 2010$|^Microsoft Office Web Apps 2010$|^Microsoft Word Viewer$|^Microsoft Office Compatibility Pack Service Pack 3$|^Microsoft SharePoint Server 2010 Service Pack 2$"
#将完整的目录拆分为按照MS14-0XX来保存
for ((ci=56;ci<=79;ci++))
do
if [ "$ci" -eq "74" ];then #微软没有给MS14-075补丁,所以跳过这个
cat /home/ms-all | sed -n "/MS14-074/,/MS14-076/p" > /home/ms/MS14-074
ci=75
@Ctyr
Ctyr / install-asciiauarium.sh
Last active Aug 29, 2015
This script will automatically install asciiauarium
View install-asciiauarium.sh
#!/bin/bash
#description:auto-install scripts for asciiquarium.
#asciiquarm author is http://robobunny.com/wp/
#2014-11-22
#scripts writed by Tyr (http://tyr.so)
do_exit() {
cp $logfile $HOME/install_asciiquarium.log
rm $HOME/asciiquarium -rf
echo "
sorry install failed!
You can’t perform that action at this time.