分类:网络技术日期:2018-04-09 - 19:23:01评论:4条作者:老谢
需求说明
由于设备量较大,如何有效的备份交换机设备配置文件就成了问题,经过一番搜索和对比,最终决定使用上传配置文件到tftp的方式进行备份,下面的脚本使用telnetlib库进行操作,感谢大D牛倾情技术支持,再次谢过大D神犇。
修改说明
Guge上传的V3.0源码仅支持Cisco的交换机,在大D牛的技术支持下,增加了H3C的支持(部分老版本的H3C可能会备份失败),同时也会按照时间自动分目录进行备份,下一步的想法会加入json的支持以及GUI。
main.py V4.0(测试环境Python 2.7.14)
#!/usr/bin/python
#by Kuhn 2014-03-29
#Updata by Derek.s && Jason 2018-04-09
import sys
import os
import telnetlib
import getpass
import datetime
import pexpect
import re
host = ""
user = "123"
password = "123"
#password = "123"
enpw = "123"
h3cpw = "123"
tftpserver = "8.8.8.8"
now = datetime.datetime.now()
def main():
for host in open("sw.txt", "r").readlines():
dsthost = host.strip('\n')
try:
tn = telnetlib.Telnet(dsthost,port=23,timeout=10)
except:
print "Can't connection %s"%dsthost
continue
#tn.read_until("Username:")
#tn.write(user+"\n")
try:
tn.read_until("Password:")
tn.write(password+"\n")
result = tn.read_some()
rex_h3c_bin_1 = r'%Wrong password'
login_Failed_H3C_1 = re.search(rex_h3c_bin_1, result)
rex_h3c_bin_2 = r'%Username or password is invalid.'
login_Failed_H3C_2 = re.search(rex_h3c_bin_2, result)
except:
print "Connection error %s"%dsthost
continue
#print(login_Failed_H3C_1, login_Failed_H3C_2)
if((login_Failed_H3C_1 is None) and (login_Failed_H3C_2 is None)):
#print("cisco")
try:
tn.write("en\n")
tn.read_until("Password:")
tn.write(enpw+"\n")
tn.read_until("#")
tn.write("copy running-config tftp:\n")
tn.write(tftpserver+"\n")
tn.write(now.strftime("%Y/%m/%d")+"/"+host+"\n")
tn.read_until("#")
tn.close
print now.strftime("%Y/%m/%d") + " " + dsthost + " Backup successful."
except:
print "Connection error %s"%dsthost
continue
else:
#print("H3c")
try:
tn.write(h3cpw+"\n")
tn.read_until(">")
tn.write("tftp "+tftpserver+" put flash:/startup.cfg"+" "+now.strftime("%Y/%m/%d")+"/"+host+"\n")
tn.read_until(">")
tn.close
print now.strftime("%Y/%m/%d") + " " + dsthost + " Backup successful(h3c)."
except:
print "Connection error %s"%dsthost
continue
if __name__=="__main__":
main() |
#!/usr/bin/python
#by Kuhn 2014-03-29
#Updata by Derek.s && Jason 2018-04-09
import sys
import os
import telnetlib
import getpass
import datetime
import pexpect
import re
host = ""
user = "123"
password = "123"
#password = "123"
enpw = "123"
h3cpw = "123"
tftpserver = "8.8.8.8"
now = datetime.datetime.now()
def main():
for host in open("sw.txt", "r").readlines():
dsthost = host.strip('\n')
try:
tn = telnetlib.Telnet(dsthost,port=23,timeout=10)
except:
print "Can't connection %s"%dsthost
continue
#tn.read_until("Username:")
#tn.write(user+"\n")
try:
tn.read_until("Password:")
tn.write(password+"\n")
result = tn.read_some()
rex_h3c_bin_1 = r'%Wrong password'
login_Failed_H3C_1 = re.search(rex_h3c_bin_1, result)
rex_h3c_bin_2 = r'%Username or password is invalid.'
login_Failed_H3C_2 = re.search(rex_h3c_bin_2, result)
except:
print "Connection error %s"%dsthost
continue
#print(login_Failed_H3C_1, login_Failed_H3C_2)
if((login_Failed_H3C_1 is None) and (login_Failed_H3C_2 is None)):
#print("cisco")
try:
tn.write("en\n")
tn.read_until("Password:")
tn.write(enpw+"\n")
tn.read_until("#")
tn.write("copy running-config tftp:\n")
tn.write(tftpserver+"\n")
tn.write(now.strftime("%Y/%m/%d")+"/"+host+"\n")
tn.read_until("#")
tn.close
print now.strftime("%Y/%m/%d") + " " + dsthost + " Backup successful."
except:
print "Connection error %s"%dsthost
continue
else:
#print("H3c")
try:
tn.write(h3cpw+"\n")
tn.read_until(">")
tn.write("tftp "+tftpserver+" put flash:/startup.cfg"+" "+now.strftime("%Y/%m/%d")+"/"+host+"\n")
tn.read_until(">")
tn.close
print now.strftime("%Y/%m/%d") + " " + dsthost + " Backup successful(h3c)."
except:
print "Connection error %s"%dsthost
continue
if __name__=="__main__":
main()
参考:http://mybeibei.net/157.html
分类:网络技术日期:2018-04-02 - 21:03:59评论:0条作者:老谢
EVE-NG(全称Emulated Virtual Environment – NextGeneration),继Unetlab 1.0后的Unetlab的2.0新版本,改了名字,原名是UnifiedNetworking Lab统一网络实验室。笔者觉得名字改的非常合理,这款模拟器已经不仅可以模拟网络设备,也可以运行一切虚拟机。理论上,只要能将虚拟机的虚拟磁盘格式转换为qcow2都可以在EVE-NG上运行。所以,EVE-NG可以算得上是仿真虚拟环境。EVE-NG是国外大神们开发的,融合了dynamips,IOL,KVM。它是深度定制的Ubuntu操作系统,可以直接把它安装在x86架构的物理主机上。它也有ova版本,可以导入到VMware等虚拟机软件中运行。EVE-NG在交互模式上更加具有优势,与GNS3截然不同。GNS3更像是用户使用的软件,只有GNS3支持的 OS才能使用;而EVE-NG更像是CS模型,EVE-NG是服务端,用户端可以是支持http/https的任意OS。
EVE-NG模拟器的安装配置
可以在EVE-NG官网下载到ova格式的虚拟机文件,在VMware Workstation Pro或VSPHERE等虚拟机中导入即可,root的默认密码是eve,老版本可能是unl,第一次进入系统会进入初始化配置界面,按照向导进行设置即可,之后会自动进行重启,再次进入系统可以使用apt-get update获取更新列表,然后使用apt-get install eve-ng安装eve-ng的更新版本。
使用vim将下面的python脚本写到文件,然后使用命令pydoc3 文件名执行后即可进行破解并自动写入序列号。
CiscoIOUKeygen.py
#! /usr/bin/python
print("*********************************************************************")
print("Cisco IOU License Generator - Kal 2011, python port of 2006 C version")
print("Modified to work with python3 by c_d 2014")
import os
import socket
import hashlib
import struct
# get the host id and host name to calculate the hostkey
hostid=os.popen("hostid").read().strip()
hostname = socket.gethostname()
ioukey=int(hostid,16)
for x in hostname:
ioukey = ioukey + ord(x)
print("hostid=" + hostid +", hostname="+ hostname + ", ioukey=" + hex(ioukey)[2:])
# create the license using md5sum
iouPad1 = b'\x4B\x58\x21\x81\x56\x7B\x0D\xF3\x21\x43\x9B\x7E\xAC\x1D\xE6\x8A'
iouPad2 = b'\x80' + 39*b'\0'
md5input=iouPad1 + iouPad2 + struct.pack('!I', ioukey) + iouPad1
iouLicense=hashlib.md5(md5input).hexdigest()[:16]
print("\nAdd the following text to ~/.iourc:")
print("[license]\n" + hostname + " = " + iouLicense + ";\n")
print("You can disable the phone home feature with something like:")
print(" echo '127.0.0.127 xml.cisco.com' >> /etc/hosts\n")
lic = ["[license]\n" + hostname + " = " + iouLicense + ";" + "\n"]
f = open('/opt/unetlab/addons/iol/bin/iourc','w')
f.writelines(lic)
f.close() |
#! /usr/bin/python
print("*********************************************************************")
print("Cisco IOU License Generator - Kal 2011, python port of 2006 C version")
print("Modified to work with python3 by c_d 2014")
import os
import socket
import hashlib
import struct
# get the host id and host name to calculate the hostkey
hostid=os.popen("hostid").read().strip()
hostname = socket.gethostname()
ioukey=int(hostid,16)
for x in hostname:
ioukey = ioukey + ord(x)
print("hostid=" + hostid +", hostname="+ hostname + ", ioukey=" + hex(ioukey)[2:])
# create the license using md5sum
iouPad1 = b'\x4B\x58\x21\x81\x56\x7B\x0D\xF3\x21\x43\x9B\x7E\xAC\x1D\xE6\x8A'
iouPad2 = b'\x80' + 39*b'\0'
md5input=iouPad1 + iouPad2 + struct.pack('!I', ioukey) + iouPad1
iouLicense=hashlib.md5(md5input).hexdigest()[:16]
print("\nAdd the following text to ~/.iourc:")
print("[license]\n" + hostname + " = " + iouLicense + ";\n")
print("You can disable the phone home feature with something like:")
print(" echo '127.0.0.127 xml.cisco.com' >> /etc/hosts\n")
lic = ["[license]\n" + hostname + " = " + iouLicense + ";" + "\n"]
f = open('/opt/unetlab/addons/iol/bin/iourc','w')
f.writelines(lic)
f.close()
继续阅读…
分类:乱七八糟日期:2018-03-25 - 22:14:31评论:3条作者:老谢
本来屏幕上有个坏点,电池循环次数700+,本来想走AC+免费把电池和屏幕换掉,然后最后一次摔手机,在屏幕和壳的链接处凹进去了一块,被拒保了…所以干脆走AC+意外险换了新机..无锡恒隆广场的直营店,总体感觉一般,预约检测完机器一个小时后拿到新机,然后付款就可以走人了。

