예제 #1
0
 def proxy(self):
     os.system('adb -s ' + self.deviceid + ' shell am force-stop org.proxydroid')
     self.driver = Open().Phone('org.proxydroid', '.ProxyDroid', self.deviceid, self.port)
     self.driver.implicitly_wait(180)
     self.driver.find_element_by_id('android:id/switchWidget').click()
     time.sleep(2)
     logging.info(self.deviceid+u'-Proxy成功连接')
예제 #2
0
 def dd_switch(self, ph, mm, device_token):
     if duoduo_api.Recover(self.deviceid,device_token) == True:
         self.visualization('环境还原成功')
         logging.info(self.deviceid+u'-环境还原成功')
         self.driver = Open().Phone('com.tencent.mm', '.ui.LauncherUI', self.deviceid, self.port)
         self.driver.implicitly_wait(60)
     self.visualization('启动')
     logging.info(self.deviceid + u'-启动')
     return ph, mm
예제 #3
0
 def dd_new(self):
     time.sleep(2)
     self.device_token = duoduo_api.newPhone(self.deviceid)
     logging.info(self.deviceid+'-token:%s'%self.device_token)
     time.sleep(2)
     logging.info(self.deviceid + u'-一键新建成功')
     logging.info(self.deviceid + u'-启动WX')
     self.driver = Open().Phone('com.tencent.mm', '.ui.LauncherUI', self.deviceid, self.port)
     self.driver.implicitly_wait(180)
     size = self.driver.get_window_size()
예제 #4
0
 def wb_new(self):
     #api调用一键新机
     status = self.w.newDevice()
     if status == True:
         logging.info(self.deviceid+u'-一键新机成功')
         logging.info(self.deviceid + u'-准备打开WX')
         self.driver = Open().Phone('com.tencent.mm','.ui.LauncherUI', self.deviceid, self.port)
         self.driver.implicitly_wait(180)
         size = self.driver.get_window_size()
         self.wb = int(size.values()[0]) / 1080
         self.hb = int(size.values()[1]) / 1920
예제 #5
0
 def wb_login(self, ph, mm):
     if self.login_mode == '1.wxid登陆'.decode("utf-8"):
         if self.w.switch_wechat_data(self.wxid) == True:
             self.driver = Open().Phone('com.tencent.mm', '.ui.LauncherUI', self.deviceid, self.port)
             self.driver.implicitly_wait(60)
             return ph, mm
         else:
             raise quit()
     if self.login_mode == '2.云码登陆'.decode("utf-8"):
         if self.w.cloudCodeRecover(self.cloudCode) == True:
             self.driver = Open().Phone('com.tencent.mm', '.ui.LauncherUI', self.deviceid, self.port)
             self.driver.implicitly_wait(60)
             return ph, mm
예제 #6
0
 def proxy(self):
     try:
         os.popen('adb -s %s shell kill -9 %s' %
                  (self.deviceid,
                   os.popen('adb -s %s shell "ps|grep org.proxydroid"' %
                            self.deviceid).read().split()[1]))
     except:
         pass
     os.system('adb -s ' + self.deviceid +
               ' shell am force-stop org.proxydroid')
     self.driver = Open().Phone('org.proxydroid', '.ProxyDroid',
                                self.deviceid, self.port)
     self.driver.implicitly_wait(180)
     self.driver.find_element_by_id('android:id/switch_widget').click()
     time.sleep(10)
     logging.info(self.deviceid + u'-Proxy成功连接')
예제 #7
0
 def start(self, m, t, filtering_mode):
     self.appPackage = re.findall('(.*?)\|',
                                  file.read('平台账号.txt')[25].strip('\n'))[0]
     self.appActivity = re.findall('\|(.*)',
                                   file.read('平台账号.txt')[25].strip('\n'))[0]
     os.system('adb -s ' + self.deviceid +
               ' shell am force-stop com.tencent.mm')
     driver = Open().Phone(self.appPackage, self.appActivity, self.deviceid,
                           self.port)
     driver.implicitly_wait(60)
     while True:
         driver.find_element_by_id('org.wuji:id/exit_vpn').click()  # 切换VPN
         time.sleep(int(t))
         try:
             ip = re.findall(
                 '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}',
                 driver.find_element_by_id('org.wuji:id/ips').get_attribute(
                     ("text")))[0]
             logging.info(self.deviceid + u"-VPN已成功连接")
             logging.info(self.deviceid + u"-IP:%s" % ip)
             if m == '1':
                 if ip_fiter(self.deviceid, ip, filtering_mode) == True:
                     return ip
                 else:
                     pass
             if m == '2':
                 if ip_fiter(self.deviceid, ip, filtering_mode) == True:
                     return ip
                 else:
                     pass
         except:
             time.sleep(10)
예제 #8
0
 def newvpn(self,m,t,filtering_mode):
     os.system('adb -s ' + self.deviceid + ' shell am force-stop com.tencent.mm')
     driver = Open().Phone(self.appPackage, self.appActivity, self.deviceid, self.port)
     driver.implicitly_wait(60)
     while True:
         driver.find_element_by_id('it.colucciweb.sstpvpnclient:id/start_stop').click()  # 开启VPN
         time.sleep(int(t))
         pd=driver.find_element_by_id('it.colucciweb.sstpvpnclient:id/details1').get_attribute(("text"))
         try:
             if u"(已连接)" == pd:
                 logging.info(self.deviceid+u"-VPN已成功连接")
                 try:
                     self.ip = re.findall('"cip": "([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})"', os.popen(
                         'adb -s ' + self.deviceid + ' shell curl "http://pv.sohu.com/cityjson"').read())[0]
                 except:
                     logging.info(self.deviceid+u'网络异常 ,请查看手机是否可以正常联网')
                 logging.info(self.deviceid + u'-' + self.ip)
                 if m == '1':
                     if ip_fiter(self.deviceid, self.ip, filtering_mode) == True:
                         return self.ip
                     else:
                         pass
                 if m == '2':
                     return self.ip
         except:pass
예제 #9
0
 def proxy(self):
     try:
         os.popen('adb -s %s shell kill -9 %s' % (self.deviceid,os.popen('adb -s %s shell "ps|grep org.proxydroid"'%self.deviceid).read().split()[1]))
     except:
         pass
     os.system('adb -s ' + self.deviceid + ' shell am force-stop org.proxydroid')
     self.driver = Open().Phone('org.proxydroid', '.ProxyDroid', self.deviceid, self.port)
     self.driver.implicitly_wait(180)
     self.driver.find_element_by_id('android:id/switch_widget').click()
     time.sleep(10)
     logging.info(self.deviceid+u'-Proxy成功连接')
예제 #10
0
 def newvpn(self,m,t,filtering_mode):
     os.system('adb -s ' + self.deviceid + ' shell am force-stop com.tencent.mm')
     driver = Open().Phone(self.appPackage, self.appActivity, self.deviceid, self.port)
     driver.implicitly_wait(60)
     while True:
         driver.find_element_by_id('it.colucciweb.sstpvpnclient:id/start_stop').click()  # 开启VPN
         time.sleep(int(t))
         pd=driver.find_element_by_id('it.colucciweb.sstpvpnclient:id/details1').get_attribute(("text"))
         try:
             if u"(已连接)" == pd:
                 logging.info(self.deviceid+u"-VPN已成功连接")
                 try:
                     self.ip = re.findall('"cip": "([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})"', os.popen(
                         'adb -s ' + self.deviceid + ' shell curl "http://pv.sohu.com/cityjson"').read())[0]
                 except:
                     logging.info(self.deviceid+u'网络异常 ,请查看手机是否可以正常联网')
                 logging.info(self.deviceid + u'-' + self.ip)
                 if m == '1':
                     if ip_fiter(self.deviceid, self.ip, filtering_mode) == True:
                         return self.ip
                     else:
                         pass
                 if m == '2':
                     return self.ip
         except:pass
예제 #11
0
 def start(self,m,t,filtering_mode):
     self.appPackage = re.findall('(.*?)\|', file.read('平台账号.txt')[25].strip('\n'))[0]
     self.appActivity = re.findall('\|(.*)', file.read('平台账号.txt')[25].strip('\n'))[0]
     os.system('adb -s ' + self.deviceid + ' shell am force-stop com.tencent.mm')
     driver = Open().Phone(self.appPackage, self.appActivity, self.deviceid, self.port)
     driver.implicitly_wait(60)
     while True:
         driver.find_element_by_id('org.wuji:id/exit_vpn').click()  # 切换VPN
         time.sleep(int(t))
         try:
             ip = re.findall('[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}',
                             driver.find_element_by_id('org.wuji:id/ips').get_attribute(("text")))[0]
             logging.info(self.deviceid + u"-VPN已成功连接")
             logging.info(self.deviceid + u"-IP:%s" % ip)
             if m == '1':
                 if ip_fiter(self.deviceid, ip, filtering_mode) == True:
                     return ip
                 else:
                     pass
             if m == '2':
                 if ip_fiter(self.deviceid, ip, filtering_mode) == True:
                     return ip
                 else:
                     pass
         except:
             time.sleep(10)
