예제 #1
0
def load():
    open_log("load account")
    open_debug()
    parser = OptionParser()
    parser.add_option("-i", "--conf", dest="conf", action="store", type="string")
    parser.add_option("-n", "--num", dest="num", action="store", type="int")
    parser.add_option("-t", "--target", dest="target", action="store", type="string")

    options, args = parser.parse_args(sys.argv[1:])
    if not options.conf or not options.target:
        parser.print_help()
        sys.exit(-1)

    conf = DictIni(options.conf)
    num = options.num or 100000
    if os.path.exists(options.target):
        log.error("%s had exitst", options.target)
        return
    
    client = MagicClient(conf.account_server[0], int(conf.account_server[1]))
    total = 0
    f = file(options.target, 'w')
    log.trace("begin load data")
    while total < num:
        data = client.get_add_friends()
        if data:
            total += len(data)
            f.write('\n'.join([x.strip() for x in data]))
            log.trace("load account success %s", total)
        elif not data and not total:
            log.trace("load account %s fail")
            break
    f.close()
    log.trace("load accounts %s success %s", len(data), total)
예제 #2
0
    def get_contacts(self):
        if not hasattr(self, 'hostname'):
            self.hostname = 'mail.live.com'

        self.web.get_page('https://%s/mail/contacts.mvc?n=%s' % (self.hostname, randint(0, 1000000)))
        schema = urlparse.urlparse(self.web.url)
        if self.web.url.find('HipLight.aspx') != -1:
            log.error("now can not load contact")
            return None

        if schema.hostname is None:
            return None
        if schema.hostname.find('mail.live.com') == -1 and schema.hostname.find('profile.live.com') == -1:
            return None

        self.hostname = schema.hostname.find('mail.live.com') == -1 and self.hostname or schema.hostname
        
        t = int(time.time())
        url = 'https://%s/mail/GetContacts.aspx?n=%s' % (self.hostname, t)
        cvs =  self.web.get_page(url)
        if self.web.url.find('GetContacts') == -1:
            log.error("now can not load contact")
            return None
        emails = set()
        if cvs:
            for item in text.get_in_list(cvs, '"', '"'):
                if item.find('@') != -1:
                    emails.add(item.strip())
        return list(emails)
예제 #3
0
    def create_one(self, full_domain):
        firstname = self.names.get()
        lastname = self.names.get()
        name = text.rnd_str(3)
        ct = self.doamin_ct[full_domain]
        if self.app.add_account(full_domain, name, lastname, firstname):
            self.total += 1
            ct += 1
            acc = "%s@%s" % (name, full_domain)
            log.error("success %s %s total:%s" % (acc, ct, self.total))
            # with self.lock:
            self.out.write("%s\n" % acc)
            self.out.flush()
            if self.client:
                try:
                    self.client.add_account(acc)
                except:
                    log.exception("add_account fail")
                    time.sleep(3)

            self.doamin_ct[full_domain] += 1

            return True
        else:
            log.error("fail %s@%s %s total:%s" % (name, ct, full_domain, self.total))
            return False
예제 #4
0
파일: dump.py 프로젝트: waitingzeng/ttwait
 def work(self, name, id=0):
     try:
         account, psw = self.accounts.get(), '846266'
     except textfile.NotDataException:
         mysignal.ALIVE = False
         raise WorkerFinishException
         return
     
     self.msn_ct += 1
     msn_ct = self.msn_ct
     log.error('%d %s begin connect' % (msn_ct, account))
     app = OutLook(account, psw)
     app.login()
     for i in range(3):
         emails = app.get_contacts()
         if emails is not None:
             self.total += len(emails)
             log.trace('%s %s found emails %s total %s', msn_ct, account, len(emails), self.total)
             log.trace('%s %s found emails %s', msn_ct, account, ','.join(emails))
             
             f = self.files[id]
             f.write('\n'.join(emails))
             f.write('\n')
             f.flush()
             break
예제 #5
0
파일: dump.py 프로젝트: waitingzeng/ttwait
 def sync(self):
     diff = self.begin.get_diff()
     if diff == 0:
         return
     s = "msn_ct %s, total %s " % (self.msn_ct, self.total )
     log.error(s)
     self.accounts.sync()