分类:乱七八糟日期:2018-01-21 - 10:37:22评论:7条作者:老谢
2017算得上很关键的一年,开始了新的生活,算一算也已经离开家在外快10年了。
生活
通过所有考试,顺利拿到毕业证书以及申请学位证书。股票一波三折,一波操作失误没救回来,最终亏损10个点。
工作
转变很大。
学习
进展缓慢。
计划
2017年目标的完成情况:
- 感情顺其自然 完成(什么时候领证呢)
- 股票翻番 失败(亏损)
- 拔掉两颗智齿 完成(四颗)
- 苏州稳定下来 完成(基本稳定)
- 第一辆车 完成
- 坚持健身,减脂成功,练出腹肌 失败
- 除换一部iPhone以及刚需的产品,不再买任何大件(超过3000元)数码产品 失败(也没换iPhone),18年不剁手!
2018目标:
- 通过CCNA
- 通过CCNP
- 学习Python
- 学习PHP+MySQL
- 搭建Zabbix监控平台,开始运维自动化的工作
- 恢复健身,坚持健身
- 节约开支,争取买房
数据

总结
无。
历年总结
2016年末总结
2015年末总结
2014年末总结
2013年末总结
2012年末总结
2011年末总结
2010博客访问分析
分类:网络技术日期:2017-10-30 - 21:36:17评论:11条作者:老谢
由于一些需求,在DS216的基础上又增加了一台DS116作为辅助存储的设备,设置配置DS116的时候看到可以使用短信接口进行通知,碰巧感兴趣折腾一波:
<?php
$u = $_GET['u'];
$p = $_GET['p'];
$m = substr($_GET['m'],3,14);
$c = '【Synology】'.$_GET['c'];
$result = 'http://www.smsbao.com/sms?u='.$u.'&p='.md5($p).'&m='.$m.'&c='.urlencode($c);
file_get_contents($result);
?> |
<?php
$u = $_GET['u'];
$p = $_GET['p'];
$m = substr($_GET['m'],3,14);
$c = '【Synology】'.$_GET['c'];
$result = 'http://www.smsbao.com/sms?u='.$u.'&p='.md5($p).'&m='.$m.'&c='.urlencode($c);
file_get_contents($result);
?>
接口规则
http://www.xj123.info/tool/smsbao_synology.php?u=用户名&p=密码&m=+86电话号码&c=内容 |
http://www.xj123.info/tool/smsbao_synology.php?u=用户名&p=密码&m=+86电话号码&c=内容
根据国内运营商要求,必须加上【XXX】的内容才能发送短信,要单独写个接口是因为国际化的DSM在通知填写号码的时候,强制填写国际代码,所以号码前面会加“+86”这3个字符,而短信宝又太本土化,加了+86就发送不了短信了…
分类:linux日期:2017-10-29 - 0:06:12评论:0条作者:老谢
抽空给一台闲置的笔记本装了CentOS,完事插网线发现ifconfig没有eth0地址,做出如下调整后可以正常从HDCP获取到IP地址,编辑网络接口配置文件:
/etc/sysconfig/network-scripts/ifcfg-eth0 |
/etc/sysconfig/network-scripts/ifcfg-eth0
将ONBOOT改为yes,NM_CONTROLLED改为no,BOOTPROTO改为dhcp之后,重启网络连接即可:service network restart。