예제 #12
0
class newenvironment():
    def __init__(self, uid, password, pid, deviceid, port, o_username, o_password, wxmm, phmode, wxmc, phonenumber, gj_mode, tm=None, cooperator=None, country=None,gj=None,qh=None,switchingmode=None,filtering_mode=None,t=None,ip=None):
        self.uid = uid
        self.cooperator = cooperator
        self.password = password
        self.pid = pid
        self.deviceid = deviceid
        self.port = port
        self.o_username = o_username
        self.o_password = o_password
        self.wxmm = wxmm
        self.phmode = phmode
        self.ph = PhoneNumber(self.uid, self.password, self.pid, self.deviceid, phmode)
        self.wxmc = wxmc
        self.gj_mode = gj_mode
        self.phonenumber = phonenumber
        self.tm = tm
        self.country = country
        self.gj = gj
        self.qh = qh
        self.w = WB(deviceid)
        self.wj = wj(deviceid, port)
        self.element_json = json.loads(file.read_all('6.7.3.json'))
        self.switchingmode =switchingmode
        self.filtering_mode = filtering_mode
        self.t = t
        self.ip = ip
    #微霸新机
    def wb_new(self):
        #api调用一键新机
        status = self.w.newDevice()
        if status == True:
            logging.info(self.deviceid+u'-一键新机成功')
            logging.info(self.deviceid + u'-准备打开WX')
            self.driver = Open().Phone('com.tencent.mm','.ui.LauncherUI', self.deviceid, self.port)
            self.driver.implicitly_wait(180)
            size = self.driver.get_window_size()
            self.wb = int(size.values()[0]) / 1080
            self.hb = int(size.values()[1]) / 1920

    #多多新机
    def dd_new(self):
        time.sleep(2)
        self.device_token = duoduo_api.newPhone(self.deviceid)
        logging.info(self.deviceid+'-token:%s'%self.device_token)
        time.sleep(2)
        logging.info(self.deviceid + u'-一键新建成功')
        logging.info(self.deviceid + u'-启动WX')
        self.driver = Open().Phone('com.tencent.mm', '.ui.LauncherUI', self.deviceid, self.port)
        self.driver.implicitly_wait(180)
        size = self.driver.get_window_size()

    #沙盒新机
    def sand_box(self):
        os.popen('adb -s %s shell rm -rf /sdcard/boxbackup' % self.deviceid)
        with open('沙盒账密配置.json'.decode('utf-8'), 'r') as f:
            a = json.loads(f.read())
        for i in a:
            if self.deviceid == i['deviceid']:
                username = i['username']
                password = i['password']
        os.popen('adb -s %s shell am force-stop com.dobe.sandbox' % self.deviceid)
        self.driver = Open().Phone('com.dobe.sandbox', '.home.Main2Activity', self.deviceid, self.port)
        self.driver.implicitly_wait(50)
        size = self.driver.get_window_size()
        self.wb = int(size.values()[0]) / 1080
        self.hb = int(size.values()[1]) / 1920
        self.driver.find_element_by_id('com.dobe.sandbox:id/download_icon').click()
        wz = self.driver.find_element_by_id('com.dobe.sandbox:id/textView').get_attribute(('text'))
        while True:
            if wz.encode('utf-8') == '尚未登陆,点击登陆':
                self.driver.find_element_by_name('尚未登陆,点击登陆').click()
                self.driver.find_element_by_id('com.dobe.sandbox:id/editText').send_keys(username)
                self.driver.find_element_by_id('com.dobe.sandbox:id/editText2').send_keys(password)
                self.driver.keyevent('66')
                time.sleep(1)
                self.driver.find_element_by_name('点击登陆').click()
                if self.driver.find_elements_by_id('com.dobe.sandbox:id/download_icon') != []:
                    break
            else:
                self.driver.keyevent('4')
                break
        self.driver.find_element_by_id('com.dobe.sandbox:id/context_menu').click()
        self.driver.find_element_by_name('清除APP数据').click()
        self.driver.find_element_by_name('确认删除').click()
        time.sleep(5)
        self.driver.find_element_by_id('com.dobe.sandbox:id/download_device').click()
        self.driver.find_element_by_name('修改设备').click()
        self.driver.find_element_by_name('修改机型').click()
        b = 0
        self.driver.implicitly_wait(2)
        while True:
            if self.driver.find_elements_by_class_name('android.widget.TextView') != []:
                list = self.driver.find_elements_by_class_name('android.widget.TextView')
                if list.__len__() > 5:
                    self.IMEI = re.findall('IMEI: (.*)', list[2].get_attribute(("text")))[0]
                    logging.info('%s-IMEI:%s' % (self.deviceid,self.IMEI))
                    self.MAC = re.findall('MAC: (.*)', list[5].get_attribute(("text")))[0]
                    logging.info('%s-MAC:%s' % (self.deviceid, self.MAC))
                    self.Brand = re.findall('BRAND: (.*)', list[6].get_attribute(("text")))[0]
                    logging.info('%s-BRAND:%s' % (self.deviceid, self.Brand))
                    self.driver.keyevent(4)
                    time.sleep(1)
                    self.driver.keyevent(4)
                    time.sleep(2)
                    self.driver.find_element_by_id('com.dobe.sandbox:id/appIcon').click()
                    break
                else:
                    if 30 == b:
                        self.driver.quit()
                        break
                    else:
                        b = b + 1
                        time.sleep(2)
    #国内注册
    def register(self):
        self.driver.implicitly_wait(60)
        self.driver.find_element_by_id(self.element_json[u'首页注册ID']).click()
        time.sleep(1)
        self.driver.implicitly_wait(5)
        logging.info(self.deviceid + u'-点击注册')
    #国外输入账号信息

    def Judgment_Devices(self):
        while True:
            if os.system('adb -s %s shell cd /sdcard' % self.deviceid) != 0:
                logging.info(u'%s未检测到手机连接'%self.deviceid)
                time.sleep(5)
            else:
                break

    #国内输入账号信息
    def input_text(self):
        self.Judgment_Devices()
        # for i in  list(self.wxmc):
        #     time.sleep(0.3)
        #     os.system('adb -s %s shell input text %s'%(self.deviceid,i))
        self.driver.find_elements_by_id(self.element_json[u'输入框ID'])[0].send_keys(self.wxmc)
        logging.info(self.deviceid + u'-输入昵称')
        self.driver.find_elements_by_id(self.element_json[u'输入框ID'])[1].clear()
        self.Judgment_Devices()
        logging.info(self.deviceid + u'-清空手机号码')
        #os.system('adb -s %s shell input text %s' % (self.deviceid, self.phonenumber[0]))
        for i in  list(self.phonenumber[0]):
            time.sleep(0.3)
            os.system('adb -s %s shell input text %s'%(self.deviceid,i))
        logging.info(self.deviceid + u'-输入手机号码:' + self.phonenumber[0])
        time.sleep(random.randint(1, 3))
        self.Judgment_Devices()
        self.driver.find_elements_by_id(self.element_json[u'输入框ID'])[2].click()
        for i in  list(self.wxmm):
            time.sleep(0.3)
            os.system('adb -s %s shell input text %s'%(self.deviceid,i))
        logging.info(self.deviceid + u'-输入密码:' + self.wxmm)
        self.driver.implicitly_wait(180)
        time.sleep(random.randint(1, 3))
        self.Judgment_Devices()
        self.driver.find_element_by_id(self.element_json[u'手机号注册页面注册按钮ID']).click()
        logging.info(self.deviceid + u'-点击注册')
        self.driver.implicitly_wait(1)
        while True:
            self.Judgment_Devices()
            if self.driver.find_elements_by_class_name(self.element_json['CheckBox']) != []:
                self.driver.find_elements_by_class_name(self.element_json['CheckBox'])[0].click()
                logging.info(self.deviceid + u'-同意协议')
                os.popen('adb -s %s shell input tap 567 1789'%self.deviceid)
                time.sleep(5)
                break
            self.Judgment_Devices()
            if self.driver.find_elements_by_id(self.element_json[u'手机号注册页面注册按钮ID']) != []:
                self.driver.find_element_by_id(self.element_json[u'手机号注册页面注册按钮ID']).click()
            self.Judgment_Devices()
            if self.driver.find_elements_by_name('网页无法打开') != []:
                logging.info(self.deviceid + u'-找不到网页,网络不稳定,重新注册')
                self.driver.quit()
                break
            self.Judgment_Devices()
            if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("网页无法打开")') != []:
                logging.info(self.deviceid + u'-找不到网页,网络不稳定,重新注册')
                self.driver.quit()
                break
            self.Judgment_Devices()
            if self.driver.find_elements_by_name('找不到网页') != []:
                logging.info(self.deviceid + u'-找不到网页,网络不稳定,重新注册')
                self.driver.quit()
                break
        time.sleep(4)
        while True:
            self.Judgment_Devices()
            if self.driver.find_elements_by_class_name(self.element_json['CheckBox']) != []:
                self.driver.find_elements_by_class_name(self.element_json['CheckBox'])[0].click()
                logging.info(self.deviceid + u'-同意协议')
                os.popen('adb -s %s shell input tap 567 1789' % self.deviceid)
            if self.driver.find_elements_by_id(self.element_json[u'错误弹窗确定ID']) != []:
                self.driver.find_element_by_id(self.element_json[u'错误弹窗确定ID']).click()
            if self.driver.find_elements_by_name('微信安全')!=[]:
                logging.info(self.deviceid + u'-进入滑图页面')
                break
            if self.driver.find_elements_by_name('网页无法打开') != []:
                logging.info(self.deviceid + u'-找不到网页,网络不稳定,重新注册')
                self.driver.quit()
                break
            if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("网页无法打开")') != []:
                logging.info(self.deviceid + u'-找不到网页,网络不稳定,重新注册')
                self.driver.quit()
                break
            if self.driver.find_elements_by_name('找不到网页') != []:
                logging.info(self.deviceid + u'-找不到网页,网络不稳定,重新注册')
                self.driver.quit()
                break
            os.popen('adb -s %s shell input tap 500 900' % self.deviceid)
            os.popen('adb -s %s shell input tap 460 1096' % self.deviceid)
        time.sleep(5)

    # 小蚂蚁
    def xmy(self):
        os.system('adb -s %s shell input tap 1056 573' % self.deviceid)
        time.sleep(1)
        os.system('adb -s %s shell input tap 580 630' % self.deviceid)

    #滑图错误
    def error_Three_Months(self):
        if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("返回 ")') != []:
            logging.info(self.deviceid + u'-出现三个月,重新返回')
            if self.phmode == '14.玉米平台'.decode("utf-8"):
                self.ph.yumi_cancelSMSRecv(self.phonenumber[0], self.phonenumber[1])
            return '1'
        if self.driver.find_elements_by_android_uiautomator('操作超时,请重新发起(错误码: -22)') != []:
            logging.info(self.deviceid + u'-操作超时')
            if self.phmode == '14.玉米平台'.decode("utf-8"):
                self.ph.yumi_cancelSMSRecv(self.phonenumber[0], self.phonenumber[1])
            return '1'


    #成功跳码
    def successful_Skip_Code(self):
        if self.driver.find_elements_by_id(self.element_json['czl'])!=[]:
            logging.info(self.deviceid + u'-跳码成功')
            return True

    #跳码失败直接退出
    def skip_Code_fail(self, error_type=None):
        if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("让用户用微信扫描下面的二维码")') != []:
            if error_type == 'Continue':
                logging.info(self.deviceid + u'-跳转到二维码页面')
            return False
        if self.driver.find_elements_by_name('让用户用微信扫描下面的二维码')!=[]:
            if error_type == 'Continue':
                logging.info(self.deviceid + u'-跳转到二维码页面')
            return False
    # 国内图片验证
    def yztp(self):
        """
        验证图片 
        """
        if self.tm == '9':
            while True:
                if self.driver.find_elements_by_name('安全校验') != []:
                    if self.skip_Code_fail() == False:
                        return False
                    if self.error_Three_Months() == '1':
                        return '1'
                if self.driver.find_elements_by_id(self.element_json[u'短信内容ID']) != []:
                    return True
                if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("开始 ")') != []:
                    os.popen('adb -s %s shell input swipe 50 1000 1000 1000 3000' % self.deviceid)
        if self.tm == '6':
            while True:
                try:
                    for j in range(101, 200, 30):
                        a = TouchAction(self.driver)
                        a.press(x=250, y=1000)
                        for i in range(0, 5):
                            a.move_to(x=50, y=(random.randint(-500, 0))).wait(0)
                            a.move_to(x=50, y=(random.randint(0, 500))).wait(0)
                        for i in range(0, j / 10):
                            a.move_to(x=10, y=0).wait(100)
                        a.release().perform()
                        self.Judgment_Devices()
                        if self.driver.find_elements_by_name('安全校验') != []:
                            if self.skip_Code_fail('Continue') == False:
                                return False
                            if self.error_Three_Months() == False:
                                return False
                        self.Judgment_Devices()
                        if self.driver.find_elements_by_id(self.element_json[u'短信内容ID']) != []:
                            return True
                        if self.driver.find_elements_by_name('开始 ') != []:
                            os.popen('adb -s %s shell input swipe 50 1000 1000 1000 3000' % self.deviceid)
                        if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("开始 ")') != []:
                            os.popen('adb -s %s shell input swipe 50 1000 1000 1000 3000' % self.deviceid)
                        if self.driver.find_elements_by_name('开始') != []:
                            os.popen('adb -s %s shell input swipe 50 1000 1000 1000 3000' % self.deviceid)
                        if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("开始")') != []:
                            os.popen('adb -s %s shell input swipe 50 1000 1000 1000 3000' % self.deviceid)
                except:pass
    #任务确认
    def task_validation(self):
        """
        任务确认 
        """
        time.sleep(5)
        token = TokenYZ.pdtoken()
        status = submissionorder().confirm(self.deviceid, self.taskid, token)
        if status == '成功':
            logging.info(self.deviceid+u'-任务已确认完成')
        else:
            token = TokenYZ.pdtoken()
            status = submissionorder().confirm(self.deviceid, self.taskid, token)
            if status == '成功':
                logging.info(self.deviceid+u'-任务已确认完成')
        logging.info(self.deviceid + u'-正在发送短信')

    #等待扫码
    def waiting_code(self, end_time):
        self.driver.implicitly_wait(5)
        for self.i in range(1, int(end_time)):
            try:
                TouchAction(self.driver).tap(element=None, x=500, y=900).perform()
                self.dx = re.findall('[a-z0-9]{1,10}', self.driver.find_element_by_id(self.element_json[u'短信内容ID']).get_attribute(("text")))[0]
                logging.info(self.deviceid + u'-提取的发送内容为' + self.dx)
                self.task_validation()
                return True
            except:
                logging.info(self.deviceid + u'-扫码剩余时长' + str(end_time * 5 - self.i * 5))
                if self.i == end_time - 1:
                    token = TokenYZ.pdtoken()
                    submissionorder().fail(self.deviceid, self.taskid, token)
                    logging.info(self.deviceid + u'-辅助并未扫描成功,等待时间已过,重新注册!')
                    if self.tm == 'tm7':
                        if self.phmode == '14.玉米平台'.decode("utf-8"):
                            self.ph.yumi_cancelSMSRecv(self.phonenumber[0], self.phonenumber[1])
                    if self.phmode == '3.火箭API'.decode("utf-8"):
                        return self.ph.hj_fail(TokenYZ.pdtoken(), self.phonenumber[1])
                    self.driver.quit()
                    return False
    #切换VPN
    def switching_VPN(self):
        os.system('adb -s ' + self.deviceid + ' shell am force-stop org.proxydroid')
        os.system('adb -s ' + self.deviceid + ' shell am force-stop it.colucciweb.sstpvpnclient')

    def pd_ip(self, m):
        if self.switchingmode == '3.不换IP'.decode("utf-8"):
            self.ip =  os.popen('adb -s %s shell curl "http://ip.cip.cc'%self.deviceid).read()[0]
            return self.ip
        if self.switchingmode == '4.私人VPN'.decode('utf-8'):
            return self.wj.start(m,self.t,self.filtering_mode)

    #打开影子科技
    def start_yz(self):
        os.popen('adb -s ' + self.deviceid + ' shell am force-stop wechatscancoder.jionego.com.wechatscancoder')
        os.popen('adb -s %s shell am start -n wechatscancoder.jionego.com.wechatscancoder/.MainActivity' % self.deviceid).read()
        time.sleep(3)
        os.popen('adb -s %s shell am start -n com.tencent.mm/.ui.LauncherUI' % self.deviceid).read()

     #获取二维码图片
    def get_qr_image(self):
        folder = os.path.exists('./%s' % self.deviceid)
        if not folder:
            os.makedirs('./%s' % self.deviceid)
        else:
            pass
        res = requests.get('http://193.112.218.104:89/api?str=Initialize').text
        image = json.loads(res)['qrcode']
        data_62 = json.loads(res)['data']
        h = open("./%s/%s.jpg" % (self.deviceid, self.deviceid), "wb")
        h.write(base64.b64decode(image))
        h.close()
        os.popen('adb -s %s push ./%s/%s.jpg  /sdcard/myData/%s.jpg' % (self.deviceid, self.deviceid, self.deviceid,self.deviceid)).read()
        time.sleep(2)
        os.popen('adb -s %s shell mv /sdcard/myData/%s.jpg /sdcard/myData/scan.jpg' % (self.deviceid, self.deviceid)).read()
        time.sleep(2)
        os.system('adb -s %s shell curl http://127.0.0.1:8089?api=scandCode' % self.deviceid)
        return data_62


    #国内判断跳码
    def qr_validation(self, status):
        """
        判断是否跳码成功
        """
        if status == '1':
            self.driver.quit()
        if status == False:
            if self.tm == '9' or self.tm == '6':
                logging.info(self.deviceid + u'-未跳码成功,重新注册!')
                if self.phmode == '3.火箭API'.decode("utf-8"):
                    self.ph.hj_fail(TokenYZ.pdtoken(), self.phonenumber[1])
                if self.phmode == '9.老九专属API'.decode("utf-8"):
                    file().wite_lj_NotHopCode(self.phonenumber[0])
                if self.phmode == '2.菜鸟平台'.decode('utf-8'):
                    self.ph.cn_lh(self.phonenumber[0], self.phonenumber[1])
                if self.phmode == '12.国内私人3'.decode('utf-8'):
                    self.ph.grsr3_lh(self.phonenumber[1])
                if self.phmode == '13.国内私人4'.decode('utf-8'):
                    self.ph.grsr4_lh(self.phonenumber[1])
                self.driver.quit()
            else:
                self.Submission_Task()
                if self.cooperator == '1.火箭辅助'.decode("utf-8"):
                    if self.waiting_code(72) == True:
                        if self.phmode == '14.玉米平台'.decode("utf-8"):
                            return self.yumi_sendmsg(self.dx)
                        if self.phmode == '3.火箭API'.decode("utf-8"):
                            if self.ph.send_text(TokenYZ.pdtoken(), self.phonenumber[1], self.dx) == True:
                                return 'succ'
                        if self.phmode == '1.小鱼平台'.decode('utf-8'):
                            return self.ph.xiaoyu_send_message(self.phonenumber[0], self.dx)
                        if self.phmode == '13.国内私人4'.decode('utf-8'):
                            return self.ph.grsr4_send(self.phonenumber[1], self.dx)
                    else:
                        return False
        if status == True:
            dx = re.findall('[a-z0-9]{1,10}', self.driver.find_element_by_id(self.element_json[u'短信内容ID']).get_attribute(("text")))[0]
            logging.info(self.deviceid + u'-读取的短信内容为:' + dx)
            if self.phmode == '14.玉米平台'.decode("utf-8"):
                return self.yumi_sendmsg(dx)
            if self.phmode == '2.菜鸟平台'.decode('utf-8'):
                return self.ph.cn_send(self.phonenumber[1], dx)
            if self.phmode == '3.火箭API'.decode("utf-8"):
                #如果火箭平台返回True代表发送成功
                hj_status = self.ph.send_text(TokenYZ.pdtoken(), self.phonenumber[1], dx)
                if hj_status == True:
                    # 如果火箭平台返回True则返回一个succ
                    return 'succ'
            if self.phmode == '7.辽宁API'.decode("utf-8"):
                ln_status=self.ph.ln_send(self.phonenumber[0], dx)
                if ln_status == True:
                    return 'succ'
            if self.phmode == '8.国内私人1'.decode("utf-8"):
                return self.ph.gnsr_send_text(self.phonenumber[0], dx)
            if self.phmode == '9.老九专属API'.decode("utf-8"):
                return self.ph.lj_send_text(self.phonenumber[0], dx)
            if self.phmode == '10.国内私人2'.decode('utf-8'):
                return self.ph.gnsr2_send(self.phonenumber[0], dx)
            if self.phmode == '12.国内私人3'.decode('utf-8'):
                return self.ph.grsr3_send(self.phonenumber[1], dx)
            if self.phmode == '13.国内私人4'.decode('utf-8'):
                return self.ph.grsr4_send(self.phonenumber[1], dx)
            if self.phmode == '1.小鱼平台'.decode('utf-8'):
                return self.ph.xiaoyu_send_message(self.phonenumber[0], dx)
    #提交任务
    def Submission_Task(self):
        """
        提交任务订单
        """
        self.driver.implicitly_wait(180)
        self.driver.execute()
        logging.info(self.deviceid + u'-获取二维码')
        logging.info(self.deviceid + u'-正在解析二维码')
        url = analysis().get(self.deviceid)
        token = TokenYZ.pdtoken()
        logging.info(self.deviceid + u'-二维码解析地址:%s' % url)
        if self.phmode == '3.火箭API'.decode("utf-8"):
            self.taskid = submissionorder().submission_hj(url, self.phonenumber[0], token, '360', self.phonenumber[1])
        else:
            self.taskid = submissionorder().submission(url, self.phonenumber[0], token, '360')
        logging.info(self.deviceid + u'-订单提交成功')
        logging.info(self.deviceid + u'-订单号:' + self.taskid)
        self.driver.implicitly_wait(5)
    #玉米发短信
    def yumi_sendmsg(self, dx):
        try:
            yz = self.ph.yumi_sendmessages(dx, self.phonenumber[0], self.phonenumber[1])
            return yz
        except:
            logging.info(self.deviceid + u'-短信发送失败,卡商已下卡')

    #国外登录
    def gw_login_validation(self):
        self.driver.implicitly_wait(2)
        while True:
            if self.driver.find_elements_by_name(self.element_json['Two_registration'])!=[]:
                logging.info(self.deviceid + u'-判断是否二次注册')
                self.driver.find_element_by_name(self.element_json['Two_registration']).click()
                self.driver.implicitly_wait(10)
                if self.driver.find_elements_by_name(self.element_json['OK'])!=[]:
                    raise Exception(logging.info(self.deviceid + u'-出现错误,重新注册'))
                logging.info(self.deviceid + u'-该账号为二次注册')
            if self.driver.find_elements_by_name(self.element_json['WeChat'])!=[]:
                logging.info(self.deviceid + u'-已进入到微信页面')
                if self.gj_mode == '1.微霸改机'.decode("utf-8"):
                    self.wxid = self.w.get_wxid()
                    self.cloudCode = self.w.getCloudCode(self.phonenumber[0])
                    self.xr_wechat(self.wxid, self.cloudCode, 'True')
                    logging.info(self.deviceid + u'-注册数据已写入文件')
                    logging.info(self.deviceid + u'-正在保存微霸数据请稍等')
                    if self.w.save_wechat_data(self.phonenumber[0], self.wxid, self.wxmc) == True:
                        break
                else:
                    self.xr_wechat(mf='True')
                    logging.info(self.deviceid + u'-注册数据已写入文件')
                    break
            if self.driver.find_elements_by_name(self.element_json['OK']) != []:
                self.driver.find_element_by_name(self.element_json['OK']).click()
                self.driver.implicitly_wait(10)
                if self.driver.find_elements_by_name(self.element_json['allow'])!=[]:
                    self.driver.find_element_by_name(self.element_json['allow']).click()
            if self.driver.find_elements_by_id(self.element_json[u'输入框ID'])!=[]:
                raise Exception(logging.info(self.deviceid + u'-账号秒封'))

    def T_A16(self,A16):
            file().write('%s|%s|%s|%s|%s|%s|%s|%s|\n' % (self.phonenumber[0], self.wxmm,A16, self.IMEI,self.ANDROID_ID ,self.MAC, self.CPU_ABI,self.Brand), 'A16数据.txt')
            logging.info(u'%s-提62成功' % self.deviceid)

    def scanCode(self,A16):
        if token().huojian_t62(self.deviceid, TokenYZ.pdtoken()) == True:
            self.T_A16(A16)

    #写入文件
    def xr_wechat(self,wxid=None,cloudCode=None,mf=None):
            wechat_list = '%s_%s  %s  %s  %s  %s  %s|\n' % (self.phonenumber[0], self.wxmm, self.ip, self.deviceid, datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), wxid,cloudCode )
            file().write(wechat_list, '微信账号数据.txt')

    def send_login(self):
            if self.phmode == '8.国内私人1'.decode("utf-8"):
                self.ph.qg_card_add(TokenYZ.pdtoken(), self.phonenumber[0])
            time.sleep(8)
            self.driver.implicitly_wait(60)
            logging.info(self.deviceid + u'-短信发送成功')
            if self.driver.find_elements_by_name('已发送短信,下一步')!=[]:
                self.driver.find_element_by_name('已发送短信,下一步').click()
            # 判断是否发送短信失败,点击下一步
            while True:
                self.driver.implicitly_wait(2)
                self.Judgment_Devices()
                if self.driver.find_elements_by_name('不是我的,继续注册')!=[]:
                    self.driver.find_element_by_name('不是我的,继续注册').click()
                self.Judgment_Devices()
                if self.driver.find_elements_by_id(self.element_json[u'输入框ID'])!=[]:
                    self.driver.quit()
                    break
                self.Judgment_Devices()
                if self.driver.find_elements_by_id(self.element_json[u'错误弹窗确定ID']) != []:
                    self.cw = self.driver.find_element_by_id(self.element_json[u'错误弹窗内容ID']).get_attribute(('text'))
                    if '短信' in self.cw.encode('utf-8'):
                        self.driver.find_element_by_id(self.element_json[u'错误弹窗确定ID']).click()
                        time.sleep(25)
                        self.driver.find_element_by_name('已发送短信,下一步').click()
                        time.sleep(20)
                        if self.driver.find_elements_by_id(self.element_json[u'错误弹窗确定ID'])!=[]:
                            self.cw = self.driver.find_element_by_id(self.element_json[u'错误弹窗内容ID']).get_attribute(('text'))
                            if '短信' in self.cw.encode('utf-8'):
                                logging.info(self.deviceid + u'-已点击过"已发送短信,下一步"两次,还是未注册成功,进入重新注册流程')
                                self.driver.quit()
                            if '逻辑' in self.cw.encode('utf-8'):
                                self.driver.find_element_by_id(self.element_json[u'错误弹窗确定ID']).click()
                                logging.info(self.deviceid + u'-已进入到微信页面,等待5秒判断是否出现秒封状况')
                                self.driver.implicitly_wait(5)
                                if self.driver.find_elements_by_id(self.element_json[u'错误弹窗确定ID']) != []:
                                    logging.info(self.deviceid + u'-账号秒封,重新注册')
                                else:
                                    if self.gj_mode == '1.微霸改机'.decode("utf-8"):
                                        self.save_wechat_data()
                                        if self.w.save_wechat_data(self.phonenumber[0], self.wxid, self.wxmc) == True:
                                            break
                                    if self.gj_mode == '测试'.decode("utf-8"):
                                        self.driver.implicitly_wait(50)
                                        self.driver.find_element_by_name('我').click()
                                        wxid = re.findall('(wxid_[0-9a-z]{1,100})', self.driver.find_element_by_id('com.tencent.mm:id/cl8').get_attribute(("text")))[0]
                                        logging.info('%s-微信ID:%s'%(self.deviceid,wxid))
                                        self.driver.find_element_by_name('微信').click()
                                        self.sandbox_save(wxid)
                                    else:
                                        self.xr_wechat(mf='True')

                                        logging.info(self.deviceid + u'-注册数据已写入文件')
                                        break
                    if '异常' in self.cw.encode('utf-8'):
                        logging.info(self.deviceid + u'-该账号被秒封')
                        if self.gj_mode == '1.微霸改机'.decode("utf-8"):
                            self.save_wechat_data()
                            if self.w.save_wechat_data(self.phonenumber[0], self.wxid, self.wxmc) == True:
                                break
                    if '逻辑' in self.cw.encode('utf-8'):
                        self.driver.find_element_by_id(self.element_json[u'错误弹窗确定ID']).click()
                        logging.info(self.deviceid + u'-已进入到微信页面,等待5秒判断是否出现秒封状况')
                        self.driver.implicitly_wait(5)
                        if self.driver.find_elements_by_id(self.element_json[u'错误弹窗确定ID']) != []:
                            logging.info(self.deviceid + u'-账号秒封,重新注册')
                        else:
                            if self.gj_mode == '1.微霸改机'.decode("utf-8"):
                                self.save_wechat_data()
                                if self.w.save_wechat_data(self.phonenumber[0], self.wxid, self.wxmc) == True:
                                    break
                            else:
                                self.xr_wechat(mf='True')
                                logging.info(self.deviceid + u'-注册数据已写入文件')
                                break
                    if '一个月' in self.cw.encode('utf-8'):
                        logging.info(self.deviceid + u'-该手机号码一个月之内不能重复注册')
                        self.driver.quit()
                    if '当天' in self.cw.encode('utf-8'):
                        logging.info(self.deviceid + u'-该手机号码当天不能重复注册')
                        os.popen('adb -s %s shell input keyevent 4' % self.deviceid).read()
                        time.sleep(3)
                        os.popen('adb -s %s shell input keyevent 4' % self.deviceid).read()
                        self.driver.implicitly_wait(60)
                        if self.driver.find_elements_by_id(self.element_json[u'输入框ID'])!=[]:
                            os.popen('adb -s %s shell input keyevent 4' % self.deviceid).read()
                            if self.driver.find_elements_by_id(self.element_json[u'微信四个主按钮ID'])!=[]:
                                pass
                    if '不正确' in self.cw.encode('utf-8'):
                        logging.info(self.deviceid + u'-发送的验证码不正确')
                        self.driver.quit()
                    if '近期' in self.cw.encode('utf-8'):
                        logging.info(self.deviceid + u'-近期相同号码不可重复注册')
                        self.driver.quit()
                self.Judgment_Devices()
                if self.driver.find_elements_by_name('微信') != []:
                    logging.info(u'%s-已进入到微信页面,等待5秒判断是否出现秒封状况'%self.deviceid)
                    self.driver.implicitly_wait(5)
                    if self.driver.find_elements_by_id(self.element_json[u'错误弹窗确定ID']) != []:
                        logging.info(self.deviceid + u'-账号秒封,重新注册')
                    else:
                        if self.gj_mode == '测试'.decode('utf-8'):
                            self.driver.implicitly_wait(180)
                            self.driver.find_element_by_name('我').click()
                            wxid = re.findall('(wxid_[0-9a-z]{1,100})',self.driver.find_element_by_id('com.tencent.mm:id/czz').get_attribute(("text")))[0]
                            self.driver.find_element_by_name('微信').click()
                            self.driver.keyevent(4)
                            while True:
                                if self.driver.find_elements_by_id('com.dobe.sandbox:id/appIcon')!=[]:
                                    self.driver.find_element_by_id('com.dobe.sandbox:id/appIcon').click()
                                if self.driver.find_elements_by_name('微信')!=[]:
                                    break
                            #self.q(wxid)
                            self.sandbox_save(wxid)
                            break
                        else:
                            self.xr_wechat(mf='True')
                            logging.info(self.deviceid + u'-注册数据已写入文件')
                            break
                #os.popen('adb -s %s shell am start -n com.dobe.sandbox/.home.Main2Activity' % self.deviceid)
                #self.Judgment_Devices()
                #time.sleep(2)
                #self.driver.implicitly_wait(30)
                #if self.driver.find_elements_by_id('com.dobe.sandbox:id/context_menu')!=[]:
                #    self.driver.find_element_by_id('com.dobe.sandbox:id/context_menu').click()
                #    self.Judgment_Devices()
                #    self.driver.find_element_by_name('关闭进程').click()
                #    self.Judgment_Devices()
                #    self.driver.find_element_by_name('确认关闭').click()
                #    time.sleep(3)
                #    if self.driver.find_elements_by_id('com.dobe.sandbox:id/appIcon')!=[]:
                #        self.driver.find_element_by_id('com.dobe.sandbox:id/appIcon').click()
                #        time.sleep(5)

    def q(self,wxid):
        self.driver.implicitly_wait(2)
        while True:
            if self.driver.find_elements_by_id(self.element_json[u'错误弹窗确定ID']) != []:
                self.driver.quit()
                break
            if self.driver.find_elements_by_id(self.element_json[u'首页注册ID']) != []:
                logging.info(self.deviceid + u'-账号被秒封')
                self.driver.quit()
                break
            if self.driver.find_elements_by_id(self.element_json[u'微信四个主按钮ID']) != []:
                self.driver.find_elements_by_id(self.element_json[u'微信四个主按钮ID'])[2].click()
                logging.info(self.deviceid + u'-点击发现')
                break
            if self.driver.find_elements_by_id(self.element_json[u'输入框ID']) != []:
                logging.info(self.deviceid + u'-账号被秒封')
                self.driver.quit()
        time.sleep(random.randint(1, 3))
        self.driver.implicitly_wait(10)
        if self.gj_mode == '测试'.decode("utf-8"):
            wechat_list = '%s_%s  %s  %s  %s  %s  \n' % (self.phonenumber[0], self.wxmm, self.ip, self.deviceid, datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), wxid )
            file().write(wechat_list, '微信账号数据(不带环境包).txt')
        if self.driver.find_elements_by_name('朋友圈') != []:
            self.driver.find_element_by_name('朋友圈').click()
            time.sleep(random.randint(1, 3))
        else:
            logging.info(self.deviceid + u'-点击发现失败,重新点击')
            self.driver.find_elements_by_id(self.element_json[u'微信四个主按钮ID'])[2].click()
            self.driver.find_element_by_name('朋友圈').click()
        time.sleep(random.randint(1, 3))
        if self.driver.find_elements_by_id(self.element_json[u'朋友圈相机ID']) != []:
            TouchAction(self.driver).long_press(self.driver.find_element_by_id(self.element_json[u'朋友圈相机ID']),3000).release().perform()
        time.sleep(random.randint(1, 3))
        self.driver.implicitly_wait(5)
        # 检测有没有朋友圈
        if self.driver.find_elements_by_id(self.element_json[u'发表按钮ID']) != []:
            self.input_pyq_message()
        else:
            time.sleep(random.randint(1, 2))
            self.driver.find_element_by_id(self.element_json[u'我知道了ID']).click()
            self.input_pyq_message()
        logging.info(self.deviceid + u'-点击发表')
        self.driver.implicitly_wait(60)
        time.sleep(random.randint(1, 2))
        self.driver.find_element_by_android_uiautomator(
            'new UiSelector().description("返回")').click()
        time.sleep(random.randint(1, 2))
        self.driver.find_elements_by_id(self.element_json[u'微信四个主按钮ID'])[0].click()
        time.sleep(3)

    def sandbox_save(self,wxid):
        os.system('adb -s ' + self.deviceid + ' shell am force-stop org.wuji')
        self.driver.keyevent(4)
        #os.popen('adb -s %s shell am start -n com.dobe.sandbox/.home.Main2Activity'%self.deviceid)
        self.driver.implicitly_wait(50)
        self.Judgment_Devices()
        self.driver.find_element_by_id('com.dobe.sandbox:id/context_menu').click()
        self.Judgment_Devices()
        self.driver.find_element_by_name('关闭进程').click()
        self.Judgment_Devices()
        self.driver.find_element_by_name('确认关闭').click()
        self.Judgment_Devices()
        time.sleep(2)
        self.driver.find_element_by_id('com.dobe.sandbox:id/download_device').click()
        self.Judgment_Devices()
        self.driver.find_element_by_name('备份恢复').click()
        self.Judgment_Devices()
        self.driver.find_element_by_name('+ 创建备份').click()
        self.Judgment_Devices()
        os.popen('adb -s %s shell input text %s' % (self.deviceid, self.phonenumber[0]))
        self.Judgment_Devices()
        self.driver.find_element_by_name('确定').click()
        time.sleep(5)
        while True:
            time.sleep(2)
            if len(self.driver.find_elements_by_class_name('android.widget.ImageView')) < 2:
                logging.info(u'%s-数据备份完成' % self.deviceid)
                break
        time.sleep(5)
        self.new_package = re.findall('(.*?).zip', os.popen('adb -s %s shell ls /sdcard/boxbackup' % self.deviceid).read().strip('\n'))[0]
        self.xr_wechat(wxid=wxid, cloudCode = self.new_package + '.zip')
        logging.info(self.deviceid + u'-注册数据已写入文件')
        os.popen(
            'start adb -s %s pull /sdcard/boxbackup/%s.zip package/%s/%s.zip' % (self.deviceid, self.new_package,self.deviceid,self.new_package))
        while True:
            try:
                f = zipfile.ZipFile("package/%s/%s.zip" % (self.deviceid, self.new_package), 'r')
                for file in f.namelist():
                    f.extract(file, "package/%s/0" % self.deviceid)
                break
            except:pass
        time.sleep(2)
        file_data = open('package/%s/0/0/hook/data.json' % self.deviceid, 'r').read()
        self.CPU_ABI = json.loads(file_data)['CPU_ABI']
        logging.info('%s-CPU_ABI:%s' % (self.deviceid, self.CPU_ABI))
        self.ANDROID_ID = json.loads(file_data)['android_id']
        logging.info('%s-ANDROID_ID:%s' % (self.deviceid, self.ANDROID_ID))
        A16_list = []
        for filename in os.listdir('package/%s/0/0/com.tencent.mm/files/kvcomm/' % self.deviceid):
            try:
                with open('package/%s/0/0/com.tencent.mm/files/kvcomm/%s' % (self.deviceid, filename), 'r') as f:
                    A16 = re.findall(
                        '(A[0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z])',
                        f.read())
                    if A16 != []:
                        A16_list.append(A16[0])
            except:
                pass
        Notes = zipfile.ZipFile(r'package/%s/%s.zip'%(self.deviceid,self.new_package), 'r').comment
        list = ['app_tbs', 'lib','tinker']
        logging.info(u'%s-A16:%s' % (self.deviceid, A16_list[0]))
        self.scanCode(A16_list[0])
        for i in list:
            try:
                Pack.remove_dir('package/%s/0/0/com.tencent.mm/%s' % (self.deviceid,i))
            except:pass
        for i in range(100,1000):
            try:
                Pack.remove_dir('package/%s/0/0/com.tencent.mm/app_xwalk_%s' % (self.deviceid, i))
            except:pass
        shutil.make_archive('package/%s/%s' % (self.deviceid,self.new_package), 'zip', r'package/%s/0'%(self.deviceid))
        zf = zipfile.ZipFile('package/%s/%s.zip' % (self.deviceid,self.new_package), 'a')
        zf.comment = Notes
        zf.close()
        time.sleep(2)
        try:
            Pack.remove_dir('package/%s/0'%self.deviceid)
        except:pass
        os.popen('adb -s %s rm -rf /sdcard/boxbackup' % self.deviceid)

    def save_wechat_data(self):
        self.wxid = self.w.get_wxid()
        self.cloudCode = self.w.getCloudCode(self.phonenumber[0])
        self.xr_wechat(self.wxid, self.cloudCode, 'True')
        logging.info(self.deviceid + u'-注册数据已写入文件')
        logging.info(self.deviceid + u'-正在保存微霸数据请稍等')
    # 国内登录
    def login_validation(self, yz):
        if yz == None:
            self.driver.quit()
        if yz == 'succ':
            self.send_login()

    #国内发圈
    def fpyq(self, yz):
        if yz == None:
            self.driver.quit()
        if yz == 'succ':
            self.send_login()
        else:
            logging.info(self.deviceid + u'-未接收到卡商反馈,注册失败')

    def input_pyq_message(self):
        time.sleep(random.randint(1, 2))
        self.driver.find_element_by_id(self.element_json[u'朋友圈内容输入框ID']).click()
        try:
            self.driver.find_element_by_id(self.element_json[u'朋友圈内容输入框ID']).send_keys(file().sh())
        except:
            self.driver.find_element_by_id(self.element_json[u'朋友圈内容输入框ID']).send_keys('My name is daduizhang')
        logging.info(self.deviceid + u'-输入文字')
        time.sleep(random.randint(1, 2))
        self.driver.find_element_by_id(self.element_json[u'发表按钮ID']).click()
    def pd_gj(self):
        if self.gj_mode == '1.微霸改机'.decode("utf-8"):
            self.wb_new()
        if self.gj_mode == '2.神奇改机'.decode("utf-8"):
            self.dd_new()
        if self.gj_mode == '测试'.decode("utf-8"):
            self.sand_box()
    def new_zh(self):
        try:
            self.pd_gj()
            self.register()
            self.input_text()
            self.login_validation(self.qr_validation(self.yztp()))
        except:
            traceback.print_exc()
            logging.info(self.deviceid + u'-账号注册失败')

    def new_zhpyq(self):
        try:
            self.pd_gj()
            self.register()
            self.input_text()
            self.fpyq(self.qr_validation(self.yztp()))
        except:
            traceback.print_exc()
            logging.info(self.deviceid + u'-账号注册失败')

    def gw_zc_t62_1280(self):
        pass

    def zc_pyq_t62(self):
        try:
            self.pd_gj()
            if self.country == '1.国内'.decode("utf-8"):
                self.register()
                self.input_text()
                self.fpyq(self.qr_validation(self.yztp()))
        except:
            traceback.print_exc()
            logging.info(self.deviceid + u'-账号注册失败')
            try:
                if self.phmode == '3.火箭API'.decode("utf-8"):
                    self.ph.hj_fail(TokenYZ.pdtoken(), self.phonenumber[1])
            except:pass