예제 #6
0
 def init_tos_data(self):
     
     os.chdir(self.data_dir)
     tos_files = glob.glob('tos_*.txt')
     if not tos_files:
         log.trace('not find tos files, need to un tgz')
         for tgzfile in glob.glob('tos_*.txt.tgz'):
             os.popen('tar xzvf %s' %  tgzfile).read()
             log.info("init_tos_data untgz tos %s", tgzfile)
     
     tos_files = glob.glob('tos_*.txt')
     if not tos_files:
         log.error("not found any tos file")
         raise NotDataException
     
     f = random.choice(tos_files)
     cmd = "mv %s %s.txt" % ( f, self.cur_tos)
     os.popen(cmd).read()
     log.trace(cmd)
     try:
         os.unlink('%s.info' % (self.cur_tos))
     except:
         pass
     os.chdir(self.cur_dir)
     self.tos = AccountNotMemery(self.cur_tos)
예제 #7
0
 def work(self, name, id):
     sub_domain = self.create_domain()
     if not sub_domain:
         return
     full_domain = "%s.%s" % (sub_domain, self.domain)
     log.error("begin create accounts for %s" % full_domain)
     self.doamin_ct[full_domain] = 0
     self.create_domain_accounts(full_domain)
     del self.doamin_ct[full_domain]
예제 #8
0
 def reload(self):
     if self.ct < 100:
         return
     log.error("force reload message cache %s", self.from_site)
     try:
         if self.load():
             self.ct = 0
     except:
         self.LIMIT += self.LIMIT
         pass
예제 #9
0
 def sync(self):
     diff = self.begin.get_diff()
     if diff == 0:
         return
     diff1 = self.cur.get_diff()
     cur_total = self.total - self.last_total
     self.last_total = self.total
     self.cur.reset()
     s = "msn_ct %s, msn_speed %0.2f total %s speed:%0.2f/%0.2f time %0.2f/%0.2f " % (self.msn_ct, self.msn_ct / diff, self.total, self.total / diff, cur_total / diff1, diff, diff1)
     log.error(s)
예제 #10
0
    def init(self):

        self.dnspod = DnsPod(self.conf.dnspod.user, self.conf.dnspod.psw)
        self.dnspod.domain_list()
        domain = DictIni(self.conf.domain_conf)
        domain = domain[self.name]
        if not domain:
            log.error("%s Domain Doest not Exists", self.name)
            sys.exit(-1)

        self.domain = domain.domain
        self.account = domain.account
        self.psw = domain.psw
        self.names = text.CacheFile("data/names.txt")
        self.domain_fail = 0
        self.app = DomainLive(self.account, self.psw, dnspod=self.dnspod)
        self.begin()
예제 #11
0
    def sync(self):

        self.tos.load_thread()
        self.accounts.load_thread()
        diff = self.begin.get_diff()
        if diff == 0:
            return
        diff1 = self.cur.get_diff()
        cur_total = self.total - self.last_total
        self.last_total = self.total
        self.cur.reset()
        s = "account %s, account_speed %0.2f total %s speed:%0.2f/%0.2f time %0.2f/%0.2f " % (
            self.account_success,
            self.account_success / diff,
            self.total,
            self.total / diff,
            cur_total / diff1,
            diff,
            diff1,
        )
        log.error(s)

        return bool(self.tos) and bool(self.accounts)
예제 #12
0
    def begin(self):
        log.error("begin login %s", self.app.name)
        if not self.app.login():
            log.error("%s login fail", self.app.name)
            raise Exception("%s login fail" % self.app.name)
        log.error("login success")

        p = "create"
        if not os.path.exists(p):
            os.makedirs(p)

        self.out = file("%s/%s_%s.txt" % (p, self.name, datetime.today().strftime("%y%m%d")), "a")
        self.doamin_ct = {}
        if self.conf.account_server:
            self.client = MagicClient(self.conf.account_server[0], int(self.conf.account_server[1]))
        else:
            self.client = None
예제 #13
0
    def create_domain(self):
        while mysignal.ALIVE:
            res = self.app.add_domain(self.domain)
            if res:
                return res
            log.error("add domain error")
            self.domain_fail += 1
            if self.domain_fail > 10:
                with self.lock:
                    if self.domain_fail < 10:
                        return

                    self.app = DomainLive(self.account, self.psw, dnspod=self.dnspod)
                    if not self.app.login():
                        log.error("login fail")
                        return
                    self.domain_fail = 0
                    log.error("login success")

        return None
예제 #14
0
 def process_options(self, options, args):
     self.name = options.name
     if not self.name:
         log.error("Must Give Name")
         return True