| #!/usr/bin/python import re,string,commands,sys,string,os.path import smtplib from time import localtime,time,strftime work_dir='/home/samba/vol1/update_v/symantec' version_file='sym_version.log' #symantec web site symantec_url="http://securityresponse.symantec.com" #virus code data virus_data_url='/avcenter/download/pages/US-N95.html' #Email notify when update #Email_notify=1 enable email notify otherwise Email_notiyf=0 to turn it off Email_notify=1 notify_from ="set you sender email address" notify_email="your email address" notify_time=strftime('%m-%d-%H:%M',localtime(time())) notify_message="Symantec update virus at "+notify_time notify_subject='Update Symantec notify' print "Download virus data file....." print symantec_url+virus_data_url status_n,status_s=commands.getstatusoutput('wget --tries=3 --timeout=30 --wait=15 -O /tmp/US-N95.html '+symantec_url+virus_data_url) if status_n: print "Download virus data url error!" sys.exit(1) source_file=open("/tmp/US-N95.html").read() #get last_file last_file=re.search('[0-9]*-[0-9]*-i32.exe',source_file) if last_file==None: print "Parse error ! Couldn't found last_file in US-N95.html" sys.exit(1) last_file=last_file.group() ###################### #get last_file url ###################### #last_file_url=re.search('<a href="/[a-z0-9:/.-]*">',source_file) last_file_url=re.search('<a href="http://[a-z0-9/.-]*i32.exe">',source_file) if last_file_url==None: print "Parse error ! Couldn't found last_file_url in US-N95.html" sys.exit(1) last_file_url=last_file_url.group() last_file_url=string.split(last_file_url,'"')[1] ################### #get last_file md5 ################### last_file_md5=re.search('MD5[< ][/ :0-9A-Za-z>]*',source_file) if last_file_md5==None: print "Parse error ! Couldn't found last_file_md5 in US-N95.html" sys.exit(1) last_file_md5=last_file_md5.group() last_file_md5=string.strip(string.split(last_file_md5,':')[1]) need_update=0 #compare version file and last_file if os.path.exists(work_dir+"/"+version_file): version_f=open(work_dir+"/"+version_file,"r+") t_line=version_f.readline() if last_file>t_line: need_update=1 version_f.seek(0) else: version_f=open(work_dir+"/"+version_file,"w") need_update=1 if need_update: print "Download update file!" #update_url=symantec_url+last_file_url update_url=last_file_url status_n,status_f=commands.getstatusoutput('wget -O /tmp/'+last_file+' '+update_url) if status_n: print "can't get last update file!" sys.exit() #check md5 status_s=commands.getoutput('md5sum '+'/tmp/'+last_file) md5_string=string.split(status_s," ")[0] md5_string=string.upper(string.strip(md5_string)) if md5_string==last_file_md5: print "The md5 checksum is match !" else: print "The md5 Checksum is dismatch!" print "Download file:"+md5_string print "Web site :"+last_file_md5 sys.exit(1) print "Install the update file....." status_n,status_s=commands.getstatusoutput('mv -f /tmp/'+last_file+' '+work_dir+'/nav_db.exe') if status_n: print "update file fails!" else: status_s=commands.getoutput('rm -rf '+work_dir+"/*.txt") if email_notify : notify_message="Subject: "+notify_subject+"\n"+notify_message+"\n version="+last_file server=smtplib.SMTP('localhsot') server.sendmail(notify_from,notify_email,notify_message) server.quit() print "complete update file!" else: print "virus_file is up to date!" if need_update==1: version_f.write(last_file) version_f.close() |
| if Not
FileExists(@ScriptDir&"\"&@computername&".txt") Then run(@ScriptDir&"\nav_db.exe") winwait("SARC Intelligent Updater","",20) send("y") winwaitactive("SARC","½T©w") Send("{Enter}") FileOpen(@ScriptDir&"\"&@computername&".txt",2) endif exit |