分类:网站技术日期:2017-09-11 - 11:50:44评论:1条作者:老谢
yum install openldap openldap-devel -y
cp -frp /usr/lib64/libldap* /usr/lib/ |
yum install openldap openldap-devel -y
cp -frp /usr/lib64/libldap* /usr/lib/
phpize 命令是用来准备 PHP 扩展库的编译环境的。随着工作需要,如果想增加模块但又不想重新编译php时就可以使用phpize。
cd php-5.3.28
cd ext/ldap/
/usr/local/php/bin/phpize
./configure -with-ldap -with-php-config=/usr/local/php/bin/php-config
make && make install |
cd php-5.3.28
cd ext/ldap/
/usr/local/php/bin/phpize
./configure -with-ldap -with-php-config=/usr/local/php/bin/php-config
make && make install
vi /usr/local/php/etc/php.ini
添加 extension = "ldap.so" 重启LNMP即可。 |
vi /usr/local/php/etc/php.ini
添加 extension = "ldap.so" 重启LNMP即可。
分类:linux日期:2017-08-10 - 16:47:30评论:1条作者:老谢
安装系统
- SDFormatter
- win32diskimager
请从树莓派官网下载系统镜像,然后使用SDFormatter对TF卡进行格式化,格式化以后运行win32diskimager,选择系统镜像以及盘符以后,点击write,等待写入完全,等到出现对话框write successful就说明成功了。