예제 #13
0
 def sandbox_login(self, ph, mm):
     with open('跳辅设置.txt'.decode('utf-8'), 'r') as f:
         mode = json.loads(f.read())['transmission_mode']
     os.popen('adb -s %s shell rm -rf /sdcard/boxbackup' % self.deviceid)
     os.popen('adb -s %s shell mkdir /sdcard/boxbackup' % self.deviceid)
     fsize = int(
         round(
             os.path.getsize('package/%s/%s' %
                             (self.deviceid, self.cloudCode)) /
             float(1024 * 1024), 2)) - 2
     with open('沙盒账密配置.json'.decode('utf-8'), 'r') as f:
         a = json.loads(f.read())
     for i in a:
         if self.deviceid == i['deviceid']:
             username = i['username']
             password = i['password']
     if mode == 'ftp':
         with open('server_config.txt', 'r') as f:
             data = json.loads(f.read())
         time.sleep(2)
         os.popen(
             'start adb -s %s shell curl ftp://%s/package/%s/%s -o /sdcard/boxbackup/%s'
             % (self.deviceid, data['host'], self.deviceid, self.cloudCode,
                self.cloudCode))
     if mode == 'adb':
         os.popen(
             'start adb -s %s push package/%s/%s /sdcard/boxbackup/%s' %
             (self.deviceid, self.deviceid, self.cloudCode, self.cloudCode))
     time.sleep(2)
     while True:
         time.sleep(3)
         try:
             sj_fsize = re.findall(
                 '([0-9]{1,3})M',
                 os.popen('adb -s %s shell ls -lh sdcard/boxbackup/%s' %
                          (self.deviceid, self.cloudCode)).read())[0]
             logging.info(u'%s-正在检查文件传输状态,请稍等' % self.deviceid)
             if int(sj_fsize) > int(fsize):
                 logging.info(u'%s-文件传输完毕' % self.deviceid)
                 break
         except:
             pass
     self.driver = Open().Phone('com.dobe.sandbox', '.home.Main2Activity',
                                self.deviceid, self.port)
     self.driver.implicitly_wait(60)
     self.driver.find_element_by_id(
         'com.dobe.sandbox:id/download_icon').click()
     wz = self.driver.find_element_by_id(
         'com.dobe.sandbox:id/textView').get_attribute(('text'))
     while True:
         if wz.encode('utf-8') == '尚未登陆,点击登陆':
             self.driver.find_element_by_name('尚未登陆,点击登陆').click()
             self.driver.find_element_by_id(
                 'com.dobe.sandbox:id/editText').send_keys(username)
             self.driver.find_element_by_id(
                 'com.dobe.sandbox:id/editText2').send_keys(password)
             self.driver.keyevent('66')
             time.sleep(1)
             self.driver.find_element_by_name('点击登陆').click()
             if self.driver.find_elements_by_id(
                     'com.dobe.sandbox:id/download_icon') != []:
                 break
         else:
             self.driver.keyevent('4')
             break
     self.driver.find_element_by_id(
         'com.dobe.sandbox:id/context_menu').click()
     self.driver.find_element_by_name('清除APP数据').click()
     self.driver.find_element_by_name('确认删除').click()
     time.sleep(5)
     self.driver.find_element_by_id(
         'com.dobe.sandbox:id/download_device').click()
     self.driver.find_element_by_name('备份恢复').click()
     while True:
         if self.driver.find_elements_by_id(
                 'com.dobe.sandbox:id/backup_info') != []:
             self.driver.find_element_by_id(
                 'com.dobe.sandbox:id/backup_info').click()
             self.driver.find_element_by_name('确定').click()
             break
     time.sleep(10)
     os.popen('adb -s %s shell am force-stop com.dobe.sandbox' %
              self.deviceid)
     time.sleep(3)
     os.popen(
         'adb -s %s shell am start -n com.dobe.sandbox/.home.Main2Activity'
         % self.deviceid)
     if self.driver.find_elements_by_id(
             'com.dobe.sandbox:id/context_menu') != []:
         self.driver.find_element_by_id(
             'com.dobe.sandbox:id/appIcon').click()
     return ph, mm
