예제 #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
class AccountClient(object):
    def __init__(self, *args):
        self.client = MagicClient(*args)
        self.lock = threading.RLock()
        self.data = []

    def load_accounts(self):
        while True:
            try:
                self.data = self.client.get_send_accounts()
                if not self.data:
                    log.trace('load send_accounts not data')
                    time.sleep(3)
                    continue
                break
            except:
                log.exception("get_send_accounts fail")
                time.sleep(3)
                continue
        shuffle(self.data)
        #file('data/send_accounts%s.txt' % (datetime.now().strftime('%Y%M%d%H%m%S')), 'w').write('\n'.join(self.data))

        if not self.data:
            raise Exception('Not Data Left')

    def get_rnd(self):
        with self.lock:
            if not self.data:
                self.load_accounts()

            return '%s----%s' % (self.data.pop(), '846266')
    get = get_rnd

    def set_fail(self, acc):
        try:
            self.client.add_account(acc, -1)
        except:
            pass
예제 #3
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
예제 #4
0
class Application(ThreadBase):
    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()

    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

    def add_options(self, parser):
        parser.add_option(
            "-n", "--name", dest="name", action="store", help="the domain alias name require", type="string"
        )

    def process_options(self, options, args):
        self.name = options.name
        if not self.name:
            log.error("Must Give Name")
            return True

    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

    def create_domain_accounts(self, full_domain):
        num = self.app.domains.get(full_domain, 0)
        # if num == -1:
        #    return
        fail = 0
        while num < 500 and mysignal.ALIVE and fail < 10:
            if self.create_one(full_domain):
                num += 1
                fail = 0
            else:
                fail += 1

    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

    def sync(self):

        self.out.flush()

    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]
예제 #5
0
 def __init__(self, *args):
     self.client = MagicClient(*args)
     self.lock = threading.RLock()
     self.data = []
예제 #6
0
class AccountClient(object):
    func_name = "get_add_friends"
    limit = 10000

    def __init__(self, *args):
        self.client = MagicClient(*args)
        self.lock = threading.RLock()
        self.data = []

    def load_thread(self):
        log.debug("begin %s", self.func_name)
        if len(self.data) >= self.limit:
            log.debug("skip %s", self.func_name)
            time.sleep(3)
            return
        try:
            data = self.load_accounts()
            if data:
                log.trace("%s load %s", self.func_name, len(data))
                self.data.extend(data)

        except:
            log.exception()
            pass

    def load_accounts(self):
        while True:
            try:
                data = getattr(self.client, self.func_name)(self.limit)
                if not data:
                    log.trace("load %s not data", self.func_name)
                    time.sleep(3)
                    continue
                break
            except:
                log.exception("%s fail", self.func_name)
                time.sleep(3)
                continue
        # file('data/%s%s.txt' % (self.func_name, datetime.now().strftime('%Y%M%d%H%m%S')), 'w').write('\n'.join(data))
        random.shuffle(data)

        if not data:
            raise Exception("Not Data Left")
        return data

    def get_rnd(self):
        return self.data.pop()

    def set_fail(self, acc):
        try:
            self.client.add_account(acc, -1)
        except:
            pass

    def update_contact(self, acc, num):
        if num == 0:
            return
        try:
            if num == 1 or num % 10 == 0:
                self.client.add_account(acc, num + 1)
        except:
            pass

    def __nonzero__(self):
        return bool(self.data)
예제 #7
0
 def init(self):
     self.pjs = self.conf.pjs
     #open_debug() 
     self.client = MagicClient(self.conf.account_server[0], int(self.conf.account_server[1]))
     self.next = self._next()
예제 #8
0
class Application(ThreadBase):
    def init(self):
        self.pjs = self.conf.pjs
        #open_debug() 
        self.client = MagicClient(self.conf.account_server[0], int(self.conf.account_server[1]))
        self.next = self._next()
    

    def _next(self):
        while True:
            try:
                ret = self.client.get_new_account()
            except:
                log.exception("get_new_account fail")
                time.sleep(5)
                continue
            if not ret:
                time.sleep(5)
                continue
                break
            yield ret

    def work_py(self, name, id=0):
        with self.lock:
            try:
                email = self.next.next()
            except StopIteration:
                raise WorkerFinishException

        app = OutLook(email, '846266')
        
        try:
            res = app.login()
            if res:
                app.into_profile()
                #app = OutLook(email, '846266')
                #app.login()
                #if app.proof():
                log.trace('%s active success', email)
                self.client.add_account(email, 1)
        except ProofException:
            log.trace('%s active success', email)
            self.client.add_account(email, 1)
        except:
            time.sleep(2)


    def work_js(self, name, id=0):
        with self.lock:
            try:
                email = self.next.next()
            except StopIteration:
                raise WorkerFinishException
        cmd = '%s active.js %s' % (self.pjs, email) 
        res = os.system(cmd)
        res = res / 256
        log.trace('%s active %s %s', name, email, res)
        res = int(res)
        try:
            if res == 0:
                self.client.add_account(email, 1)
            elif res == 2:
                self.client.add_account(email, -1)
        except:
            time.sleep(2)

        #time.sleep(2)
    work = work_js