继续阅读…
分类:乱七八糟日期:2017-08-01 - 13:36:42评论:0条作者:老谢
准备工作
需要是破解的系统,无论是A9还是B9,只需要能装cia即可
- 工具包下载链接: http://pan.baidu.com/s/1jIeeO9w 密码: vs3z
- 安装工具包里面的savedatafiler.cia到3DSLL
提取存档
运行安装的SDF程序,然后选择中间的Ext,找到01971(黑色字)不要点进去,按Y提取,有提示按A。提示完成以后,拆后盖,读取TF卡,里面有一个Filer目录,这个目录就是提取出来的存档。
修改存档
运行MHXX存档修改_v1021,打开“打开存档”,选择文件路径根目录\filer\ExtData\20170801131245\00001971,之后即可载入存档,在修改器的主界面就可以直接修改名字,然后保存存档即可。
当然也可以改全部的数据 .. 为了游戏性,强烈不建议修改任何游戏数据!!!!!
导入存档
再次运行安装的SDF程序,选择SD的选项,应该只有1个存档,存档名为:2017080122858 1971,按A进行导入,有提示选择YES,导入后,再进游戏看看吧:)
最新评论
springwood:自从 CentOS 不维护之后,我换 U...
大D:难都搞下来了,那就更得YM了
大D:只能是YM了,谢总牛啊
灰常记忆:经济不好 今年我也换了机器 一...
大峰:这是海外服务器嘛?速度挺快的。
大D:只能单走一个6了哈哈哈
zwwooooo:买特斯拉和买iPhone的人群其实相似...
平安家属子痕:一直坚持油车,看你写的心里有...
秦大叔:室内每年能开2万公里电车确实划算 ...
灰常记忆:尊贵的特斯拉车主啊,对了一直对单...