From 8e0550a0734ecf72a370a43c4301483b69a3ab0c Mon Sep 17 00:00:00 2001 From: AceVest Date: Wed, 30 Dec 2015 12:09:41 +0800 Subject: [PATCH] ... --- .gitignore | 1 + learn/doc/Ace.Homebrew.itermcolors | 213 ++++++++++++++++++++++++++ tools/comm/dec2hex.py | 28 +++- tools/{oldtools => comm}/genpwd.py | 0 tools/{oldtools => comm}/nth.cc | 0 tools/hack/ettercap/filter.ef | Bin 2010 -> 0 bytes tools/oldtools/NetDetector.py | 147 ------------------ tools/oldtools/analyzeCSDN.py | 65 -------- tools/oldtools/baby.sh | 11 -- tools/oldtools/cpl | 37 ----- tools/oldtools/cpy.c | 58 ------- tools/oldtools/csc.cc | 73 --------- tools/oldtools/cscc.cc | 75 --------- tools/oldtools/utf8togb2312.pl | 41 ----- tools/python/AceGlobalConfSample.conf | 7 - tools/python/GetWanIP.py | 105 ------------- tools/python/Sensors.py | 65 -------- tools/python/__init__.py | 8 - tools/python/config.py | 12 -- tools/python/packges | 2 - tools/python/utils.py | 29 ---- 21 files changed, 238 insertions(+), 739 deletions(-) create mode 100644 learn/doc/Ace.Homebrew.itermcolors rename tools/{oldtools => comm}/genpwd.py (100%) rename tools/{oldtools => comm}/nth.cc (100%) delete mode 100644 tools/hack/ettercap/filter.ef delete mode 100755 tools/oldtools/NetDetector.py delete mode 100755 tools/oldtools/analyzeCSDN.py delete mode 100755 tools/oldtools/baby.sh delete mode 100755 tools/oldtools/cpl delete mode 100644 tools/oldtools/cpy.c delete mode 100644 tools/oldtools/csc.cc delete mode 100644 tools/oldtools/cscc.cc delete mode 100755 tools/oldtools/utf8togb2312.pl delete mode 100644 tools/python/AceGlobalConfSample.conf delete mode 100755 tools/python/GetWanIP.py delete mode 100755 tools/python/Sensors.py delete mode 100755 tools/python/__init__.py delete mode 100755 tools/python/config.py delete mode 100644 tools/python/packges delete mode 100755 tools/python/utils.py diff --git a/.gitignore b/.gitignore index d36b95c..1311e67 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ ish *.DS_Store *.swp +*.ef dvwa diff --git a/learn/doc/Ace.Homebrew.itermcolors b/learn/doc/Ace.Homebrew.itermcolors new file mode 100644 index 0000000..ceb8b12 --- /dev/null +++ b/learn/doc/Ace.Homebrew.itermcolors @@ -0,0 +1,213 @@ + + + + + Ansi 0 Color + + Blue Component + 0.0 + Green Component + 0.0 + Red Component + 0.0 + + Ansi 1 Color + + Blue Component + 0.032882384955883026 + Green Component + 0.0 + Red Component + 0.98047482967376709 + + Ansi 10 Color + + Blue Component + 0.0 + Green Component + 0.85098040103912354 + Red Component + 0.0 + + Ansi 11 Color + + Blue Component + 0.0 + Green Component + 0.89803922176361084 + Red Component + 0.89803922176361084 + + Ansi 12 Color + + Blue Component + 1 + Green Component + 0.0 + Red Component + 0.0 + + Ansi 13 Color + + Blue Component + 0.89803922176361084 + Green Component + 0.0 + Red Component + 0.89803922176361084 + + Ansi 14 Color + + Blue Component + 0.89803922176361084 + Green Component + 0.89803922176361084 + Red Component + 0.0 + + Ansi 15 Color + + Blue Component + 0.89803922176361084 + Green Component + 0.89803922176361084 + Red Component + 0.89803922176361084 + + Ansi 2 Color + + Blue Component + 0.0 + Green Component + 0.65098041296005249 + Red Component + 0.0 + + Ansi 3 Color + + Blue Component + 0.0 + Green Component + 0.60000002384185791 + Red Component + 0.60000002384185791 + + Ansi 4 Color + + Blue Component + 0.92527294158935547 + Green Component + 0.50906872749328613 + Red Component + 0.11661802977323532 + + Ansi 5 Color + + Blue Component + 0.69803923368453979 + Green Component + 0.0 + Red Component + 0.69803923368453979 + + Ansi 6 Color + + Blue Component + 0.69803923368453979 + Green Component + 0.65098041296005249 + Red Component + 0.0 + + Ansi 7 Color + + Blue Component + 0.74901962280273438 + Green Component + 0.74901962280273438 + Red Component + 0.74901962280273438 + + Ansi 8 Color + + Blue Component + 0.40000000596046448 + Green Component + 0.40000000596046448 + Red Component + 0.40000000596046448 + + Ansi 9 Color + + Blue Component + 0.0 + Green Component + 0.0 + Red Component + 0.89803922176361084 + + Background Color + + Blue Component + 0.0 + Green Component + 0.0 + Red Component + 0.0 + + Bold Color + + Blue Component + 0.0 + Green Component + 1 + Red Component + 0.0 + + Cursor Color + + Blue Component + 0.094117648899555206 + Green Component + 1 + Red Component + 0.13725490868091583 + + Cursor Text Color + + Blue Component + 0.0940093994140625 + Green Component + 0.0 + Red Component + 1 + + Foreground Color + + Blue Component + 0.0 + Green Component + 1 + Red Component + 0.0 + + Selected Text Color + + Blue Component + 1 + Green Component + 1 + Red Component + 1 + + Selection Color + + Blue Component + 0.019607843831181526 + Green Component + 0.22352941334247589 + Red Component + 0.031372550874948502 + + + diff --git a/tools/comm/dec2hex.py b/tools/comm/dec2hex.py index 0ce56fc..c7bc6d5 100755 --- a/tools/comm/dec2hex.py +++ b/tools/comm/dec2hex.py @@ -6,8 +6,28 @@ # Tue Apr 28 15:00:56 2015 # Description: none # ------------------------------------------------------------------------ +import sys -while True : - n = raw_input("Input Decimal: ") - hexs = "{0:X}".format(int(n)) - print hexs +def main() : + while True : + n = 0 + inputdata = raw_input("> ") + if inputdata.lower() == 'quit' : + sys.exit() + + try : + n = int(inputdata) + except ValueError,e : + print "ERROR: ", e + continue + + hexs = "{0:X} 0x{1:X}".format(n, n) + print hexs + + +if __name__ == "__main__" : + try : + main() + except KeyboardInterrupt : + print "Bye..." + pass diff --git a/tools/oldtools/genpwd.py b/tools/comm/genpwd.py similarity index 100% rename from tools/oldtools/genpwd.py rename to tools/comm/genpwd.py diff --git a/tools/oldtools/nth.cc b/tools/comm/nth.cc similarity index 100% rename from tools/oldtools/nth.cc rename to tools/comm/nth.cc diff --git a/tools/hack/ettercap/filter.ef b/tools/hack/ettercap/filter.ef deleted file mode 100644 index 4ea56e328c6fff026aee6a2122d45cdf277d3042..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2010 zcmbVM%Syvg5WRi*g8HaX-)MJk5*0U6L?~MDL8IVO6eLY;pd<=ex$p~I_y>N1x^*kA zx^(GI7cL5ZgEz^XNJp+|+Rfz5nKNgm$-Q4UtNMn%CVqcKQAkxx)4KGus$;r!+qn=7 z>pTH$xL#A%>te5=8Lne#wR6vGb|X$2E-S4`&xUQ)wPV{cEnnQ72^w^#glxhx;mBp0 z3=@}y5v*1go1X2ptS!Wo-OBbsb?04*xZMb)1g;vT2c)^+|Hpp!%b{&9at<)*C2mK)x#`S>?`<;;vbG8_UKXlmdnurM$C?e)7D0o#Ge$d}i zVO$^Ru-`rDFy|A)@P`ijy%2%(g*qNFU()jqKj_;%`ay^N-k9#4Vaywyx<2o-1vKh0 zMt<@>^M6V2v-uu@XE%E+zh+hdW&xF|T;qxDa{rl0!?b(oDkvJ>y4~S-PZvX%Q diff --git a/tools/oldtools/NetDetector.py b/tools/oldtools/NetDetector.py deleted file mode 100755 index 930750a..0000000 --- a/tools/oldtools/NetDetector.py +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------ -# File Name: NetDetector.py -# Author: AceZhao -# Copyright (C) 2013 GZRD,Tencent. All Rights Reserved. -# Fri Mar 29 11:09:56 2013 -# Description: none -# ------------------------------------------------------------------------ -import os -import sys -import socket -import logging -import time -from threading import Timer - -gPort = 0xACE -gSndPktCnt = 0xACE -gSndDst = '' -gPktSize = 100 -gSndHz = 100 -gSndDelay = 1 - - -logging.basicConfig(level=logging.DEBUG, - format='%(asctime)s %(message)s', - filename='log.{0}.txt'.format(time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))), - filemode='w+') - -class Storage(dict) : - def __getattr__(self, key) : - try : - return self[key] - except KeyError, k: - raise AttributeError, k - - def __setattr__(self, key, value) : - self[key] = value - - def __delattr__(self, key) : - try : - del self[key] - except KeyError, k: - raise AttributeError, k - - def __repr__(self) : - return '' - - -class Data(Storage) : - def __init__(self) : - self.Sn = 0 - self.size = 0 - self.Data = '0' - - def Init(self, sn, size) : - self.Sn = sn - self.Size = size - - msg = "" - for i in range(0, size-len(str(self.Sn))) : - msg += ' ' - - self.Data = str(self.Sn) + msg - - def InitWithMsg(self, msg) : - self.Sn = msg.strip() - self.Size = len(msg) - len(self.Sn) - self.Data = msg - - def GetData(self) : - return self.Data - - -def Log(s) : - logging.error(s) - - -gSndSn = 0 -def SndPkts() : - global gSndSn,gSndDelay,gSndPktCnt - data = Data() - data.Init(gSndSn, gPktSize) - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.bind(('', 2766)) - s.sendto(data.GetData(), (gSndDst, gPort)) - Log('sended sn {0}'.format(data.Sn)) - gSndSn += 1 - if gSndSn < gSndPktCnt : - Timer(gSndDelay, SndPkts, ()).start() - s.close() - -def Client() : - global gSndDelay, gSndSn, gSndPktCnt - gSndSn = 0 - print gSndDelay - Timer(gSndDelay, SndPkts, ()).start() - Log('send data size {0}'.format(gPktSize)) - while True : - print gSndSn, gSndPktCnt - if gSndSn >= gSndPktCnt : - break - time.sleep(1) - -def Server() : - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.bind(('',gPort)) - Log('waiting on port {0}'.format(gPort)) - while True : - (msg, (addr, port)) = s.recvfrom(1024) - data = Data() - data.InitWithMsg(msg) - print "dsfasdfads" - Log('received sn {0}'.format(data.Sn)) - -def main() : - mode = 'cli' - try : - mode = sys.argv[1] - except : - print "svr or cli ?" - sys.exit() - global gSndDst, gPort, gSndPktSize, gSndPktCnt, gSndHz, gSndDelay - - if mode == 'cli' : - if len(sys.argv) != 7 : - print "{0} ".format(sys.argv[0]) - sys.exit() - - gSndDst = sys.argv[2] - gPort = int(sys.argv[3]) - gSndPktSize = int(sys.argv[4]) - gSndPktCnt = int(sys.argv[5]) - gSndHz = int(sys.argv[6]) - gSndDelay = float(1.0 / (gSndHz+gSndHz*0.01)) - Client() - elif mode == 'svr' : - if len(sys.argv) != 3 : - print "{0} ".format(sys.argv[0]) - sys.exit() - gPort = int(sys.argv[2]) - Server() - else : - pass - -if __name__ == "__main__" : - main() diff --git a/tools/oldtools/analyzeCSDN.py b/tools/oldtools/analyzeCSDN.py deleted file mode 100755 index 29fc79b..0000000 --- a/tools/oldtools/analyzeCSDN.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -------------------------------------------------------------------------- -# File Name: analyzeCSDN.py -# Author: Zhao Yanbai -# Fri Jan 13 12:17:10 2012 -# Description: 将网络上泄露的CSDN网站的账号密码及电子邮件信息提取出来并构造 -# 成插入数据库的SQL语句 -# -------------------------------------------------------------------------- - -import re - -try : - inf = open("./www.csdn.net.sql", "r") - ouf = open("./csdn.sql", "w") -except IOError as ioerr : - print "Error: ", ioerr - exit(); - -# 将每10000条记录生成成一条SQL -# 如果一条SQL中含的记录太多,则在MYSQL中执行会超时 -itemperline = 10000 - -i = 0 -while True: - - line = inf.readline() - - if(len(line) == 0) : - ouf.write(";") - break; - - # 去掉行尾的 \r\n - line = line[:-2] - - # 将gb2312编码转换成utf-8编码 - try : - line = unicode(line, "gbk").encode("utf-8") - except UnicodeDecodeError as err : - print "Error Msg: ", err - print "Error Line: ", line - continue - - # 构造的SQL语句针对客串形式的参数需要用至"'" - # 所以需要将密码中的"'"转换成"\'",涉及到转义的问题,所以为"\\'" - # 如果\是最后一个字符也会造成SQL语句构造错误 - line = line.replace("\\", "\\\\") - line = line.replace("'", "\\'") - - # 提取用户名、密码、Email - D = re.findall(r'(.*) # (.*) # (.*)', line) - - # 构造SQL语句 - if(i % itemperline == 0) : - ouf.write("INSERT INTO csdn VALUES") - else : - ouf.write(",") - ouf.write("(NULL,'" + D[0][0] +"','" + D[0][1] +"','" + D[0][2] + "')") - if((i+1) % itemperline == 0) : - ouf.write(";") - - i += 1 - -inf.close(); -ouf.close(); diff --git a/tools/oldtools/baby.sh b/tools/oldtools/baby.sh deleted file mode 100755 index db8e119..0000000 --- a/tools/oldtools/baby.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# 哄baby睡觉的强力程序 -# 所要做的就是把光驱用绳子连在摇篮上 -# 网上视频中抄的 -while [ 1 = 1 ] -do - eject - - eject -t -done - diff --git a/tools/oldtools/cpl b/tools/oldtools/cpl deleted file mode 100755 index 1b45415..0000000 --- a/tools/oldtools/cpl +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/perl - -use strict; - -my $file = $ARGV[0]; -my $time = localtime(); -my $del; - -if(!$file){ - die "Please add your perl file name...\n"; -} - -if (-e $file){ - do{ - print "File $file already exists, delete...[y/N]"; - chomp ($del = ); - }while($del ne "y" && $del ne "N"); - - if($del eq "y"){ - unlink($file) || die "Can not delete file: $file\n"; - } - else{ - exit; - } -} - -open FILE, ">", "$file"; -print FILE "#!/usr/bin/perl\n"; -print FILE "# " . "-"x72 . "\n"; -print FILE "# File Name:\t$file\n"; -print FILE "# Author:\tZhao Yanbai\n"; -print FILE "# \t$time\n"; -print FILE "# Description:\tnone\n"; -print FILE "# " . "-"x72 . "\n"; -print FILE "use strict;\n\n"; -close FILE; -chmod 0755,$file; diff --git a/tools/oldtools/cpy.c b/tools/oldtools/cpy.c deleted file mode 100644 index f2be52b..0000000 --- a/tools/oldtools/cpy.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - *-------------------------------------------------------------------------- - * File Name: cpy.c - * - * Author: Zhao Yanbai [zhaoyanbai@126.com] - * Wed Jun 30 11:22:16 2010 - * - * Description: none - * - *-------------------------------------------------------------------------- - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - int fd; - time_t now; - char timestr[256]; - char cmd[] = "#!/usr/bin/env python\n"; - char charset[] = "# -*- coding: utf-8 -*-\n"; - char line[] = "# -------------------------------------" - "-------------------------------------\n"; - char file[] = "# File Name:\t"; - char author[] = "\n# Author:\tZhao Yanbai\n#\t\t"; - char desc[] = "# Description:\tnone\n"; - - if(argc != 2) - { - printf("usage: %s \n", argv[0]); - exit(1); - } - - now = time(NULL); - strcpy(timestr, ctime(&now)); - - fd = open(argv[1], O_CREAT | O_WRONLY, - S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); - write(fd, cmd, strlen(cmd)); - write(fd, charset, strlen(charset)); - write(fd, line, strlen(line)); - write(fd, file, strlen(file)); - write(fd, argv[1], strlen(argv[1])); - write(fd, author, strlen(author)); - write(fd, timestr, strlen(timestr)); - write(fd, desc, strlen(desc)); - write(fd, line, strlen(line)); - - close(fd); - return 0; -} diff --git a/tools/oldtools/csc.cc b/tools/oldtools/csc.cc deleted file mode 100644 index 0d8ba11..0000000 --- a/tools/oldtools/csc.cc +++ /dev/null @@ -1,73 +0,0 @@ -// By Zhao Yanbai -// 2008.12.10 -// Version 1.0 -#include -#include -#include -#include -#include -using namespace std; -void usage() -{ - printf("usage...\n"); -} - -int main(int argc, char *argv[]) -{ - FILE *fp; - time_t now = time(NULL); - const char *sfile = argv[1]; - int len = strlen(sfile); - string project; - string hstr; - - if(argc != 2) - { - usage(); - return 1; - } - - if((fp = fopen(argv[1],"w+")) == NULL) - { - printf("cannot create file\n"); - return 1; - } - fprintf(fp,"/*\n"); - fprintf(fp," *--------------------------------------------------------------------------\n"); - fprintf(fp," * File Name:\t%s\n",argv[1]); - fprintf(fp," * \n"); - fprintf(fp," * Author:\tZhao Yanbai [zhaoyanbai@126.com]\n"); - fprintf(fp," * \t\t\t%s",ctime(&now)); - fprintf(fp," * \n"); - fprintf(fp," * Description:\tnone\n"); - fprintf(fp," * \n"); - fprintf(fp," *--------------------------------------------------------------------------\n"); - fprintf(fp," */\n\n"); - - if(argv[1][len-1] == 'h' && argv[1][len-2] == '.') - { - - cout<<"Project Name:"; - cin>>project; - - hstr += project; - hstr += "_"; - hstr += argv[1]; - - for(int i=0; i -#include -#include -#include -#include -using namespace std; -void usage() -{ - printf("usage...\n"); -} - -int main(int argc, char *argv[]) -{ - FILE *fp; - time_t now = time(NULL); - int len = strlen(argv[1]); - string project; - string hstr; - - if(argc != 2) - { - usage(); - return 1; - } - - if((fp = fopen(argv[1],"w+")) == NULL) - { - printf("cannot create file\n"); - return 1; - } - fprintf(fp,"/*\n"); - fprintf(fp," *--------------------------------------------------------------------------\n"); - fprintf(fp," * File Name:\t%s\n",argv[1]); - fprintf(fp," * \n"); - fprintf(fp," * Create Date: %s",ctime(&now)); - fprintf(fp," * \n"); - fprintf(fp," * Author:\tZhao Yanbai [zhaoyanbai@126.com]\n"); - fprintf(fp," * \t\tInformation Security Research Center Of\n"); - fprintf(fp," * \t\tHarbin Engineering University\n"); - fprintf(fp," * \n"); - fprintf(fp," * Description:\tnone\n"); - fprintf(fp," * \n"); - fprintf(fp," *--------------------------------------------------------------------------\n"); - fprintf(fp," */\n\n"); - - if(argv[1][len-1] == 'h' && argv[1][len-2] == '.') - { - - cout<<"Project Name:"; - cin>>project; - - hstr += project; - hstr += "_"; - hstr += argv[1]; - - for(int i=0; i){ - $line = $line . $_; - } - close INF; - - print "Processing... $filename\n" unless (detect($line) =~ /gb/); - $line=encode("gbk",decode("utf-8",$line)) unless (detect($line) =~ /gb/); - open OUTF, ">$filename"; - print OUTF $line; - close OUTF; - - - open INF, "<$filename"; - $line = ""; - while(){ - $line = $line . $_; - } - close INF; - unlink($filename) unless (detect($line) =~ /gb/); -} -closedir(DIR); diff --git a/tools/python/AceGlobalConfSample.conf b/tools/python/AceGlobalConfSample.conf deleted file mode 100644 index f9aed80..0000000 --- a/tools/python/AceGlobalConfSample.conf +++ /dev/null @@ -1,7 +0,0 @@ -[EMAIL] -MAILTO = xxx@xx.com -MAILHOST= smtp.xx.com -MAILUSER= xxx -USERNICK= xx -MAILPASS= ***** -MAILPOSTFIX= xx.com diff --git a/tools/python/GetWanIP.py b/tools/python/GetWanIP.py deleted file mode 100755 index 54905e6..0000000 --- a/tools/python/GetWanIP.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------ -# File Name: GetWanIP.py -# Author: Zhao Yanbai -# Thu Oct 30 04:34:37 2014 -# Description: none -# ------------------------------------------------------------------------ -import os -import re,urllib2 -import smtplib -import ConfigParser -import config -from email.mime.text import MIMEText -from utils import * - -''' - CONFIG FILE SAMPLE -[EMAIL] -MAILTO = xxx@xx.com -MAILHOST= smtp.xx.com -MAILUSER= xxxxx -USERNICK= xxx -MAILPASS= ***** -MAILPOSTFIX= xx.com -''' -''' - CONTAB -* * * * * root cd /xxx/xxx/xxx/ && python GetWanIP.py -''' - -TMP_FILE_PATH = '/tmp/GetWanIP.txt' -log = CreateLogger(config.ACE_GLOBAL_LOG_PATH) - -mailto_list=[] -mail_host="" #设置服务器 -mail_user="" #用户名 -user_nick="" -mail_pass="" #口令 -mail_postfix="" #发件箱的后缀 - -class GetWanIP: - def GetIP(self): - try: - log.info('Try ip.qq.com') - WanIP = self.Visit('http://ip.qq.com') - except: - s = 'Failed to Get WanIP!!!' - WanIP = s - log.error(s) - return WanIP - - def Visit(self,url): - opener = urllib2.urlopen(url) - if url == opener.geturl(): - str = opener.read() - return re.search('\d+\.\d+\.\d+\.\d+',str).group(0) - - -def send_mail(to_list,sub,content): #to_list:收件人;sub:主题;content:邮件内容 - me=user_nick+"<"+mail_user+"@"+mail_postfix+">" #这里的hello可以任意设置,收到信后,将按照设置显示 - msg = MIMEText(content,_subtype='html',_charset='gb2312') #创建一个实例,这里设置为html格式邮件 - msg['Subject'] = sub #设置主题 - msg['From'] = me - msg['To'] = ";".join(to_list) - try: - s = smtplib.SMTP() - s.connect(mail_host) #连接smtp服务器 - s.login(mail_user,mail_pass) #登陆服务器 - s.sendmail(me, to_list, msg.as_string()) #发送邮件 - s.close() - return True - except Exception, e: - log.error(str(e)) - return False -if __name__ == '__main__': - try : - fd = open(TMP_FILE_PATH) - OldWanIP = fd.readline().strip() - fd.close() - except : - OldWanIP = '0.0.0.0' - - getWanIP = GetWanIP() - WanIP = getWanIP.GetIP() - - cnfp = ConfigParser.ConfigParser() - cnfp.read(config.ACE_GLOBAL_CONF_PATH) - mailto_list.append(cnfp.get('EMAIL', 'MAILTO')) - mail_host = cnfp.get('EMAIL', 'MAILHOST') - mail_user = cnfp.get('EMAIL', 'MAILUSER') - user_nick = cnfp.get('EMAIL', 'USERNICK') - mail_pass = cnfp.get('EMAIL', 'MAILPASS') - mail_postfix = cnfp.get('EMAIL', 'MAILPOSTFIX') - - if OldWanIP != WanIP : - s = 'WanIP has Changed From ' + OldWanIP + ' To ' + WanIP - log.info(s) - if send_mail(mailto_list,u'外网IP有变动', s): - log.info('发送成功') - fd = open(TMP_FILE_PATH, 'w+') - fd.write(WanIP+'\n') - fd.close() - else: - log.error('发送失败') diff --git a/tools/python/Sensors.py b/tools/python/Sensors.py deleted file mode 100755 index af8a4e5..0000000 --- a/tools/python/Sensors.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------ -# File Name: Sensors.py -# Author: Zhao Yanbai -# Thu Oct 30 14:46:58 2014 -# Description: none -# ------------------------------------------------------------------------ - -import time -import serial -import os -import commands -import config -from utils import * - -log = CreateLogger(config.ACE_GLOBAL_LOG_PATH) - -s = serial.Serial('/dev/ttyACM0', 9600) - -ApiKey = 'c2ac9bff44b29c8f3edca022ed621aa9' -class Sensor : - def __init__(self, Name, url) : - self.Name = Name - self.Url = url - self.LastTs = 0 - self.Value = 0 - -Map = { } - -SensorList = [Sensor('Light', 'http://api.yeelink.net/v1.0/device/15328/sensor/26264/datapoints'), - Sensor('Temperature', 'http://api.yeelink.net/v1.0/device/15328/sensor/26256/datapoints')] - -for x in SensorList : - Map[x.Name] = x - -while True : - line = s.readline().strip() - - if line[0] != '>' : - continue - - log.info(line) - - (name, value) = line[1:].strip().split(': ') - if Map.get(name, None) == None : - continue - - if int(time.time()) - Map[name].LastTs < 10 : - continue - - log.info('Prepare to Report') - - Map[name].LastTs = int(time.time()) - Map[name].Value = float(value) - - json = '{"value":%f}' % Map[name].Value - fd = open('datafile.txt', 'w+') - fd.write(json + '\n') - fd.close() - - cmd = 'curl --request POST --data-binary @datafile.txt --header "U-ApiKey: '+ApiKey+'" ' + Map[name].Url - output = commands.getoutput(cmd) - log.info(output) - diff --git a/tools/python/__init__.py b/tools/python/__init__.py deleted file mode 100755 index eca95de..0000000 --- a/tools/python/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------ -# File Name: __init__.py -# Author: Zhao Yanbai -# Thu Oct 30 06:21:42 2014 -# Description: none -# ------------------------------------------------------------------------ diff --git a/tools/python/config.py b/tools/python/config.py deleted file mode 100755 index 30ad717..0000000 --- a/tools/python/config.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------ -# File Name: config.py -# Author: Zhao Yanbai -# Thu Oct 30 06:37:52 2014 -# Description: none -# ------------------------------------------------------------------------ - - -ACE_GLOBAL_CONF_PATH = '/etc/AceGlobal.conf' -ACE_GLOBAL_LOG_PATH = '/var/log/AceGlobal.log' diff --git a/tools/python/packges b/tools/python/packges deleted file mode 100644 index 0d0314f..0000000 --- a/tools/python/packges +++ /dev/null @@ -1,2 +0,0 @@ -pyinotify -https://github.com/seb-m/pyinotify/archive/0.9.4.tar.gz diff --git a/tools/python/utils.py b/tools/python/utils.py deleted file mode 100755 index b55788a..0000000 --- a/tools/python/utils.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------ -# File Name: utils.py -# Author: Zhao Yanbai -# Thu Oct 30 06:33:24 2014 -# Description: none -# ------------------------------------------------------------------------ - -import logging - -def CreateLogger(logpath, level=logging.DEBUG) : - logger = logging.getLogger(logpath) - fmtr = logging.Formatter('%(levelname)s\t%(asctime)s: %(message)s') - - fileHdlr = logging.FileHandler(logpath) - fileHdlr.setFormatter(fmtr) - fileHdlr.setLevel(level) - - streamHdlr = logging.StreamHandler() - streamHdlr.setFormatter(fmtr) - streamHdlr.setLevel(level) - - logger.addHandler(fileHdlr) - logger.addHandler(streamHdlr) - logger.setLevel(level) - - return logger - -- 2.44.0