예제 #14
0
class login_wechat():
    def __init__(self,
                 deviceid,
                 port,
                 gj_mode,
                 country=None,
                 gj=None,
                 wxid=None,
                 login_mode=None,
                 cloudCode=None,
                 ip=None,
                 date=None,
                 switchingmode=None):
        self.deviceid = deviceid
        self.port = port
        self.om = file().readOperationMode()
        self.gj_mode = gj_mode
        self.country = country
        self.gj = gj
        self.w = WB(self.deviceid)
        self.wxid = wxid
        self.login_mode = login_mode
        self.cloudCode = cloudCode
        self.ip = ip
        self.date = date
        self.switchingmode = switchingmode
        self.element_json = json.loads(file.read_all('6.7.3.json'))

    def sandbox_login(self, ph, mm):
        with open('跳辅设置.txt'.decode('utf-8'), 'r') as f:
            mode = json.loads(f.read())['transmission_mode']
        os.popen('adb -s %s shell rm -rf /sdcard/boxbackup' % self.deviceid)
        os.popen('adb -s %s shell mkdir /sdcard/boxbackup' % self.deviceid)
        fsize = int(
            round(
                os.path.getsize('package/%s/%s' %
                                (self.deviceid, self.cloudCode)) /
                float(1024 * 1024), 2)) - 2
        with open('沙盒账密配置.json'.decode('utf-8'), 'r') as f:
            a = json.loads(f.read())
        for i in a:
            if self.deviceid == i['deviceid']:
                username = i['username']
                password = i['password']
        if mode == 'ftp':
            with open('server_config.txt', 'r') as f:
                data = json.loads(f.read())
            time.sleep(2)
            os.popen(
                'start adb -s %s shell curl ftp://%s/package/%s/%s -o /sdcard/boxbackup/%s'
                % (self.deviceid, data['host'], self.deviceid, self.cloudCode,
                   self.cloudCode))
        if mode == 'adb':
            os.popen(
                'start adb -s %s push package/%s/%s /sdcard/boxbackup/%s' %
                (self.deviceid, self.deviceid, self.cloudCode, self.cloudCode))
        time.sleep(2)
        while True:
            time.sleep(3)
            try:
                sj_fsize = re.findall(
                    '([0-9]{1,3})M',
                    os.popen('adb -s %s shell ls -lh sdcard/boxbackup/%s' %
                             (self.deviceid, self.cloudCode)).read())[0]
                logging.info(u'%s-正在检查文件传输状态,请稍等' % self.deviceid)
                if int(sj_fsize) > int(fsize):
                    logging.info(u'%s-文件传输完毕' % self.deviceid)
                    break
            except:
                pass
        self.driver = Open().Phone('com.dobe.sandbox', '.home.Main2Activity',
                                   self.deviceid, self.port)
        self.driver.implicitly_wait(60)
        self.driver.find_element_by_id(
            'com.dobe.sandbox:id/download_icon').click()
        wz = self.driver.find_element_by_id(
            'com.dobe.sandbox:id/textView').get_attribute(('text'))
        while True:
            if wz.encode('utf-8') == '尚未登陆,点击登陆':
                self.driver.find_element_by_name('尚未登陆,点击登陆').click()
                self.driver.find_element_by_id(
                    'com.dobe.sandbox:id/editText').send_keys(username)
                self.driver.find_element_by_id(
                    'com.dobe.sandbox:id/editText2').send_keys(password)
                self.driver.keyevent('66')
                time.sleep(1)
                self.driver.find_element_by_name('点击登陆').click()
                if self.driver.find_elements_by_id(
                        'com.dobe.sandbox:id/download_icon') != []:
                    break
            else:
                self.driver.keyevent('4')
                break
        self.driver.find_element_by_id(
            'com.dobe.sandbox:id/context_menu').click()
        self.driver.find_element_by_name('清除APP数据').click()
        self.driver.find_element_by_name('确认删除').click()
        time.sleep(5)
        self.driver.find_element_by_id(
            'com.dobe.sandbox:id/download_device').click()
        self.driver.find_element_by_name('备份恢复').click()
        while True:
            if self.driver.find_elements_by_id(
                    'com.dobe.sandbox:id/backup_info') != []:
                self.driver.find_element_by_id(
                    'com.dobe.sandbox:id/backup_info').click()
                self.driver.find_element_by_name('确定').click()
                break
        time.sleep(10)
        os.popen('adb -s %s shell am force-stop com.dobe.sandbox' %
                 self.deviceid)
        time.sleep(3)
        os.popen(
            'adb -s %s shell am start -n com.dobe.sandbox/.home.Main2Activity'
            % self.deviceid)
        if self.driver.find_elements_by_id(
                'com.dobe.sandbox:id/context_menu') != []:
            self.driver.find_element_by_id(
                'com.dobe.sandbox:id/appIcon').click()
        return ph, mm

    def visualization(self, message):
        try:
            requests.get(
                'http://127.0.0.1:666/query?time=%s&number=%s&state=%s' %
                (int(time.time()), self.deviceid, message))
        except:
            pass

    def error_message(self):
        while True:
            if '外挂' in self.cw.encode('utf-8'):
                return 'waigua'
            if '批量' in self.cw.encode('utf-8'):
                return 'piliang'
            if '密码错误' in self.cw.encode('utf-8'):
                return 'piliang'
            if '多人投诉' in self.cw.encode('utf-8'):
                return 'tousu'
            if '系统检测' in self.cw.encode('utf-8'):
                return 'xitong'
            if '微信登陆环境存在异常' in self.cw.encode('utf-8'):
                return 'huanjingyichang'
            if '添加好友' in self.cw.encode('utf-8'):
                return 'tianjia'
            if '使用存在异常' in self.cw.encode('utf-8'):
                return 'shiyongyichang'
            if '传播色情' in self.cw.encode('utf-8'):
                return 'seqing'
            if '长期未登陆' in self.cw.encode('utf-8'):
                return 'changqi'
            if '你的微信号由于长期' in self.cw.encode('utf-8'):
                return 'weishiyong'
            if '解封环境异常' in self.cw.encode('utf-8'):
                return 'jiefengyichang'
            if '手机通讯录' in self.cw.encode('utf-8'):
                self.driver.find_element_by_name('否').click()
                return None
            if '表情' in self.cw.encode('utf-8'):
                self.driver.find_element_by_name(' 取消 ').click()
                return None
            if '通过短信验证码' in self.cw.encode('utf-8'):
                self.driver.find_element_by_name('确定').click()
                return None
            if '注册了新的微信号' in self.cw.encode('utf-8'):
                return 'newwechat'

    def mm_login(self, ph, mm):
        time.sleep(20)
        self.driver.implicitly_wait(1)
        while True:
            #如果出现输入框
            if self.driver.find_elements_by_id(
                    self.element_json[u'输入框ID']) != []:
                self.driver.implicitly_wait(60)
                time.sleep(2)
                if self.driver.find_elements_by_id(
                        'com.tencent.mm:id/ji') != []:
                    self.driver.find_element_by_id(
                        'com.tencent.mm:id/ji').click()
                    time.sleep(1)
                    os.popen('adb -s %s shell input text %s' %
                             (self.deviceid, mm))
                logging.info(self.deviceid + u'-输入密码')
                time.sleep(2)
                self.driver.find_element_by_id('com.tencent.mm:id/ch6').click()
                logging.info(self.deviceid + u'-点击登录')
                self.driver.implicitly_wait(60)
                if self.driver.find_elements_by_id(
                        'com.tencent.mm:id/cvo') != []:
                    # 判断是否登录不上
                    self.cw = self.driver.find_element_by_id(
                        'com.tencent.mm:id/cvo').get_attribute(('text'))
                    if '表情' in self.cw.encode('utf-8'):
                        self.driver.find_element_by_name('取消').click()
                        break
                    if '通过微信密码' in self.cw.encode('utf-8'):
                        self.driver.find_element_by_name('忽略').click()
                        break
                    else:
                        return self.error_message()
            if self.driver.find_elements_by_id('com.tencent.mm:id/cvo') != []:
                logging.info(u'%s-发现错误弹窗' % self.deviceid)
                self.cw = self.driver.find_element_by_id(
                    'com.tencent.mm:id/cvo').get_attribute(('text'))
                if '表情' in self.cw.encode('utf-8'):
                    self.driver.find_element_by_name(' 取消 ').click()
                if '通过微信密码' in self.cw.encode('utf-8'):
                    self.driver.find_element_by_name('忽略').click()
                    break
                else:
                    self.driver.implicitly_wait(60)
                    self.driver.find_element_by_id(
                        'com.tencent.mm:id/au_').click()
                    logging.info(u'%s-点击确定' % self.deviceid)
                    logging.info(self.deviceid + u'-登陆出现错误')
                    os.popen(
                        'adb -s %s shell am start -n com.dobe.sandbox/.home.Main2Activity'
                        % self.deviceid)
                    self.driver.find_element_by_id(
                        'com.dobe.sandbox:id/appIcon').click()
                    logging.info(u'%s-打开微信' % self.deviceid)
                    self.driver.implicitly_wait(1)
            #如果进入微信页面
            if self.driver.find_elements_by_id('com.tencent.mm:id/cw2') != []:
                break
            #如果进入微信首页
            if self.driver.find_elements_by_id('com.tencent.mm:id/dbe') != []:
                self.Home_Login(ph, mm)
                while True:
                    if self.driver.find_elements_by_id(
                            'com.tencent.mm:id/cvo') != []:
                        self.cw = self.driver.find_element_by_id(
                            'com.tencent.mm:id/cvo').get_attribute(('text'))
                        return self.error_message()
                    if self.driver.find_elements_by_android_uiautomator(
                            'new UiSelector().description("拖动下方滑块完成拼图")'
                    ) != []:
                        return 'huatu'
                    if self.driver.find_elements_by_name('拖动下方滑块完成拼图') != []:
                        return 'huatu'
            if self.driver.find_elements_by_id('com.dobe.sandbox:id/appIcon'):
                self.driver.find_element_by_id(
                    'com.dobe.sandbox:id/appIcon').click()

    def Home_Login(self, ph, mm):
        self.driver.implicitly_wait(10)
        self.driver.find_element_by_name('登录').click()
        self.driver.find_element_by_id(self.element_json[u'输入框ID']).click()
        os.system('adb -s %s shell input text %s' % (self.deviceid, ph))
        logging.info(self.deviceid + u'-输入账号')
        self.visualization('输入账号')
        self.driver.find_element_by_id(
            self.element_json[u'输入手机号码登陆下一步']).click()
        self.visualization('下一步')
        logging.info(self.deviceid + u'-下一步')
        self.driver.find_elements_by_id(self.element_json[u'输入框ID'])[1].click()
        os.system('adb -s %s shell input text %s' % (self.deviceid, mm))
        self.visualization('输入密码')
        logging.info(self.deviceid + u'-输入密码')
        self.driver.find_element_by_id(
            self.element_json[u'输入手机号码登陆下一步']).click()
        self.visualization('登录')
        logging.info(self.deviceid + u'-登录')

    def zh_login(self, wechat_list):
        self.driver.implicitly_wait(5)
        if self.driver.find_elements_by_name(self.element_json['allow']) != []:
            self.driver.find_element_by_name(
                self.element_json['allow']).click()
            self.driver.find_element_by_name(
                self.element_json['allow']).click()
        self.driver.implicitly_wait(30)
        self.driver.find_element_by_name(self.element_json['login']).click()
        self.driver.find_element_by_id(self.element_json[u'输入框ID']).click()
        os.system('adb -s %s shell input text %s' %
                  (self.deviceid, wechat_list[0]))
        self.visualization('输入账号')
        logging.info(self.deviceid + u'-输入账号')
        self.driver.find_element_by_id(
            self.element_json[u'输入手机号码登陆下一步']).click()
        self.visualization('下一步')
        logging.info(self.deviceid + u'-下一步')
        self.driver.find_elements_by_id(self.element_json[u'输入框ID'])[1].click()
        os.system('adb -s %s shell input text %s' %
                  (self.deviceid, wechat_list[1]))
        self.visualization('输入密码')
        logging.info(self.deviceid + u'-输入密码')
        self.driver.find_element_by_id(
            self.element_json[u'输入手机号码登陆下一步']).click()
        self.visualization('登录')
        logging.info(self.deviceid + u'-登录')
        self.driver.implicitly_wait(2)
        while True:
            if self.driver.find_elements_by_id(
                    self.element_json[u'错误弹窗内容ID']) != []:
                self.cw = self.driver.find_element_by_id(
                    self.element_json[u'错误弹窗内容ID']).get_attribute(('text'))
                return self.error_message()
            if self.driver.find_elements_by_id(
                    self.element_json[u'微信四个主按钮ID']) != []:
                break
            if self.driver.find_elements_by_android_uiautomator(
                    'new UiSelector().description("拖动下方滑块完成拼图")') != []:
                logging.info(u'%s-进入滑图页面' % self.deviceid)
                while True:
                    for j in range(100, 200, 30):
                        try:
                            a = TouchAction(self.driver)
                            a.press(x=250, y=1000)
                            for i in range(0, 5):
                                a.move_to(x=50, y=(random.randint(-500,
                                                                  0))).wait(0)
                                a.move_to(x=50,
                                          y=(random.randint(0, 500))).wait(0)
                            for i in range(0, j / 10):
                                a.move_to(x=10, y=0).wait(100)
                            a.release().perform()
                        except:
                            pass
                    if self.driver.find_elements_by_android_uiautomator(
                            'new UiSelector().description("开始验证 ")') != []:
                        file().write('%s\n' % wechat_list[0], '新设备记录文本.txt')
                        logging.info(u'%s-%s该账号出现新设备' %
                                     (self.deviceid, wechat_list[0]))
                        self.driver.quit()
                        break
                    if self.driver.find_elements_by_id(
                            self.element_json[u'输入手机号码登陆下一步']) != []:
                        self.driver.find_element_by_id(
                            self.element_json[u'输入手机号码登陆下一步']).click()
                        break
                    if self.driver.find_elements_by_android_uiautomator(
                            'new UiSelector().description("声音锁验证 ")') != []:
                        file().write('%s\n' % wechat_list[0], '新设备记录文本.txt')
                        logging.info(u'%s-%s该账号出现新设备' %
                                     (self.deviceid, wechat_list[0]))
                        self.driver.quit()
                        break
            if self.driver.find_elements_by_android_uiautomator(
                    'new UiSelector().description("开始验证 ")') != []:
                file().write('%s\n' % wechat_list[0], '新设备记录文本.txt')
                logging.info(u'%s-%s该账号出现新设备' %
                             (self.deviceid, wechat_list[0]))
                self.driver.quit()
                break

    def upgrade(self):
        if self.driver.find_elements_by_name('微信团队邀请你参与内部体验') != []:
            self.driver.find_element_by_name('微信团队邀请你参与内部体验').click()

    def login_fail(self, error, wechat_list):
        if error == 'waigua':
            file().write(
                '%s %s %s %s 外挂 %s\n' % (wechat_list[0], wechat_list[1],
                                         self.ip, self.date, self.deviceid),
                '登录异常账号.txt')
        if error == 'piliang':
            file().write(
                '%s %s %s %s 批量 %s\n' % (wechat_list[0], wechat_list[1],
                                         self.ip, self.date, self.deviceid),
                '登录异常账号.txt')
        if error == 'mimacuowu':
            file().write(
                '%s %s %s %s 密码错误 %s\n' % (wechat_list[0], wechat_list[1],
                                           self.ip, self.date, self.deviceid),
                '登录异常账号.txt')
        if error == 'tousu':
            file().write(
                '%s %s %s %s 多人投诉被限制登陆 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'jidiao':
            file().write(
                '%s %s %s %s 在别的设备登陆过 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'xitong':
            file().write(
                '%s %s %s %s 系统检测到你的账号有异常 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'huanjingyichang':
            file().write(
                '%s %s %s %s 当前设备的微信登陆环境存在异常 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'tianjia':
            file().write(
                '%s %s %s %s 当前账号添加好友过于频繁 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'shiyongyichang':
            file().write(
                '%s %s %s %s 当前账号的使用存在异常 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'seqing':
            file().write(
                '%s %s %s %s该微信账号因涉嫌传播色情 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'changqi':
            file().write(
                '%s %s %s %s 该账号长期未登陆 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'huatu':
            file().write(
                '%s %s %s %s 进入滑图页面 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'weishiyong':
            file().write(
                '%s %s %s %s 该账号长期未使用,已被收回 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'jiefengyichang':
            file().write(
                '%s %s %s %s 解封环境异常 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'newwechat':
            file().write(
                '%s %s %s %s 注册了新的微信号 %s\n' %
                (wechat_list[0], wechat_list[1], self.ip, self.date,
                 self.deviceid), '登录异常账号.txt')
        if error == 'huatu':
            file().write(
                '%s %s %s %s 出现滑图 %s\n' % (wechat_list[0], wechat_list[1],
                                           self.ip, self.date, self.deviceid),
                '登录异常账号.txt')

    def add_friend(self, zh, mm, hy):
        self.driver.implicitly_wait(60)
        self.driver.find_element_by_id(self.element_json[u'微信页面加号']).click()
        self.driver.find_elements_by_id(self.element_json[u'加号列表'])[1].click()
        self.visualization('添加朋友')
        logging.info(self.deviceid + u'-添加朋友')
        self.driver.find_element_by_id(self.element_json[u'输入框ID']).click()
        self.driver.find_element_by_id(
            self.element_json[u'输入框ID']).send_keys(hy)
        time.sleep(3)
        if self.driver.find_elements_by_id(self.element_json[u'点击添加按钮']) != []:
            self.driver.find_element_by_id(
                self.element_json[u'点击添加按钮']).click()
        self.driver.implicitly_wait(2)
        while True:
            if self.driver.find_elements_by_id(
                    self.element_json[u'设置备注']) != []:
                break
            if self.driver.find_elements_by_id(
                    self.element_json[u'错误弹窗确定ID']) != []:
                self.driver.find_element_by_id(
                    self.element_json[u'错误弹窗确定ID']).click()
                time.sleep(3)
                self.driver.find_element_by_id(
                    self.element_json[u'点击添加按钮']).click()
        while True:
            if self.driver.find_elements_by_id(
                    self.element_json[u'添加通讯录']) != []:
                self.driver.find_element_by_id(
                    self.element_json[u'添加通讯录']).click()
            if self.driver.find_elements_by_id(
                    self.element_json[u'发消息']) != []:
                self.driver.find_element_by_id(
                    self.element_json[u'发消息']).click()
            if self.driver.find_elements_by_id(
                    self.element_json[u'消息内容框ID']) != []:
                break
        self.driver.implicitly_wait(180)
        self.driver.find_element_by_id(
            self.element_json[u'消息内容框ID']).send_keys(zh)
        logging.info(self.deviceid + u'-正在发送信息:' + zh)
        self.visualization('正在发送信息:%s' % zh)
        time.sleep(5)
        self.driver.find_element_by_id(self.element_json[u'消息发送按钮ID']).click()
        self.visualization('点击发送')
        logging.info(self.deviceid + u'-点击发送')
        time.sleep(2)
        if self.gj_mode == '1.微霸改机'.decode("utf-8"):
            file().writehy('%s_%s  %s  %s  %s  %s| %s' %
                           (self.wechat_list[0], self.wechat_list[1],
                            datetime.datetime.now().strftime('%Y-%m-%d'),
                            self.deviceid, self.wxid, self.cloudCode, hy))
        else:
            file().writehy('%s  %s  %s %s' % (zh, mm, self.deviceid, hy))

    def circle_of_friends(self):
        self.driver.implicitly_wait(60)
        self.driver.find_elements_by_id(
            self.element_json[u'微信四个主按钮ID'])[2].click()
        self.visualization('点击发送')
        logging.info(self.deviceid + u'-点击发现')
        time.sleep(random.randint(1, 3))
        self.driver.find_elements_by_id(
            self.element_json[u'发现页面朋友圈ID'])[0].click()
        self.visualization('点击朋友圈')
        logging.info(self.deviceid + u'-点击朋友圈')
        time.sleep(5)
        if self.driver.find_elements_by_id(
                self.element_json[u'朋友圈相机ID']) != []:
            TouchAction(self.driver).long_press(
                self.driver.find_element_by_id(self.element_json[u'朋友圈相机ID']),
                3000).release().perform()
            logging.info(self.deviceid + u'-长按相机')
            self.visualization('长按相机')
        self.driver.implicitly_wait(5)
        if self.driver.find_elements_by_id(self.element_json[u'发表按钮ID']) != []:
            self.input_message()
        else:
            time.sleep(random.randint(1, 2))
            self.driver.find_element_by_id(
                self.element_json[u'我知道了ID']).click()
            self.input_message()
        self.visualization('点击发表')
        logging.info(self.deviceid + u'-点击发表')
        self.driver.find_element_by_android_uiautomator(
            'new UiSelector().description("返回")').click()
        time.sleep(random.randint(1, 3))
        self.driver.find_element_by_id(self.element_json[u'微信四个主按钮ID']).click()
        time.sleep(random.randint(1, 3))
        if self.gj_mode == '1.微霸改机'.decode("utf-8"):
            file().write_pyq_succ(
                '%s_%s  %s  %s  %s  %s|' %
                (self.wechat_list[0], self.wechat_list[1],
                 datetime.datetime.now().strftime('%Y-%m-%d'), self.deviceid,
                 self.wxid, self.cloudCode))
        else:
            file().write_pyq_succ(
                '%s  %s  %s  %s' %
                (self.wechat_list[0], self.wechat_list[1],
                 datetime.datetime.now().strftime('%Y-%m-%d'), self.deviceid))

    def input_message(self):
        time.sleep(random.randint(1, 2))
        self.visualization('进入到发文字朋友圈页面')
        logging.info(self.deviceid + u'-进入到发文字朋友圈页面')
        self.driver.find_element_by_id(
            self.element_json[u'朋友圈内容输入框ID']).click()
        self.driver.find_element_by_id(
            self.element_json[u'朋友圈内容输入框ID']).send_keys(file().sh())
        self.visualization('输入文字')
        logging.info(self.deviceid + u'-输入文字')
        time.sleep(random.randint(1, 2))
        self.driver.find_element_by_id(self.element_json[u'发表按钮ID']).click()

    #打开影子科技
    def start_yz(self):
        os.system(
            'adb -s ' + self.deviceid +
            ' shell am force-stop wechatscancoder.jionego.com.wechatscancoder')
        os.popen(
            'adb -s %s shell am start -n wechatscancoder.jionego.com.wechatscancoder/.MainActivity'
            % self.deviceid).read()
        time.sleep(3)
        os.popen('adb -s %s shell am start -n com.tencent.mm/.ui.LauncherUI' %
                 self.deviceid).read()

    #获取62二维码
    def get_qr_image(self):
        folder = os.path.exists('./%s' % self.deviceid)
        if not folder:
            os.makedirs('./%s' % self.deviceid)
        else:
            pass
        res = requests.get('http://193.112.218.104:89/api?str=Initialize').text
        image = json.loads(res)['qrcode']
        data_62 = json.loads(res)['data']
        h = open("./%s/%s.jpg" % (self.deviceid, self.deviceid), "wb")
        h.write(base64.b64decode(image))
        h.close()
        os.popen('adb -s %s push ./%s/%s.jpg  /sdcard/myData/%s.jpg' %
                 (self.deviceid, self.deviceid, self.deviceid,
                  self.deviceid)).read()
        time.sleep(2)
        os.popen(
            'adb -s %s shell mv /sdcard/myData/%s.jpg /sdcard/myData/scan.jpg'
            % (self.deviceid, self.deviceid)).read()
        time.sleep(2)
        os.popen('adb -s %s shell curl http://127.0.0.1:8089?api=scandCode' %
                 self.deviceid)
        time.sleep(3)
        for i in range(0, 10):
            os.popen('adb -s %s shell input tap 524 1587' % self.deviceid)
        return data_62

    def check_62(self):
        try:
            data = open('config.ini', 'r').read()
            return json.loads(data)['62'], json.loads(data)['A16']
        except:
            with open('config.ini', 'w') as f:
                f.write('{"62":"False","A16":"False"}')
            return "False", "False"

    def sys(self, ph, mm):
        self.driver.implicitly_wait(180)
        self.driver.find_elements_by_id(
            self.element_json[u'微信四个主按钮ID'])[0].click()
        config_data = self.check_62()
        if config_data[0] == "True":
            self.start_yz()
            if token().get_jurisdiction(TokenYZ.pdtoken(),
                                        self.deviceid) != None:
                for i in range(0, 5):
                    self.visualization('开始提62')
                    logging.info(self.deviceid + u'-开始提62')
                    data_62 = self.get_qr_image()
                    for j in range(0, 3):
                        os.system(
                            'adb -s %s shell input swipe 500 1200 500 1600' %
                            self.deviceid)
                        self.driver.implicitly_wait(5)
                        if self.driver.find_elements_by_id(
                                'com.tencent.mm:id/co5') != []:
                            if self.driver.find_elements_by_name(
                                    'Mac 微信已登录') != []:
                                self.driver.find_element_by_name(
                                    'Mac 微信已登录').click()
                                time.sleep(2)
                            if self.driver.find_elements_by_name(
                                    'iPad 微信已登录') != []:
                                self.visualization('提62成功')
                                logging.info(self.deviceid + u'-提62成功')
                                file().write(
                                    '%s----%s----%s----%s----%s\n' %
                                    (ph, mm, data_62, self.wxid,
                                     datetime.datetime.now().strftime(
                                         '%Y-%m-%d')), '提62成功列表.txt')
                                token().huojian_t62(self.deviceid,
                                                    TokenYZ.pdtoken())
                                return data_62
                    if i == 4:
                        self.visualization('提取62失败')
                        logging.info(u'%s-提取62失败' % self.deviceid)
                        file().write('%s|\n' % ph, '提62失败列表.txt')
                        break
        if config_data[1] == "True":
            os.system('adb -s %s shell input keyevent 3' % self.deviceid)
            if token().get_jurisdiction(TokenYZ.pdtoken(),
                                        self.deviceid) != None:
                self.T_A16(ph, mm)

    def smjhy(self, ph=None, mm=None, device_token=None, hy=None):
        try:
            self.wechat_list = self.sandbox_login(ph, mm)
            self.error = self.mm_login(self.wechat_list[0],
                                       self.wechat_list[1])
            if self.error != None:
                self.login_fail(self.error, self.wechat_list)
            else:
                self.add_friend(self.wechat_list[0], self.wechat_list[1], hy)
                self.visualization('成功')
                logging.info(self.deviceid + u'-成功')
        except:
            traceback.print_exc()
            try:
                self.driver.quit()
                self.visualization('失败')
                logging.info(self.deviceid + u'-失败')
            except:
                pass

    #发朋友圈
    def fpyq(self, ph=None, mm=None, device_token=None):
        try:
            self.wechat_list = self.sandbox_login(ph, mm)
            self.error = self.mm_login(self.wechat_list[0],
                                       self.wechat_list[1])
            if self.error != None:
                self.login_fail(self.error, self.wechat_list)
            else:
                self.circle_of_friends()
                self.visualization('成功')
                logging.info(self.deviceid + u'-成功')
        except:
            try:
                self.driver.quit()
                self.visualization('成功')
                logging.info(self.deviceid + u'-失败')
            except:
                pass

    #登录
    def wechat_signout(self, ph=None, mm=None, device_token=None):
        try:
            self.wechat_list = self.sandbox_login(ph, mm)
            self.error = self.mm_login(self.wechat_list[0],
                                       self.wechat_list[1])
            if self.error != None:
                self.login_fail(self.error, self.wechat_list)
            else:
                self.sys(ph, mm)
                self.visualization('成功')
                logging.info(self.deviceid + u'-成功')
        except:
            try:
                self.driver.quit()
                self.visualization('失败')
                logging.info(self.deviceid + u'-失败')
            except:
                pass

    def T_A16(self, ph, mm):
        A16_list = []
        file_list = os.popen(
            'adb -s %s shell ls /data/data/com.tencent.mm/files/kvcomm/' %
            self.deviceid).readlines()
        try:
            for _file in file_list:
                os.system(
                    'adb -s %s shell su root chmod a+rw /data/data/com.tencent.mm/files/kvcomm/%s'
                    % (self.deviceid, _file))
                file_data = os.popen(
                    'adb -s %s shell su root cat -v /data/data/com.tencent.mm/files/kvcomm/%s'
                    % (self.deviceid, _file)).read()
                A16 = re.findall(',(A[0-9a-z]{15})', file_data)
                if A16 != []:
                    A16_list.append(A16[0])
            device_data = os.popen(
                'adb -s %s shell curl "http://127.0.0.1:8888/cmd?group=AppTool\&action=getHookDevice'
                % self.deviceid).read()
            data = json.loads(device_data)['data']
            file().write(
                '%s|%s|%s|%s|%s|%s|%s|%s\n' %
                (ph, mm, A16_list[0], data['phone']['Imei'],
                 data['build']['ANDROIDID'], data['phone']['BSSID'],
                 data['build']['CPU_ABI'], data['build']['BRAND']),
                'A16数据.txt')
            self.visualization('提A16数据成功')
            logging.info(u'%s-提A16数据成功' % self.deviceid)
            token().huojian_t62(self.deviceid, TokenYZ.pdtoken())
        except:
            self.visualization('提A16数据失败')
            logging.info(u'%s-提A16数据失败' % self.deviceid)

    def login_sys(self, ph=None, mm=None, device_token=None):
        try:
            if self.gj_mode == '1.微霸改机'.decode("utf-8"):
                self.wechat_list = self.wb_login(ph, mm)
                if self.login_mode == '1.wxid登陆'.decode("utf-8"):
                    self.error = self.mm_login(self.wechat_list[0],
                                               self.wechat_list[1])
                if self.login_mode == '2.云码登陆'.decode("utf-8"):
                    self.error = self.zh_login(self.wechat_list)
            if self.gj_mode == '2.神奇改机'.decode("utf-8"):
                self.wechat_list = self.dd_switch(ph, mm, device_token)
                self.error = self.zh_login(self.wechat_list)
            if self.error != None:
                self.login_fail(self.error, self.wechat_list)
            else:
                self.sys(ph, mm)
        except:
            try:
                self.driver.quit()
                self.visualization('失败')
                logging.info(self.deviceid + u'-失败')
            except:
                pass
예제 #15
0
 def connectbot(self):
         os.system('adb -s ' + self.deviceid + ' shell am force-stop org.connectbot')
         driver = Open().Phone('org.connectbot', '.HostListActivity', self.deviceid, self.port)
         driver.implicitly_wait(180)
         driver.find_elements_by_id('android:id/icon')[0].click()
         driver.implicitly_wait(2)
         while True:
             if driver.find_elements_by_id('org.connectbot:id/console_prompt_yes') != []:
                 driver.find_element_by_id('org.connectbot:id/console_prompt_yes').click()
                 driver.find_element_by_id('android:id/content').click()
             if driver.find_elements_by_id('org.connectbot:id/console_password') != []:
                 driver.find_element_by_id('org.connectbot:id/console_password').send_keys('kk123')
                 driver.keyevent(66)
                 time.sleep(1)
                 driver.keyevent(66)
                 break
         time.sleep(3)
class login_wechat():
    def __init__(self, deviceid, port, gj_mode, country=None, gj=None, wxid=None, login_mode=None, cloudCode=None, ip=None, date=None,switchingmode=None):
        self.deviceid = deviceid
        self.port = port
        self.om = file().readOperationMode()
        self.gj_mode = gj_mode
        self.country = country
        self.gj = gj
        self.w = WB(self.deviceid)
        self.wxid = wxid
        self.login_mode = login_mode
        self.cloudCode = cloudCode
        self.ip = ip
        self.date = date
        self.switchingmode=switchingmode
        self.element_json = json.loads(file.read_all('6.7.3.json'))


    def sandbox_login(self, ph, mm):
        with open('跳辅设置.txt'.decode('utf-8'), 'r')as f:
            mode = json.loads(f.read())['transmission_mode']
        os.popen('adb -s %s shell rm -rf /sdcard/boxbackup' % self.deviceid)
        os.popen('adb -s %s shell mkdir /sdcard/boxbackup' % self.deviceid)
        fsize = int(
            round(os.path.getsize('package/%s/%s' % (self.deviceid, self.cloudCode)) / float(1024 * 1024), 2)) - 2
        with open('沙盒账密配置.json'.decode('utf-8'), 'r') as f:
            a = json.loads(f.read())
        for i in a:
            if self.deviceid == i['deviceid']:
                username = i['username']
                password = i['password']
        if mode == 'ftp':
            with open('server_config.txt', 'r') as f:
                data = json.loads(f.read())
            time.sleep(2)
            os.popen('start adb -s %s shell curl ftp://%s/package/%s/%s -o /sdcard/boxbackup/%s'%(self.deviceid,data['host'],self.deviceid,self.cloudCode,self.cloudCode))
        if mode == 'adb':
            os.popen('start adb -s %s push package/%s/%s /sdcard/boxbackup/%s' %(self.deviceid,self.deviceid,self.cloudCode,self.cloudCode))
        time.sleep(2)
        while True:
            time.sleep(3)
            try:
                sj_fsize = re.findall('([0-9]{1,3})M', os.popen('adb -s %s shell ls -lh sdcard/boxbackup/%s'%(self.deviceid,self.cloudCode)).read())[0]
                logging.info(u'%s-正在检查文件传输状态,请稍等' % self.deviceid)
                if int(sj_fsize) > int(fsize):
                    logging.info(u'%s-文件传输完毕'% self.deviceid)
                    break
            except:
                pass
        self.driver = Open().Phone('com.dobe.sandbox', '.home.Main2Activity', self.deviceid, self.port)
        self.driver.implicitly_wait(60)
        self.driver.find_element_by_id('com.dobe.sandbox:id/download_icon').click()
        wz = self.driver.find_element_by_id('com.dobe.sandbox:id/textView').get_attribute(('text'))
        while True:
            if wz.encode('utf-8') == '尚未登陆,点击登陆':
                self.driver.find_element_by_name('尚未登陆,点击登陆').click()
                self.driver.find_element_by_id('com.dobe.sandbox:id/editText').send_keys(username)
                self.driver.find_element_by_id('com.dobe.sandbox:id/editText2').send_keys(password)
                self.driver.keyevent('66')
                time.sleep(1)
                self.driver.find_element_by_name('点击登陆').click()
                if self.driver.find_elements_by_id('com.dobe.sandbox:id/download_icon') != []:
                    break
            else:
                self.driver.keyevent('4')
                break
        self.driver.find_element_by_id('com.dobe.sandbox:id/context_menu').click()
        self.driver.find_element_by_name('清除APP数据').click()
        self.driver.find_element_by_name('确认删除').click()
        time.sleep(5)
        self.driver.find_element_by_id('com.dobe.sandbox:id/download_device').click()
        self.driver.find_element_by_name('备份恢复').click()
        while True:
            if self.driver.find_elements_by_id('com.dobe.sandbox:id/backup_info') != []:
                self.driver.find_element_by_id('com.dobe.sandbox:id/backup_info').click()
                self.driver.find_element_by_name('确定').click()
                break
        time.sleep(10)
        os.popen('adb -s %s shell am force-stop com.dobe.sandbox' % self.deviceid)
        time.sleep(3)
        os.popen('adb -s %s shell am start -n com.dobe.sandbox/.home.Main2Activity' % self.deviceid)
        if self.driver.find_elements_by_id('com.dobe.sandbox:id/context_menu') != []:
            self.driver.find_element_by_id('com.dobe.sandbox:id/appIcon').click()
        return ph,mm

    def visualization(self, message):
        try:
            requests.get('http://127.0.0.1:666/query?time=%s&number=%s&state=%s' % (int(time.time()), self.deviceid, message))
        except:pass

    def error_message(self):
        while True:
            if '外挂' in self.cw.encode('utf-8'):
                return 'waigua'
            if '批量' in self.cw.encode('utf-8'):
                return 'piliang'
            if '密码错误' in self.cw.encode('utf-8'):
                return 'piliang'
            if '多人投诉' in self.cw.encode('utf-8'):
                return 'tousu'
            if '系统检测' in self.cw.encode('utf-8'):
                return 'xitong'
            if '微信登陆环境存在异常' in self.cw.encode('utf-8'):
                return 'huanjingyichang'
            if '添加好友' in self.cw.encode('utf-8'):
                return 'tianjia'
            if '使用存在异常' in self.cw.encode('utf-8'):
                return 'shiyongyichang'
            if '传播色情' in self.cw.encode('utf-8'):
                return 'seqing'
            if '长期未登陆' in self.cw.encode('utf-8'):
                return 'changqi'
            if '你的微信号由于长期' in self.cw.encode('utf-8'):
                return 'weishiyong'
            if '解封环境异常' in self.cw.encode('utf-8'):
                return 'jiefengyichang'
            if '手机通讯录' in self.cw.encode('utf-8'):
                self.driver.find_element_by_name('否').click()
                return None
            if '表情' in self.cw.encode('utf-8'):
                self.driver.find_element_by_name(' 取消 ').click()
                return None
            if '通过短信验证码' in self.cw.encode('utf-8'):
                self.driver.find_element_by_name('确定').click()
                return None
            if '注册了新的微信号' in self.cw.encode('utf-8'):
                return 'newwechat'



    def mm_login(self, ph, mm):
        time.sleep(20)
        self.driver.implicitly_wait(1)
        while True:
            #如果出现输入框
            if self.driver.find_elements_by_id(self.element_json[u'输入框ID'])!=[]:
                self.driver.implicitly_wait(60)
                time.sleep(2)
                if self.driver.find_elements_by_id('com.tencent.mm:id/ji') != []:
                    self.driver.find_element_by_id('com.tencent.mm:id/ji').click()
                    time.sleep(1)
                    os.popen('adb -s %s shell input text %s' % (self.deviceid, mm))
                logging.info(self.deviceid + u'-输入密码')
                time.sleep(2)
                self.driver.find_element_by_id('com.tencent.mm:id/ch6').click()
                logging.info(self.deviceid + u'-点击登录')
                self.driver.implicitly_wait(60)
                if self.driver.find_elements_by_id('com.tencent.mm:id/cvo') != []:
                    # 判断是否登录不上
                    self.cw = self.driver.find_element_by_id('com.tencent.mm:id/cvo').get_attribute(('text'))
                    if '表情' in self.cw.encode('utf-8'):
                        self.driver.find_element_by_name('取消').click()
                        break
                    if '通过微信密码' in self.cw.encode('utf-8'):
                        self.driver.find_element_by_name('忽略').click()
                        break
                    else:
                        return self.error_message()
            if self.driver.find_elements_by_id('com.tencent.mm:id/cvo')!=[]:
                logging.info(u'%s-发现错误弹窗'%self.deviceid)
                self.cw = self.driver.find_element_by_id('com.tencent.mm:id/cvo').get_attribute(('text'))
                if '表情' in self.cw.encode('utf-8'):
                    self.driver.find_element_by_name(' 取消 ').click()
                if '通过微信密码' in self.cw.encode('utf-8'):
                    self.driver.find_element_by_name('忽略').click()
                    break
                else:
                    self.driver.implicitly_wait(60)
                    self.driver.find_element_by_id('com.tencent.mm:id/au_').click()
                    logging.info(u'%s-点击确定' % self.deviceid)
                    logging.info(self.deviceid + u'-登陆出现错误')
                    os.popen('adb -s %s shell am start -n com.dobe.sandbox/.home.Main2Activity' % self.deviceid)
                    self.driver.find_element_by_id('com.dobe.sandbox:id/appIcon').click()
                    logging.info(u'%s-打开微信' % self.deviceid)
                    self.driver.implicitly_wait(1)
            #如果进入微信页面
            if self.driver.find_elements_by_id('com.tencent.mm:id/cw2')!=[]:
                break
            #如果进入微信首页
            if self.driver.find_elements_by_id('com.tencent.mm:id/dbe')!=[]:
                self.Home_Login(ph, mm)
                while True:
                    if self.driver.find_elements_by_id('com.tencent.mm:id/cvo') != []:
                        self.cw = self.driver.find_element_by_id('com.tencent.mm:id/cvo').get_attribute(('text'))
                        return self.error_message()
                    if self.driver.find_elements_by_android_uiautomator(
                        'new UiSelector().description("拖动下方滑块完成拼图")') != []:
                        return 'huatu'
                    if self.driver.find_elements_by_name('拖动下方滑块完成拼图') != []:
                        return 'huatu'
            if self.driver.find_elements_by_id('com.dobe.sandbox:id/appIcon'):
                self.driver.find_element_by_id('com.dobe.sandbox:id/appIcon').click()

    def Home_Login(self,ph,mm):
        self.driver.implicitly_wait(10)
        self.driver.find_element_by_name('登录').click()
        self.driver.find_element_by_id(self.element_json[u'输入框ID']).click()
        os.system('adb -s %s shell input text %s' % (self.deviceid, ph))
        logging.info(self.deviceid + u'-输入账号')
        self.visualization('输入账号')
        self.driver.find_element_by_id(self.element_json[u'输入手机号码登陆下一步']).click()
        self.visualization('下一步')
        logging.info(self.deviceid + u'-下一步')
        self.driver.find_elements_by_id(self.element_json[u'输入框ID'])[1].click()
        os.system('adb -s %s shell input text %s' % (self.deviceid, mm))
        self.visualization('输入密码')
        logging.info(self.deviceid + u'-输入密码')
        self.driver.find_element_by_id(self.element_json[u'输入手机号码登陆下一步']).click()
        self.visualization('登录')
        logging.info(self.deviceid + u'-登录')

    def zh_login(self, wechat_list):
        self.driver.implicitly_wait(5)
        if self.driver.find_elements_by_name(self.element_json['allow']) != []:
            self.driver.find_element_by_name(self.element_json['allow']).click()
            self.driver.find_element_by_name(self.element_json['allow']).click()
        self.driver.implicitly_wait(30)
        self.driver.find_element_by_name(self.element_json['login']).click()
        self.driver.find_element_by_id(self.element_json[u'输入框ID']).click()
        os.system('adb -s %s shell input text %s' % (self.deviceid, wechat_list[0]))
        self.visualization('输入账号')
        logging.info(self.deviceid + u'-输入账号')
        self.driver.find_element_by_id(self.element_json[u'输入手机号码登陆下一步']).click()
        self.visualization('下一步')
        logging.info(self.deviceid + u'-下一步')
        self.driver.find_elements_by_id(self.element_json[u'输入框ID'])[1].click()
        os.system('adb -s %s shell input text %s' % (self.deviceid, wechat_list[1]))
        self.visualization('输入密码')
        logging.info(self.deviceid + u'-输入密码')
        self.driver.find_element_by_id(self.element_json[u'输入手机号码登陆下一步']).click()
        self.visualization('登录')
        logging.info(self.deviceid + u'-登录')
        self.driver.implicitly_wait(2)
        while True:
            if self.driver.find_elements_by_id(self.element_json[u'错误弹窗内容ID']) != []:
                self.cw = self.driver.find_element_by_id(self.element_json[u'错误弹窗内容ID']).get_attribute(('text'))
                return self.error_message()
            if self.driver.find_elements_by_id(self.element_json[u'微信四个主按钮ID']) != []:
                break
            if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("拖动下方滑块完成拼图")') != []:
                logging.info(u'%s-进入滑图页面' % self.deviceid)
                while True:
                    for j in range(100, 200, 30):
                        try:
                            a = TouchAction(self.driver)
                            a.press(x=250, y=1000)
                            for i in range(0, 5):
                                a.move_to(x=50, y=(random.randint(-500, 0))).wait(0)
                                a.move_to(x=50, y=(random.randint(0, 500))).wait(0)
                            for i in range(0, j / 10):
                                a.move_to(x=10, y=0).wait(100)
                            a.release().perform()
                        except:
                            pass
                    if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("开始验证 ")') != []:
                        file().write('%s\n' % wechat_list[0], '新设备记录文本.txt')
                        logging.info(u'%s-%s该账号出现新设备' % (self.deviceid, wechat_list[0]))
                        self.driver.quit()
                        break
                    if self.driver.find_elements_by_id(self.element_json[u'输入手机号码登陆下一步']) != []:
                        self.driver.find_element_by_id(self.element_json[u'输入手机号码登陆下一步']).click()
                        break
                    if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("声音锁验证 ")') != []:
                        file().write('%s\n' % wechat_list[0], '新设备记录文本.txt')
                        logging.info(u'%s-%s该账号出现新设备' % (self.deviceid, wechat_list[0]))
                        self.driver.quit()
                        break
            if self.driver.find_elements_by_android_uiautomator('new UiSelector().description("开始验证 ")') != []:
                file().write('%s\n' % wechat_list[0], '新设备记录文本.txt')
                logging.info(u'%s-%s该账号出现新设备' % (self.deviceid, wechat_list[0]))
                self.driver.quit()
                break

    def upgrade(self):
        if self.driver.find_elements_by_name('微信团队邀请你参与内部体验')!=[]:
            self.driver.find_element_by_name('微信团队邀请你参与内部体验').click()

    def login_fail(self, error, wechat_list):
        if error == 'waigua':
            file().write('%s %s %s %s 外挂 %s\n' % (wechat_list[0], wechat_list[1], self.ip, self.date, self.deviceid),'登录异常账号.txt')
        if error == 'piliang':
            file().write('%s %s %s %s 批量 %s\n' %(wechat_list[0], wechat_list[1], self.ip, self.date, self.deviceid),'登录异常账号.txt')
        if error == 'mimacuowu':
            file().write('%s %s %s %s 密码错误 %s\n' % (wechat_list[0], wechat_list[1], self.ip, self.date, self.deviceid),'登录异常账号.txt')
        if error == 'tousu':
            file().write('%s %s %s %s 多人投诉被限制登陆 %s\n' % (wechat_list[0], wechat_list[1],self.ip,self.date, self.deviceid), '登录异常账号.txt')
        if error == 'jidiao':
            file().write('%s %s %s %s 在别的设备登陆过 %s\n' % (wechat_list[0], wechat_list[1],self.ip,self.date, self.deviceid),'登录异常账号.txt')
        if error == 'xitong':
            file().write('%s %s %s %s 系统检测到你的账号有异常 %s\n' % (wechat_list[0], wechat_list[1], self.ip,self.date,self.deviceid),'登录异常账号.txt')
        if error == 'huanjingyichang':
            file().write('%s %s %s %s 当前设备的微信登陆环境存在异常 %s\n' % (wechat_list[0], wechat_list[1],self.ip,self.date, self.deviceid),'登录异常账号.txt')
        if error == 'tianjia':
            file().write('%s %s %s %s 当前账号添加好友过于频繁 %s\n' % (wechat_list[0], wechat_list[1],self.ip,self.date ,self.deviceid),'登录异常账号.txt')
        if error == 'shiyongyichang':
            file().write('%s %s %s %s 当前账号的使用存在异常 %s\n' % (wechat_list[0], wechat_list[1], self.ip,self.date,self.deviceid),'登录异常账号.txt')
        if error == 'seqing':
            file().write('%s %s %s %s该微信账号因涉嫌传播色情 %s\n' % (wechat_list[0], wechat_list[1],self.ip,self.date, self.deviceid), '登录异常账号.txt')
        if error == 'changqi':
            file().write('%s %s %s %s 该账号长期未登陆 %s\n' % (wechat_list[0], wechat_list[1], self.ip,self.date,self.deviceid),'登录异常账号.txt')
        if error == 'huatu':
            file().write('%s %s %s %s 进入滑图页面 %s\n' % (wechat_list[0], wechat_list[1],self.ip,self.date, self.deviceid),'登录异常账号.txt')
        if error == 'weishiyong':
            file().write('%s %s %s %s 该账号长期未使用,已被收回 %s\n' % (wechat_list[0], wechat_list[1], self.ip, self.date, self.deviceid),'登录异常账号.txt')
        if error == 'jiefengyichang':
            file().write( '%s %s %s %s 解封环境异常 %s\n' % (wechat_list[0], wechat_list[1], self.ip, self.date, self.deviceid), '登录异常账号.txt')
        if error == 'newwechat':
            file().write('%s %s %s %s 注册了新的微信号 %s\n' % (wechat_list[0], wechat_list[1], self.ip, self.date, self.deviceid),'登录异常账号.txt')
        if error == 'huatu':
            file().write('%s %s %s %s 出现滑图 %s\n' % (wechat_list[0], wechat_list[1], self.ip, self.date, self.deviceid),'登录异常账号.txt')
    def add_friend(self, zh, mm, hy):
        self.driver.implicitly_wait(60)
        self.driver.find_element_by_id(self.element_json[u'微信页面加号']).click()
        self.driver.find_elements_by_id(self.element_json[u'加号列表'])[1].click()
        self.visualization('添加朋友')
        logging.info(self.deviceid + u'-添加朋友')
        self.driver.find_element_by_id(self.element_json[u'输入框ID']).click()
        self.driver.find_element_by_id(self.element_json[u'输入框ID']).send_keys(hy)
        time.sleep(3)
        if self.driver.find_elements_by_id(self.element_json[u'点击添加按钮']) != []:
            self.driver.find_element_by_id(self.element_json[u'点击添加按钮']).click()
        self.driver.implicitly_wait(2)
        while True:
            if self.driver.find_elements_by_id(self.element_json[u'设置备注'])!=[]:
                break
            if self.driver.find_elements_by_id(self.element_json[u'错误弹窗确定ID'])!=[]:
                self.driver.find_element_by_id(self.element_json[u'错误弹窗确定ID']).click()
                time.sleep(3)
                self.driver.find_element_by_id(self.element_json[u'点击添加按钮']).click()
        while True:
            if self.driver.find_elements_by_id(self.element_json[u'添加通讯录']) != []:
                self.driver.find_element_by_id(self.element_json[u'添加通讯录']).click()
            if self.driver.find_elements_by_id(self.element_json[u'发消息'])!=[]:
                self.driver.find_element_by_id(self.element_json[u'发消息']).click()
            if self.driver.find_elements_by_id(self.element_json[u'消息内容框ID'])!=[]:
                break
        self.driver.implicitly_wait(180)
        self.driver.find_element_by_id(self.element_json[u'消息内容框ID']).send_keys(zh)
        logging.info(self.deviceid + u'-正在发送信息:' + zh)
        self.visualization('正在发送信息:%s' % zh)
        time.sleep(5)
        self.driver.find_element_by_id(self.element_json[u'消息发送按钮ID']).click()
        self.visualization('点击发送')
        logging.info(self.deviceid + u'-点击发送')
        time.sleep(2)
        if self.gj_mode == '1.微霸改机'.decode("utf-8"):
            file().writehy('%s_%s  %s  %s  %s  %s| %s' % (
            self.wechat_list[0], self.wechat_list[1], datetime.datetime.now().strftime('%Y-%m-%d'), self.deviceid, self.
                wxid, self.cloudCode, hy))
        else:
            file().writehy('%s  %s  %s %s' % (zh, mm, self.deviceid,hy))

    def circle_of_friends(self):
        self.driver.implicitly_wait(60)
        self.driver.find_elements_by_id(self.element_json[u'微信四个主按钮ID'])[2].click()
        self.visualization('点击发送')
        logging.info(self.deviceid + u'-点击发现')
        time.sleep(random.randint(1, 3))
        self.driver.find_elements_by_id(self.element_json[u'发现页面朋友圈ID'])[0].click()
        self.visualization('点击朋友圈')
        logging.info(self.deviceid + u'-点击朋友圈')
        time.sleep(5)
        if self.driver.find_elements_by_id(self.element_json[u'朋友圈相机ID'])!=[]:
            TouchAction(self.driver).long_press(self.driver.find_element_by_id(self.element_json[u'朋友圈相机ID']), 3000).release().perform()
            logging.info(self.deviceid + u'-长按相机')
            self.visualization('长按相机')
        self.driver.implicitly_wait(5)
        if self.driver.find_elements_by_id(self.element_json[u'发表按钮ID']) != []:
            self.input_message()
        else:
            time.sleep(random.randint(1, 2))
            self.driver.find_element_by_id(self.element_json[u'我知道了ID']).click()
            self.input_message()
        self.visualization('点击发表')
        logging.info(self.deviceid + u'-点击发表')
        self.driver.find_element_by_android_uiautomator(
            'new UiSelector().description("返回")').click()
        time.sleep(random.randint(1, 3))
        self.driver.find_element_by_id(self.element_json[u'微信四个主按钮ID']).click()
        time.sleep(random.randint(1, 3))
        if self.gj_mode == '1.微霸改机'.decode("utf-8"):
            file().write_pyq_succ('%s_%s  %s  %s  %s  %s|' % (
            self.wechat_list[0], self.wechat_list[1], datetime.datetime.now().strftime('%Y-%m-%d'), self.deviceid, self.
                wxid, self.cloudCode))
        else:
            file().write_pyq_succ('%s  %s  %s  %s' % (self.wechat_list[0], self.wechat_list[1], datetime.datetime.now().
                                                      strftime('%Y-%m-%d'), self.deviceid))

    def input_message(self):
        time.sleep(random.randint(1, 2))
        self.visualization('进入到发文字朋友圈页面')
        logging.info(self.deviceid + u'-进入到发文字朋友圈页面')
        self.driver.find_element_by_id(self.element_json[u'朋友圈内容输入框ID']).click()
        self.driver.find_element_by_id(self.element_json[u'朋友圈内容输入框ID']).send_keys(file().sh())
        self.visualization('输入文字')
        logging.info(self.deviceid + u'-输入文字')
        time.sleep(random.randint(1, 2))
        self.driver.find_element_by_id(self.element_json[u'发表按钮ID']).click()
    #打开影子科技
    def start_yz(self):
        os.system('adb -s ' + self.deviceid + ' shell am force-stop wechatscancoder.jionego.com.wechatscancoder')
        os.popen('adb -s %s shell am start -n wechatscancoder.jionego.com.wechatscancoder/.MainActivity' % self.deviceid).read()
        time.sleep(3)
        os.popen('adb -s %s shell am start -n com.tencent.mm/.ui.LauncherUI' % self.deviceid).read()

    #获取62二维码
    def get_qr_image(self):
        folder = os.path.exists('./%s' % self.deviceid)
        if not folder:
            os.makedirs('./%s' % self.deviceid)
        else:
            pass
        res = requests.get('http://193.112.218.104:89/api?str=Initialize').text
        image = json.loads(res)['qrcode']
        data_62 = json.loads(res)['data']
        h = open("./%s/%s.jpg" % (self.deviceid, self.deviceid), "wb")
        h.write(base64.b64decode(image))
        h.close()
        os.popen('adb -s %s push ./%s/%s.jpg  /sdcard/myData/%s.jpg' % (self.deviceid, self.deviceid,  self.deviceid,self.deviceid)).read()
        time.sleep(2)
        os.popen('adb -s %s shell mv /sdcard/myData/%s.jpg /sdcard/myData/scan.jpg' % (self.deviceid, self.deviceid)).read()
        time.sleep(2)
        os.popen('adb -s %s shell curl http://127.0.0.1:8089?api=scandCode' % self.deviceid)
        time.sleep(3)
        for i in range(0, 10):
            os.popen('adb -s %s shell input tap 524 1587' % self.deviceid)
        return data_62

    def check_62(self):
        try:
            data = open('config.ini', 'r').read()
            return json.loads(data)['62'], json.loads(data)['A16']
        except:
            with open('config.ini', 'w') as f:
                f.write('{"62":"False","A16":"False"}')
            return "False", "False"

    def sys(self, ph, mm):
        self.driver.implicitly_wait(180)
        self.driver.find_elements_by_id(self.element_json[u'微信四个主按钮ID'])[0].click()
        config_data = self.check_62()
        if config_data[0] == "True":
            self.start_yz()
            if token().get_jurisdiction(TokenYZ.pdtoken(), self.deviceid) != None:
                for i in range(0, 5):
                    self.visualization('开始提62')
                    logging.info(self.deviceid + u'-开始提62')
                    data_62 = self.get_qr_image()
                    for j in range(0, 3):
                        os.system('adb -s %s shell input swipe 500 1200 500 1600' % self.deviceid)
                        self.driver.implicitly_wait(5)
                        if self.driver.find_elements_by_id('com.tencent.mm:id/co5')!= []:
                            if self.driver.find_elements_by_name('Mac 微信已登录') != []:
                                self.driver.find_element_by_name('Mac 微信已登录').click()
                                time.sleep(2)
                            if self.driver.find_elements_by_name('iPad 微信已登录') != []:
                                self.visualization('提62成功')
                                logging.info(self.deviceid + u'-提62成功')
                                file().write('%s----%s----%s----%s----%s\n' % (ph, mm, data_62, self.wxid, datetime.datetime.now().strftime('%Y-%m-%d')), '提62成功列表.txt')
                                token().huojian_t62(self.deviceid, TokenYZ.pdtoken())
                                return data_62
                    if i == 4:
                        self.visualization('提取62失败')
                        logging.info(u'%s-提取62失败' % self.deviceid)
                        file().write('%s|\n' % ph, '提62失败列表.txt')
                        break
        if config_data[1] == "True":
            os.system('adb -s %s shell input keyevent 3' % self.deviceid)
            if token().get_jurisdiction(TokenYZ.pdtoken(), self.deviceid) != None:
                self.T_A16(ph, mm)

    def smjhy(self, ph=None, mm=None, device_token=None, hy=None):
        try:
            self.wechat_list = self.sandbox_login(ph, mm)
            self.error = self.mm_login(self.wechat_list[0], self.wechat_list[1])
            if self.error != None:
                self.login_fail(self.error, self.wechat_list)
            else:
                self.add_friend(self.wechat_list[0], self.wechat_list[1], hy)
                self.visualization('成功')
                logging.info(self.deviceid + u'-成功')
        except:
            traceback.print_exc()
            try:
                self.driver.quit()
                self.visualization('失败')
                logging.info(self.deviceid + u'-失败')
            except:pass

    #发朋友圈
    def fpyq(self, ph=None, mm=None, device_token=None):
        try:
            self.wechat_list = self.sandbox_login(ph, mm)
            self.error = self.mm_login(self.wechat_list[0], self.wechat_list[1])
            if self.error != None:
                self.login_fail(self.error, self.wechat_list)
            else:
                self.circle_of_friends()
                self.visualization('成功')
                logging.info(self.deviceid + u'-成功')
                os.system('adb -s ' + self.deviceid + ' shell am force-stop com.dobe.sandbox')
        except:
            try:
                self.driver.quit()
                self.visualization('成功')
                logging.info(self.deviceid + u'-失败')
            except:pass
    #登录
    def wechat_signout(self, ph=None, mm=None, device_token=None):
        try:
            self.wechat_list = self.sandbox_login(ph, mm)
            self.error = self.mm_login(self.wechat_list[0], self.wechat_list[1])
            if self.error != None:
                self.login_fail(self.error, self.wechat_list)
            else:
                self.sys(ph, mm)
                self.visualization('成功')
                logging.info(self.deviceid + u'-成功')
                os.system('adb -s ' + self.deviceid + ' shell am force-stop com.dobe.sandbox')
        except:
            try:
                self.driver.quit()
                self.visualization('失败')
                logging.info(self.deviceid + u'-失败')
            except:pass

    def T_A16(self, ph, mm):
        A16_list = []
        file_list = os.popen('adb -s %s shell ls /data/data/com.tencent.mm/files/kvcomm/'% self.deviceid).readlines()
        try:
            for _file in file_list:
                    os.system('adb -s %s shell su root chmod a+rw /data/data/com.tencent.mm/files/kvcomm/%s' % (self.deviceid,_file))
                    file_data = os.popen('adb -s %s shell su root cat -v /data/data/com.tencent.mm/files/kvcomm/%s' % (self.deviceid,_file)).read()
                    A16 = re.findall(',(A[0-9a-z]{15})', file_data)
                    if A16 != []:
                        A16_list.append(A16[0])
            device_data = os.popen('adb -s %s shell curl "http://127.0.0.1:8888/cmd?group=AppTool\&action=getHookDevice' % self.deviceid).read()
            data = json.loads(device_data)['data']
            file().write('%s|%s|%s|%s|%s|%s|%s|%s\n' % (ph, mm, A16_list[0], data['phone']['Imei'], data['build']['ANDROIDID'], data['phone']['BSSID'], data['build']['CPU_ABI'], data['build']['BRAND']), 'A16数据.txt')
            self.visualization('提A16数据成功')
            logging.info(u'%s-提A16数据成功' % self.deviceid)
            token().huojian_t62(self.deviceid, TokenYZ.pdtoken())
        except:
            self.visualization('提A16数据失败')
            logging.info(u'%s-提A16数据失败' % self.deviceid)
예제 #17
0
 def connectbot(self):
     os.system('adb -s ' + self.deviceid +
               ' shell am force-stop org.connectbot')
     driver = Open().Phone('org.connectbot', '.HostListActivity',
                           self.deviceid, self.port)
     driver.implicitly_wait(180)
     driver.find_elements_by_id('android:id/icon')[0].click()
     driver.implicitly_wait(2)
     while True:
         if driver.find_elements_by_id(
                 'org.connectbot:id/console_prompt_yes') != []:
             driver.find_element_by_id(
                 'org.connectbot:id/console_prompt_yes').click()
             driver.find_element_by_id('android:id/content').click()
         if driver.find_elements_by_id(
                 'org.connectbot:id/console_password') != []:
             driver.find_element_by_id(
                 'org.connectbot:id/console_password').send_keys('kk123')
             driver.keyevent(66)
             time.sleep(1)
             driver.keyevent(66)
             break
     time.sleep(3)
예제 #18
0
class mode():
    # 账号注册
    def __init__(self, deviceid, port, wxmm, switchingmode, phmode, t, gj_mode,
                 cooperator, country, gj, qh, login_mode, privince,
                 filtering_mode):
        self.user = file().readuser()
        self.deviceid = deviceid
        self.wxmm = wxmm
        self.port = port
        self.switchingmode = switchingmode
        self.fm = flightmode(deviceid, port)
        self.v = vpn(self.deviceid, port)
        self.phmode = PhoneNumber(self.user[3], self.user[6], self.user[9],
                                  self.deviceid, phmode, qh)
        self.f = phmode
        self.t = t
        self.gj_mode = gj_mode
        self.cooperator = cooperator
        self.country = country
        self.gj = gj
        self.qh = qh
        self.login_mode = login_mode
        self.privince = privince
        self.wj = wj(deviceid, port)
        self.filtering_mode = filtering_mode

    def connectbot(self):
        os.system('adb -s ' + self.deviceid +
                  ' shell am force-stop org.connectbot')
        driver = Open().Phone('org.connectbot', '.HostListActivity',
                              self.deviceid, self.port)
        driver.implicitly_wait(180)
        driver.find_elements_by_id('android:id/icon')[0].click()
        driver.implicitly_wait(2)
        while True:
            if driver.find_elements_by_id(
                    'org.connectbot:id/console_prompt_yes') != []:
                driver.find_element_by_id(
                    'org.connectbot:id/console_prompt_yes').click()
                driver.find_element_by_id('android:id/content').click()
            if driver.find_elements_by_id(
                    'org.connectbot:id/console_password') != []:
                driver.find_element_by_id(
                    'org.connectbot:id/console_password').send_keys('kk123')
                driver.keyevent(66)
                time.sleep(1)
                driver.keyevent(66)
                break
        time.sleep(3)

    def proxy(self):
        try:
            os.popen('adb -s %s shell kill -9 %s' %
                     (self.deviceid,
                      os.popen('adb -s %s shell "ps|grep org.proxydroid"' %
                               self.deviceid).read().split()[1]))
        except:
            pass
        os.system('adb -s ' + self.deviceid +
                  ' shell am force-stop org.proxydroid')
        self.driver = Open().Phone('org.proxydroid', '.ProxyDroid',
                                   self.deviceid, self.port)
        self.driver.implicitly_wait(180)
        self.driver.find_element_by_id('android:id/switch_widget').click()
        time.sleep(10)
        logging.info(self.deviceid + u'-Proxy成功连接')

    def pd_ip(self, m):
        if self.switchingmode == '1.飞行模式'.decode("utf-8"):
            return self.fm.flightmode(m, self.t, self.filtering_mode)
        if self.switchingmode == '2.VPN'.decode("utf-8"):
            return self.v.newvpn(m, self.t, self.filtering_mode)
        if self.switchingmode == '3.不换IP'.decode("utf-8"):
            self.ip = os.popen('adb -s %s shell curl "http://ip.cip.cc' %
                               self.deviceid).read()[0]
            return self.ip
        if self.switchingmode == '4.私人VPN'.decode('utf-8'):
            return self.wj.start(m, self.t, self.filtering_mode)
        if self.switchingmode == '5.私人VPN2'.decode('utf-8'):
            os.system('adb -s ' + self.deviceid +
                      ' shell am force-stop com.tencent.mm')
            ip = vps(self.deviceid).switching_VPS(m, self.filtering_mode)
            logging.info(self.deviceid + u'-服务器IP地址:%s' % ip)
            while True:
                try:
                    sj_ip = os.popen(
                        'adb -s ' + self.deviceid +
                        ' shell curl --connect-timeout 100 ip.cip.cc').read(
                        ).strip('\n')
                    logging.info(self.deviceid + u'-手机IP地址:%s' % sj_ip)
                    if ip in sj_ip:
                        return ip
                    else:
                        logging.info(self.deviceid + u'-手机IP跟服务器IP不一致')
                        self.connectbot()
                        self.proxy()
                except:
                    self.connectbot()
                    self.proxy()

    def wechat_list_Verification(self, culture_list):
        if culture_list == []:
            while True:
                logging.info(self.deviceid + u'-养号列表不存在该设备号数据')
                time.sleep(12)

    def run_mode(self):
        ye = str(token().get_balance(TokenYZ.gettoken()))
        return 'tm' + ye[-1]

    def get_wechatdata(self, culture_list):
        ph = re.findall('([0-9]{1,100})_', culture_list)[0]
        logging.info(self.deviceid + u'-获取到手机号码:' + ph)
        mm = re.findall('_(.*?) ', culture_list)[0]
        logging.info(self.deviceid + u'-获取到登录密码:' + mm)
        try:
            self.device_token = re.findall('dd_cloud:(.*)', culture_list)[0]
            logging.info(self.deviceid + u'-获取到多多云码:' + self.device_token)
        except:
            self.device_token = 'test'
        try:
            for i in culture_list.split():
                if 'ID' in i:
                    self.hy = i[3:]
            logging.info(self.deviceid + u'-获取到好友ID:' + self.hy)
        except:
            self.hy = 'test'
        try:
            self.wxid = 'wxid_' + re.findall('wxid_(.*)22  ',
                                             culture_list)[0] + '22'
            logging.info(self.deviceid + u'-获取WXID:' + self.wxid)
        except:
            logging.info(self.deviceid + u'-未获取到WXID')
            self.wxid = 'test'
        try:
            for i in culture_list.split():
                if 'zip' in i:
                    self.cloudCode = i[:-1]
            logging.info(self.deviceid + u'-获取环境包:%s' % self.cloudCode)
        except:
            logging.info(self.deviceid + u'-未获取环境包')
            self.cloudCode = 'test'
        try:
            self.ip = re.findall(
                '  ([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})  ',
                culture_list)[0]
            logging.info(self.deviceid + u'-获取到注册IP:' + self.ip)
        except:
            logging.info(self.deviceid + u'-未获取到注册IP')
            self.ip = 'test'
        try:
            self.date = re.findall('([0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2})',
                                   culture_list)[0]
            logging.info(self.deviceid + u'-获取到注册日期:' + self.date)
        except:
            logging.info(self.deviceid + u'-未获取到注册日期')
            self.date = 'test'
        return ph, mm, self.device_token, self.hy, self.wxid, self.cloudCode, self.ip, self.date

    def Judgment_Devices(self):
        while True:
            if os.system('adb -s %s shell cd /sdcard' % self.deviceid) != 0:
                logging.info(u'%s未检测到手机连接' % self.deviceid)
                time.sleep(5)
            else:
                break
                #raise Exception, "%s-未连接到手机" % self.deviceid

    def random_password_Verification(self):
        if self.wxmm == '请输入注册密码'.decode("utf-8"):
            while True:
                keylist = ''.join([
                    random.choice(string.digits + string.ascii_lowercase)
                    for i in range(6)
                ]) + str(random.randint(0, 9)) + 'a'
                if 'l' not in keylist:
                    if '9' in keylist:
                        break
            self.sjmm = keylist
            return self.sjmm
        else:
            self.sjmm = self.wxmm
            return self.sjmm

    #从养号列表获取第一条数据到微信账号数据列表去找这条数据
    def wb_mode_Verification(self):
        support_file_name = '养号列表.txt'
        support_Data = file.read(support_file_name)
        error_file_name = '登录异常账号.txt'
        error_Data_List = file.read_all(error_file_name)
        wechat_file_name = '微信账号数据.txt'
        wechat_Data_List = file.read(wechat_file_name)
        num = []
        new_data_list = []
        for data in wechat_Data_List:
            if self.deviceid in data:
                new_data_list.append(data)
        for support in support_Data:
            if 'True' not in support.strip('\n'):
                if re.findall('(.*)\|', support)[0] not in error_Data_List:
                    try:
                        for self.wechat_Data in new_data_list:
                            if re.findall('(.*)\|',
                                          support)[0] in self.wechat_Data:
                                num.append('%s ID:%s' %
                                           (self.wechat_Data.strip('\n'),
                                            re.findall('\|(.*)', support)[0]))
                    except:
                        logging.info(self.deviceid + u'-正则没有匹配到该条数据:' +
                                     self.wechat_Data)
        if num.__len__() <> 0:
            logging.info(self.deviceid + u'设备找到%s个数据' % num.__len__())
            return num
        else:
            logging.info(self.deviceid + u'该设备在养号列表中没有数据')
            time.sleep(10000)

    def breeding_Mode(self, mode):
        culture_list = self.wb_mode_Verification()
        for culture in culture_list:
            self.pd_ip('2')
            wechat_list = self.get_wechatdata(culture)
            if mode == 'moments':
                login_wechat(deviceid=self.deviceid,
                             port=self.port,
                             country=None,
                             gj_mode=self.gj_mode,
                             wxid=wechat_list[4],
                             login_mode=self.login_mode,
                             cloudCode=wechat_list[5],
                             ip=wechat_list[6],
                             date=wechat_list[7]).fpyq(
                                 ph=wechat_list[0],
                                 mm=wechat_list[1],
                                 device_token=wechat_list[2])
            if mode == 'login':
                login_wechat(deviceid=self.deviceid,
                             port=self.port,
                             country=None,
                             gj_mode=self.gj_mode,
                             wxid=wechat_list[4],
                             login_mode=self.login_mode,
                             cloudCode=wechat_list[5],
                             ip=wechat_list[6],
                             date=wechat_list[7]).wechat_signout(
                                 ph=wechat_list[0],
                                 mm=wechat_list[1],
                                 device_token=wechat_list[2])
            if mode == 'addfriends':
                login_wechat(deviceid=self.deviceid,
                             port=self.port,
                             country=None,
                             gj_mode=self.gj_mode,
                             wxid=wechat_list[4],
                             login_mode=self.login_mode,
                             cloudCode=wechat_list[5],
                             ip=wechat_list[6],
                             date=wechat_list[7]).smjhy(
                                 ph=wechat_list[0],
                                 mm=wechat_list[1],
                                 device_token=wechat_list[2],
                                 hy=wechat_list[3])
            if mode == 'dlsys':
                login_wechat(deviceid=self.deviceid,
                             port=self.port,
                             country=None,
                             gj_mode=self.gj_mode,
                             wxid=wechat_list[4],
                             login_mode=self.login_mode,
                             cloudCode=wechat_list[5],
                             ip=wechat_list[6],
                             date=wechat_list[7]).login_sys(
                                 ph=wechat_list[0],
                                 mm=wechat_list[1],
                                 device_token=wechat_list[2])

    #注册模式
    def Registration_Mode(self, mode):
        with open('跳辅设置.txt'.decode('utf-8'), 'r') as f:
            self.tm = json.loads(f.read())['runmode']
        while True:
            try:
                self.Judgment_Devices()
                phonenumber = self.phmode.all_getph()
                self.ip = self.pd_ip('1')
                if self.country == '2.国外'.decode("utf-8"):
                    self.wxmc = file().readwxmc().decode("gb2312").strip('\n')
                if self.country == '1.国内'.decode("utf-8"):
                    self.wxmc = file().readwxmc().strip('\n')
                    #self.wxmc = file().readwxmc().decode("gb2312").strip('\n')
                self.sjmm = self.random_password_Verification()
                if mode == 'zc':
                    newenvironment(self.user[3],
                                   self.user[6],
                                   self.user[9],
                                   self.deviceid,
                                   self.port,
                                   self.user[17],
                                   self.user[20],
                                   self.sjmm,
                                   self.f,
                                   self.wxmc.strip('\n'),
                                   phonenumber,
                                   self.gj_mode,
                                   self.tm,
                                   self.cooperator,
                                   country=self.country,
                                   gj=self.gj,
                                   qh=self.qh,
                                   switchingmode=self.switchingmode,
                                   filtering_mode=self.filtering_mode,
                                   t=self.t,
                                   ip=self.ip).new_zh()
                if mode == 'zcfpyq':
                    newenvironment(self.user[3],
                                   self.user[6],
                                   self.user[9],
                                   self.deviceid,
                                   self.port,
                                   self.user[17],
                                   self.user[20],
                                   self.sjmm,
                                   self.f,
                                   self.wxmc.strip('\n'),
                                   phonenumber,
                                   self.gj_mode,
                                   self.tm,
                                   self.cooperator,
                                   country=self.country,
                                   gj=self.gj,
                                   qh=self.qh,
                                   switchingmode=self.switchingmode,
                                   filtering_mode=self.filtering_mode,
                                   t=self.t,
                                   ip=self.ip).new_zhpyq()
                if mode == 'zc_pyq_t62':
                    newenvironment(self.user[3],
                                   self.user[6],
                                   self.user[9],
                                   self.deviceid,
                                   self.port,
                                   self.user[17],
                                   self.user[20],
                                   self.sjmm,
                                   self.f,
                                   self.wxmc.strip('\n'),
                                   phonenumber,
                                   self.gj_mode,
                                   self.tm,
                                   self.cooperator,
                                   country=self.country,
                                   gj=self.gj,
                                   qh=self.qh,
                                   switchingmode=self.switchingmode,
                                   filtering_mode=self.filtering_mode,
                                   t=self.t,
                                   ip=self.ip).zc_pyq_t62()
                if mode == 'gw_zc_t62_1280':
                    newenvironment(uid=self.user[3],
                                   password=self.user[6],
                                   pid=self.user[9],
                                   deviceid=self.deviceid,
                                   port=self.port,
                                   o_username=self.user[17],
                                   o_password=self.user[20],
                                   wxmm=self.sjmm,
                                   phmode=self.f,
                                   wxmc=self.wxmc,
                                   phonenumber=phonenumber,
                                   gj_mode=self.gj_mode,
                                   tm=self.tm,
                                   cooperator=self.cooperator,
                                   country=self.country,
                                   gj=self.gj,
                                   qh=self.qh,
                                   switchingmode=self.switchingmode,
                                   filtering_mode=self.filtering_mode,
                                   t=self.t,
                                   ip=self.ip).gw_zc_t62_1280()
            except:
                logging.info(self.deviceid + u'-发现异常,重新注册')
                time.sleep(5)

    def zc(self):
        self.Registration_Mode('zc')

    def zcfpyq(self):
        self.Registration_Mode('zcfpyq')

    def zc_pyq_t62(self):
        self.Registration_Mode('zc_pyq_t62')

    def moments(self):
        try:
            self.breeding_Mode('moments')
        except:
            traceback.print_exc()
            logging.info(self.deviceid + u'-发现异常')

    def login(self):
        try:
            self.breeding_Mode('login')
        except:
            logging.info(self.deviceid + u'-登录异常')

    def addfriends(self):
        try:
            self.breeding_Mode('addfriends')
        except:
            traceback.print_exc()
            logging.info(self.deviceid + u'-发现异常,重新切换队列')

    def dlsys(self):
        try:
            self.breeding_Mode('dlsys')
        except:
            traceback.print_exc()
            logging.info(self.deviceid + u'-发现异常,重新切换队列')

    def delete(self):
        os.system('adb -s %s shell rm -rf/sdcard/Download/weiba/wx' %
                  (self.deviceid))
        logging.info(self.deviceid + u'-已删除')

    def gw_zc_t62_1280(self):
        self.Registration_Mode('gw_zc_t62_1280')

    def pull_sandbox_data(self):
        os.popen('adb -s %s pull sdcard/boxbackup/ package/%s/%s/' %
                 (self.deviceid, self.deviceid,
                  datetime.datetime.now().strftime('%Y%m%d')))

    def cloudCode_Recover(self):
        try:
            culture_list = self.wb_mode_Verification()
            accounts = json.loads(WB(self.deviceid).get_accounts())['data']
            with open('云码恢复列表.txt'.decode('utf-8'), 'a') as f:
                for i in range(0, culture_list.__len__()):
                    #取到手机号码
                    self.ph = re.findall('([0-9]{11})', culture_list[i])[0]
                    self.mm = re.findall('_(.*?) ', culture_list[i])[0]
                    self.t = re.findall('([0-9]{4}-[0-9]{2}-[0-9]{2})',
                                        culture_list[i])[0]
                    self.wxid = re.findall('wxid_(.*)22  ', culture_list[i])[0]
                    for account in accounts:
                        if self.wxid in account['strWxUUID']:
                            logging.info(self.deviceid + u'-对比结果:' + self.ph +
                                         u'存在,提取云码')
                            f.write('%s_%s  %s  %s  %s  %s|\n' %
                                    (self.ph, self.mm, self.deviceid, self.t,
                                     account['strWxUUID'], account['strCode']))
            time.sleep(10000)
        except:
            pass
 def sandbox_login(self, ph, mm):
     with open('跳辅设置.txt'.decode('utf-8'), 'r')as f:
         mode = json.loads(f.read())['transmission_mode']
     os.popen('adb -s %s shell rm -rf /sdcard/boxbackup' % self.deviceid)
     os.popen('adb -s %s shell mkdir /sdcard/boxbackup' % self.deviceid)
     fsize = int(
         round(os.path.getsize('package/%s/%s' % (self.deviceid, self.cloudCode)) / float(1024 * 1024), 2)) - 2
     with open('沙盒账密配置.json'.decode('utf-8'), 'r') as f:
         a = json.loads(f.read())
     for i in a:
         if self.deviceid == i['deviceid']:
             username = i['username']
             password = i['password']
     if mode == 'ftp':
         with open('server_config.txt', 'r') as f:
             data = json.loads(f.read())
         time.sleep(2)
         os.popen('start adb -s %s shell curl ftp://%s/package/%s/%s -o /sdcard/boxbackup/%s'%(self.deviceid,data['host'],self.deviceid,self.cloudCode,self.cloudCode))
     if mode == 'adb':
         os.popen('start adb -s %s push package/%s/%s /sdcard/boxbackup/%s' %(self.deviceid,self.deviceid,self.cloudCode,self.cloudCode))
     time.sleep(2)
     while True:
         time.sleep(3)
         try:
             sj_fsize = re.findall('([0-9]{1,3})M', os.popen('adb -s %s shell ls -lh sdcard/boxbackup/%s'%(self.deviceid,self.cloudCode)).read())[0]
             logging.info(u'%s-正在检查文件传输状态,请稍等' % self.deviceid)
             if int(sj_fsize) > int(fsize):
                 logging.info(u'%s-文件传输完毕'% self.deviceid)
                 break
         except:
             pass
     self.driver = Open().Phone('com.dobe.sandbox', '.home.Main2Activity', self.deviceid, self.port)
     self.driver.implicitly_wait(60)
     self.driver.find_element_by_id('com.dobe.sandbox:id/download_icon').click()
     wz = self.driver.find_element_by_id('com.dobe.sandbox:id/textView').get_attribute(('text'))
     while True:
         if wz.encode('utf-8') == '尚未登陆,点击登陆':
             self.driver.find_element_by_name('尚未登陆,点击登陆').click()
             self.driver.find_element_by_id('com.dobe.sandbox:id/editText').send_keys(username)
             self.driver.find_element_by_id('com.dobe.sandbox:id/editText2').send_keys(password)
             self.driver.keyevent('66')
             time.sleep(1)
             self.driver.find_element_by_name('点击登陆').click()
             if self.driver.find_elements_by_id('com.dobe.sandbox:id/download_icon') != []:
                 break
         else:
             self.driver.keyevent('4')
             break
     self.driver.find_element_by_id('com.dobe.sandbox:id/context_menu').click()
     self.driver.find_element_by_name('清除APP数据').click()
     self.driver.find_element_by_name('确认删除').click()
     time.sleep(5)
     self.driver.find_element_by_id('com.dobe.sandbox:id/download_device').click()
     self.driver.find_element_by_name('备份恢复').click()
     while True:
         if self.driver.find_elements_by_id('com.dobe.sandbox:id/backup_info') != []:
             self.driver.find_element_by_id('com.dobe.sandbox:id/backup_info').click()
             self.driver.find_element_by_name('确定').click()
             break
     time.sleep(10)
     os.popen('adb -s %s shell am force-stop com.dobe.sandbox' % self.deviceid)
     time.sleep(3)
     os.popen('adb -s %s shell am start -n com.dobe.sandbox/.home.Main2Activity' % self.deviceid)
     if self.driver.find_elements_by_id('com.dobe.sandbox:id/context_menu') != []:
         self.driver.find_element_by_id('com.dobe.sandbox:id/appIcon').click()
     return ph,mm
예제 #20
0
 def sand_box(self):
     os.popen('adb -s %s shell rm -rf /sdcard/boxbackup' % self.deviceid)
     with open('沙盒账密配置.json'.decode('utf-8'), 'r') as f:
         a = json.loads(f.read())
     for i in a:
         if self.deviceid == i['deviceid']:
             username = i['username']
             password = i['password']
     os.popen('adb -s %s shell am force-stop com.dobe.sandbox' % self.deviceid)
     self.driver = Open().Phone('com.dobe.sandbox', '.home.Main2Activity', self.deviceid, self.port)
     self.driver.implicitly_wait(50)
     size = self.driver.get_window_size()
     self.wb = int(size.values()[0]) / 1080
     self.hb = int(size.values()[1]) / 1920
     self.driver.find_element_by_id('com.dobe.sandbox:id/download_icon').click()
     wz = self.driver.find_element_by_id('com.dobe.sandbox:id/textView').get_attribute(('text'))
     while True:
         if wz.encode('utf-8') == '尚未登陆,点击登陆':
             self.driver.find_element_by_name('尚未登陆,点击登陆').click()
             self.driver.find_element_by_id('com.dobe.sandbox:id/editText').send_keys(username)
             self.driver.find_element_by_id('com.dobe.sandbox:id/editText2').send_keys(password)
             self.driver.keyevent('66')
             time.sleep(1)
             self.driver.find_element_by_name('点击登陆').click()
             if self.driver.find_elements_by_id('com.dobe.sandbox:id/download_icon') != []:
                 break
         else:
             self.driver.keyevent('4')
             break
     self.driver.find_element_by_id('com.dobe.sandbox:id/context_menu').click()
     self.driver.find_element_by_name('清除APP数据').click()
     self.driver.find_element_by_name('确认删除').click()
     time.sleep(5)
     self.driver.find_element_by_id('com.dobe.sandbox:id/download_device').click()
     self.driver.find_element_by_name('修改设备').click()
     self.driver.find_element_by_name('修改机型').click()
     b = 0
     self.driver.implicitly_wait(2)
     while True:
         if self.driver.find_elements_by_class_name('android.widget.TextView') != []:
             list = self.driver.find_elements_by_class_name('android.widget.TextView')
             if list.__len__() > 5:
                 self.IMEI = re.findall('IMEI: (.*)', list[2].get_attribute(("text")))[0]
                 logging.info('%s-IMEI:%s' % (self.deviceid,self.IMEI))
                 self.MAC = re.findall('MAC: (.*)', list[5].get_attribute(("text")))[0]
                 logging.info('%s-MAC:%s' % (self.deviceid, self.MAC))
                 self.Brand = re.findall('BRAND: (.*)', list[6].get_attribute(("text")))[0]
                 logging.info('%s-BRAND:%s' % (self.deviceid, self.Brand))
                 self.driver.keyevent(4)
                 time.sleep(1)
                 self.driver.keyevent(4)
                 time.sleep(2)
                 self.driver.find_element_by_id('com.dobe.sandbox:id/appIcon').click()
                 break
             else:
                 if 30 == b:
                     self.driver.quit()
                     break
                 else:
                     b = b + 1
                     time.sleep(2)
예제 #21
0
class mode():
    # 账号注册
    def __init__(self, deviceid, port, wxmm, switchingmode ,phmode,t ,gj_mode,cooperator,country,gj,qh,login_mode,privince,filtering_mode):
        self.user = file().readuser()
        self.deviceid = deviceid
        self.wxmm = wxmm
        self.port = port
        self.switchingmode = switchingmode
        self.fm=flightmode(deviceid, port)
        self.v = vpn(self.deviceid,port)
        self.phmode = PhoneNumber(self.user[3], self.user[6], self.user[9] , self.deviceid , phmode,qh)
        self.f = phmode
        self.t = t
        self.gj_mode = gj_mode
        self.cooperator = cooperator
        self.country = country
        self.gj = gj
        self.qh = qh
        self.login_mode = login_mode
        self.privince=privince
        self.wj = wj(deviceid, port)
        self.filtering_mode = filtering_mode


    def connectbot(self):
            os.system('adb -s ' + self.deviceid + ' shell am force-stop org.connectbot')
            driver = Open().Phone('org.connectbot', '.HostListActivity', self.deviceid, self.port)
            driver.implicitly_wait(180)
            driver.find_elements_by_id('android:id/icon')[0].click()
            driver.implicitly_wait(2)
            while True:
                if driver.find_elements_by_id('org.connectbot:id/console_prompt_yes') != []:
                    driver.find_element_by_id('org.connectbot:id/console_prompt_yes').click()
                    driver.find_element_by_id('android:id/content').click()
                if driver.find_elements_by_id('org.connectbot:id/console_password') != []:
                    driver.find_element_by_id('org.connectbot:id/console_password').send_keys('kk123')
                    driver.keyevent(66)
                    time.sleep(1)
                    driver.keyevent(66)
                    break
            time.sleep(3)

    def proxy(self):
        try:
            os.popen('adb -s %s shell kill -9 %s' % (self.deviceid,os.popen('adb -s %s shell "ps|grep org.proxydroid"'%self.deviceid).read().split()[1]))
        except:
            pass
        os.system('adb -s ' + self.deviceid + ' shell am force-stop org.proxydroid')
        self.driver = Open().Phone('org.proxydroid', '.ProxyDroid', self.deviceid, self.port)
        self.driver.implicitly_wait(180)
        self.driver.find_element_by_id('android:id/switch_widget').click()
        time.sleep(10)
        logging.info(self.deviceid+u'-Proxy成功连接')

    def pd_ip(self, m):
        if self.switchingmode == '1.飞行模式'.decode("utf-8"):
            return self.fm.flightmode(m,self.t,self.filtering_mode)
        if self.switchingmode == '2.VPN'.decode("utf-8"):
            return self.v.newvpn(m,self.t,self.filtering_mode)
        if self.switchingmode == '3.不换IP'.decode("utf-8"):
            self.ip =  os.popen('adb -s %s shell curl "http://ip.cip.cc'%self.deviceid).read()[0]
            return self.ip
        if self.switchingmode == '4.私人VPN'.decode('utf-8'):
            return self.wj.start(m,self.t,self.filtering_mode)
        if self.switchingmode == '5.私人VPN2'.decode('utf-8'):
            os.system('adb -s ' + self.deviceid + ' shell am force-stop com.tencent.mm')
            ip = vps(self.deviceid).switching_VPS(m, self.filtering_mode)
            logging.info(self.deviceid+u'-服务器IP地址:%s'%ip)
            while True:
                try:
                    sj_ip = os.popen('adb -s ' + self.deviceid + ' shell curl --connect-timeout 100 ip.cip.cc').read().strip('\n')
                    logging.info(self.deviceid + u'-手机IP地址:%s' % sj_ip)
                    if ip in sj_ip:
                        return ip
                    else:
                        logging.info(self.deviceid + u'-手机IP跟服务器IP不一致')
                        self.connectbot()
                        self.proxy()
                except:
                    self.connectbot()
                    self.proxy()

    def wechat_list_Verification(self,culture_list):
        if culture_list == []:
            while True:
                logging.info(self.deviceid + u'-养号列表不存在该设备号数据')
                time.sleep(12)

    def run_mode(self):
        ye = str(token().get_balance(TokenYZ.gettoken()))
        return 'tm'+ye[-1]

    def get_wechatdata(self,culture_list):
        ph = re.findall('([0-9]{1,100})_', culture_list)[0]
        logging.info(self.deviceid + u'-获取到手机号码:' + ph)
        mm = re.findall('_(.*?) ', culture_list)[0]
        logging.info(self.deviceid + u'-获取到登录密码:' + mm)
        try:
            self.device_token = re.findall('dd_cloud:(.*)',culture_list)[0]
            logging.info(self.deviceid + u'-获取到多多云码:' + self.device_token)
        except:self.device_token = 'test'
        try:
            for i in culture_list.split():
                if 'ID' in i:
                    self.hy = i[3:]
            logging.info(self.deviceid + u'-获取到好友ID:' + self.hy)
        except:self.hy = 'test'
        try:
            self.wxid ='wxid_'+re.findall('wxid_(.*)22  ', culture_list)[0]+'22'
            logging.info(self.deviceid + u'-获取WXID:' + self.wxid)
        except:
            logging.info(self.deviceid + u'-未获取到WXID')
            self.wxid = 'test'
        try:
            for i in culture_list.split():
                if 'zip' in i:
                    self.cloudCode = i[:-1]
            logging.info(self.deviceid + u'-获取环境包:%s'%self.cloudCode)
        except:
            logging.info(self.deviceid + u'-未获取环境包')
            self.cloudCode = 'test'
        try:
            self.ip = re.findall('  ([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})  ', culture_list)[0]
            logging.info(self.deviceid + u'-获取到注册IP:' + self.ip)
        except:
            logging.info(self.deviceid + u'-未获取到注册IP')
            self.ip = 'test'
        try:
            self.date = re.findall('([0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2})', culture_list)[0]
            logging.info(self.deviceid + u'-获取到注册日期:' + self.date)
        except:
            logging.info(self.deviceid + u'-未获取到注册日期')
            self.date = 'test'
        return ph,mm,self.device_token,self.hy,self.wxid,self.cloudCode,self.ip,self.date

    def Judgment_Devices(self):
        while True:
            if os.system('adb -s %s shell cd /sdcard' % self.deviceid) != 0:
                logging.info(u'%s未检测到手机连接'%self.deviceid)
                time.sleep(5)
            else:
                break
                #raise Exception, "%s-未连接到手机" % self.deviceid

    def random_password_Verification(self):
        if self.wxmm == '请输入注册密码'.decode("utf-8"):
            #while True:
            #    keylist = ''.join([random.choice(string.digits + string.ascii_lowercase) for i in range(6)])+str(random.randint(0, 9))+'a'
            #    if 'l' not in keylist:
            #        if '9' in keylist:
            #            break
            #self.sjmm = keylist
            self.sjmm = 'a'+''.join([random.choice(string.digits) for i in range(7)])
            return self.sjmm
        else:
            self.sjmm = self.wxmm
            return self.sjmm

    #从养号列表获取第一条数据到微信账号数据列表去找这条数据
    def wb_mode_Verification(self):
        support_file_name = '养号列表.txt'
        support_Data = file.read(support_file_name)
        error_file_name = '登录异常账号.txt'
        error_Data_List = file.read_all(error_file_name)
        wechat_file_name = '微信账号数据.txt'
        wechat_Data_List = file.read(wechat_file_name)
        num = []
        new_data_list = []
        for data in wechat_Data_List:
            if self.deviceid in data:
                new_data_list.append(data)
        for support in support_Data:
            if 'True' not in support.strip('\n'):
                if re.findall('(.*)\|', support)[0] not in error_Data_List:
                    try:
                        for self.wechat_Data in new_data_list:
                            if re.findall('(.*)\|', support)[0] in self.wechat_Data:
                                num.append('%s ID:%s' % (self.wechat_Data.strip('\n'), re.findall('\|(.*)', support)[0]))
                    except:
                        logging.info(self.deviceid+u'-正则没有匹配到该条数据:'+self.wechat_Data)
        if num.__len__() <> 0:
            logging.info(self.deviceid + u'设备找到%s个数据' % num.__len__())
            return num
        else:
            logging.info(self.deviceid + u'该设备在养号列表中没有数据')
            time.sleep(10000)

    def breeding_Mode(self, mode):
        culture_list = self.wb_mode_Verification()
        for culture in culture_list:
            self.pd_ip('2')
            wechat_list = self.get_wechatdata(culture)
            if mode == 'moments':
                login_wechat(deviceid=self.deviceid, port=self.port,country=None, gj_mode=self.gj_mode, wxid=wechat_list[4],
                             login_mode=self.login_mode, cloudCode=wechat_list[5],ip=wechat_list[6],date=wechat_list[7]).fpyq(ph=wechat_list[0],mm=wechat_list[1],device_token=wechat_list[2])
            if mode == 'login':
                login_wechat(deviceid=self.deviceid, port=self.port, country=None,gj_mode=self.gj_mode, wxid=wechat_list[4],
                             login_mode=self.login_mode, cloudCode=wechat_list[5],ip=wechat_list[6],date=wechat_list[7]).wechat_signout(ph=wechat_list[0],mm=wechat_list[1],device_token=wechat_list[2])
            if mode == 'addfriends':
                login_wechat(deviceid=self.deviceid, port=self.port, country=None,gj_mode=self.gj_mode, wxid=wechat_list[4],login_mode=self.login_mode, cloudCode=wechat_list[5],ip=wechat_list[6],date=wechat_list[7]).smjhy(ph=wechat_list[0],mm=wechat_list[1],device_token=wechat_list[2], hy=wechat_list[3])


    #注册模式
    def Registration_Mode(self,mode):
        with open('跳辅设置.txt'.decode('utf-8'), 'r') as f:
            self.tm = json.loads(f.read())['runmode']
        while True:
            try:
                self.Judgment_Devices()
                phonenumber = self.phmode.all_getph()
                self.ip = self.pd_ip('1')
                if self.country == '2.国外'.decode("utf-8"):
                    self.wxmc = file().readwxmc().decode("gb2312").strip('\n')
                if self.country == '1.国内'.decode("utf-8"):
                    #self.wxmc = file().readwxmc().strip('\n')
                    self.wxmc = ''.join([random.choice(string.digits) for i in range(8)])
                    #self.wxmc = file().readwxmc().decode("gb2312").strip('\n')
                self.sjmm = self.random_password_Verification()
                if mode == 'zc':
                    newenvironment(self.user[3], self.user[6], self.user[9], self.deviceid, self.port, self.user[17],self.user[20], self.sjmm, self.f, self.wxmc.strip('\n'), phonenumber, self.gj_mode,self.tm, self.cooperator, country=self.country, gj=self.gj, qh=self.qh,switchingmode=self.switchingmode,filtering_mode=self.filtering_mode,t=self.t,ip=self.ip).new_zh()
                if mode == 'zcfpyq':
                    newenvironment(self.user[3], self.user[6], self.user[9], self.deviceid, self.port, self.user[17],
                                   self.user[20], self.sjmm, self.f, self.wxmc.strip('\n'), phonenumber, self.gj_mode,self.tm, self.cooperator, country=self.country, gj=self.gj, qh=self.qh,switchingmode=self.switchingmode,filtering_mode=self.filtering_mode,t=self.t,ip=self.ip).new_zhpyq()
                if mode == 'zc_pyq_t62':
                    newenvironment(self.user[3], self.user[6], self.user[9], self.deviceid, self.port, self.user[17],self.user[20], self.sjmm, self.f, self.wxmc.strip('\n'), phonenumber, self.gj_mode,self.tm, self.cooperator, country=self.country, gj=self.gj, qh=self.qh,switchingmode=self.switchingmode,filtering_mode=self.filtering_mode,t=self.t,ip=self.ip).zc_pyq_t62()
                if mode == 'gw_zc_t62_1280':
                    newenvironment(uid=self.user[3], password=self.user[6], pid=self.user[9], deviceid=self.deviceid,port=self.port, o_username=self.user[17], o_password=self.user[20], wxmm=self.sjmm,phmode=self.f, wxmc=self.wxmc, phonenumber=phonenumber, gj_mode=self.gj_mode,tm=self.tm, cooperator=self.cooperator, country=self.country, gj=self.gj, qh=self.qh,switchingmode=self.switchingmode,filtering_mode=self.filtering_mode,t=self.t,ip=self.ip).gw_zc_t62_1280()
            except:
                logging.info(self.deviceid + u'-发现异常,重新注册')
                time.sleep(5)

    def zc(self):
        self.Registration_Mode('zc')

    def zcfpyq(self):
        self.Registration_Mode('zcfpyq')

    def zc_pyq_t62(self):
        self.Registration_Mode('zc_pyq_t62')

    def moments(self):
        try:
            self.breeding_Mode('moments')
        except :
            traceback.print_exc()
            logging.info(self.deviceid+u'-发现异常')

    def login(self):
        try:
            self.breeding_Mode('login')
        except:
            logging.info(self.deviceid + u'-登录异常')

    def addfriends(self):
        try:
            self.breeding_Mode('addfriends')
        except:
            traceback.print_exc()
            logging.info(self.deviceid+u'-发现异常,重新切换队列')

    def dlsys(self):
        try:
            self.breeding_Mode('dlsys')
        except:
            traceback.print_exc()
            logging.info(self.deviceid+u'-发现异常,重新切换队列')

    def delete(self):
        os.system('adb -s %s shell rm -rf/sdcard/Download/weiba/wx' % (self.deviceid))
        logging.info(self.deviceid + u'-已删除')

    def gw_zc_t62_1280(self):
        self.Registration_Mode('gw_zc_t62_1280')

    def pull_sandbox_data(self):
       os.popen('adb -s %s pull sdcard/boxbackup/ package/%s/%s/' % (self.deviceid, self.deviceid,datetime.datetime.now().strftime('%Y%m%d')))

    def cloudCode_Recover(self):
            try:
                culture_list = self.wb_mode_Verification()
                accounts =json.loads(WB(self.deviceid).get_accounts())['data']
                with open('云码恢复列表.txt'.decode('utf-8'),'a') as f:
                    for i in range(0, culture_list.__len__()):
                        #取到手机号码
                        self.ph=re.findall('([0-9]{11})', culture_list[i])[0]
                        self.mm = re.findall('_(.*?) ', culture_list[i])[0]
                        self.t = re.findall('([0-9]{4}-[0-9]{2}-[0-9]{2})', culture_list[i])[0]
                        self.wxid = re.findall('wxid_(.*)22  ', culture_list[i])[0]
                        for account in accounts:
                            if self.wxid in account['strWxUUID']:
                                logging.info(self.deviceid + u'-对比结果:' + self.ph + u'存在,提取云码')
                                f.write('%s_%s  %s  %s  %s  %s|\n' % (self.ph, self.mm, self.deviceid, self.t, account['strWxUUID'], account['strCode']))
                time.sleep(10000)
            except:pass