Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
update sites are just mirrors of the node site.
Somehow I wrote a program to search for keys on the Internet and select them for an update site
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
try:
from urllib.request import Request, urlopen # Python 3
except:
from urllib2 import Request, urlopen # Python 2
import os,re, base64
from ConfigParser import ConfigParser
keys = {}
update = ConfigParser()
update_old = ConfigParser()
#Агент для поиска ссылок и ключей
BROWSER = "Mozilla/5.0 Gecko/20100101 Firefox/36.0"
NOD32 = ""
VER="/eset_upd/update.ver"#Файл обновлений
ESET = "http://update.eset.com"#сайт
PATH = "/opt/var/nod32"#локальное зеркало
TEMP="/opt/var/nod32/tmp"
ARCH = 'unrar e {} /opt/var/nod32/tmp'#программа для извлечения rar
def find_keys(s):
urls = re.findall(r'href=[\'"]?(http[^\'" >]+)',urlopen(Request(s,None,{"User-Agent":BROWSER})).read()) #Поиск ссылок на сайты
urls = [x for x in list(set(urls)) if ('nigma' not in x)and
('yandex' not in x)and
('mail' not in x)and
('google' not in x)and
('yahoo' not in x)and
('bing' not in x)]#Фильтрация всех левых сайтов
keys = []
for x in urls:#Поиск ключей по ссылкам
try:
html = urlopen(Request(x,None,{"User-Agent":BROWSER})).read()
keys.extend(re.findall(r'\s?Username\s?:\s?([A-Z]{3,5}-[0-9]{10})\s?<\w*\s?/?><?\w?/?>?\s?Password\s?:\s?([A-Za-z0-9]{10})\s?<?',html))
except:
print "Error in %s"%x
new_keys = {}
for x in keys: #Удаление дубликатов и перестройка массива
if not new_keys.has_key(x[0]):
new_keys[x[0]] = x[1]
print "Found %d keys at %s"%(len(new_keys),s)
return new_keys
def download_ver(keys):
global update, update_old
err = 0
auth = ""
if not os.path.isdir(os.path.dirname(PATH+VER)):
os.makedirs(os.path.dirname(PATH+VER))
if not os.path.isdir(TEMP):
os.makedirs(TEMP)
for x in keys:
auth = base64.encodestring("%s:%s"%(x,keys[x])).replace("\n","")
try:
verfile = open(TEMP+"/update.rar","wb")
verfile.write(urlopen(Request(ESET+VER,None,{"User-Agent":NOD32,"Authorization":"Basic %s"%auth})).read())
verfile.close()
if os.path.isfile(TEMP+"/update.ver"):
if os.path.isfile(TEMP+"/old_update.ver"):
os.remove(TEMP+"/old_update.ver")
os.rename(TEMP+"/update.ver",TEMP+"/old_update.ver")
os.system(ARCH.format(TEMP+"/update.rar"))
if os.path.isfile(TEMP+"/update.ver"):
update.read(TEMP+"/update.ver")
if os.path.isfile(TEMP+"/old_update.ver"):
update_old.read(TEMP+"/old_update.ver")
if os.path.isfile(PATH+"/update.ver"):
os.remove(PATH+"/update.ver")
os.rename(TEMP+"/update.rar", PATH+"/update.ver")
print "Worked KEY: %s, %s"%(x,keys[x])
break
except:
err+=1
auth=""
return auth
def download(sec,src,auth):
dst = PATH+src
if not os.path.isdir(os.path.dirname(dst)):
os.makedirs(os.path.dirname(dst))
try:
file = open(dst, "wb")
print "Loading[%s]: %s"%(sec, src)
file.write(urlopen(Request(ESET+src,None,{"User-Agent":NOD32,"Authorization":"Basic %s"%auth})).read())
file.close
except:
print "Error loading %s with %s"%(src,auth)
search = ["http://nigma.ru/?s=nod32+keys+Username+Password",
"http://yandex.ru/yandsearch?text=nod32+keys+Username+Password",
"https://www.google.com/search?q=nod32+keys+Username+Password"]
for s in search:
keys = find_keys(s)
if len(keys) > 0:
break
if len(keys) == 0:#если не нашлось - возьмем из файла
if os.path.isfile(PATH+"/keys.txt"):
keyfile = open(PATH+"/keys.txt", "r")
for x in keyfile:
k = x.replace('\r\n','').split(',')
keys[k[0]] = k[1]
keyfile.close()
else:
print "Create KEY file: %s \nUsername,Password"%(PATH+"/keys.txt")
else:
keyfile = open(PATH+"/keys.txt", "w")
for x in keys:
keyfile.write("%s,%s\r\n"%(x,keys[x]))
keyfile.close()
if len(keys) > 0:
key = download_ver(keys)
print "Downloading:"
for n in update.sections(): #Скачивание файлов
if (update.has_option(n,'file'))and(not update_old.has_section(n) or (update_old.has_section(n) and update.get(n,'file') != update_old.get(n,'file')) or (not os.path.isfile(PATH+update.get(n,'file'))))and(not update.has_option(n,'language') or update.get(n,'language') == '1049') :
if (update_old.has_section(n) and (os.path.isfile(PATH+update_old.get(n,'file')))):
os.remove(PATH+update_old.get(n,'file'))
if os.path.isdir(os.path.dirname(PATH+update_old.get(n,'file'))) and len(os.listdir(os.path.dirname(PATH+update_old.get(n,'file')))) == 0:
os.rmdir(os.path.dirname(PATH+update_old.get(n,'file')))
print("Removing[%s]: %s"%(n,update_old.get(n,'file')))
if not os.path.isfile(PATH+update.get(n,'file')):
download(n, update.get(n,'file'), key)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question