Esempio n. 1
0
def connect_vpn(conn, vpn):
    sql = "SELECT account, pwd, server, ip from vpn where account='%s'" % vpn
    results = read_all_sql(conn, sql)
    if results:
        for row in results:
            vpn = row['account']
            vpn_pwd = row['pwd']
            vpn_ip = row['ip']
            vpn_server = row['server'].replace('.lianstone.net', '')
            with open("D:\\work\\pin_login_system\\boot\\vpn.txt", "w", encoding='utf-8') as fp:
                print(vpn_server + "," + vpn + "," + vpn_pwd)
                fp.write(vpn_server + "," + vpn + "," + vpn_pwd)
    else:
        print(
            'No corresponding VPN account has been detected and the system is being shut down...')
        time.sleep(600)
        os.system('Shutdown -s -t 0')
    print('Disconnect the original VPN connection')
    rasphone_vpn()
    write_txt_time()
    print('Handling new VPN...')
    check_vpn_num = check_vpn()
    net_ip = get_out_ip()
    write_txt_time()
    while True:
        if net_ip == vpn_ip:
            print('VPN connection IP is correct!')
            break
        else:
            check_vpn_num = check_vpn()
            write_txt_time()
            time.sleep(10)
            net_ip = get_out_ip()
Esempio n. 2
0
 def get_account(self):
     lock_computer = self.hostname[:6]
     sql = 'SELECT count(1) from account where action_time="%s" and belong="%s"' % (
         self.current_time, lock_computer)
     operated_account = read_one_sql(self.conn, sql)['count(1)']
     sql = 'SELECT count(1) from account where state=1 and action_time<"%s" and belong="%s"' % (
         self.current_time, lock_computer)
     inactive_account = read_one_sql(self.conn, sql)['count(1)']
     print('Operated account: ', operated_account, ';'
           'Inactive account: ', inactive_account)
     sql = 'SELECT * from account where priority>0 and belong="%s"' % lock_computer
     self.priority_result = read_all_sql(self.conn, sql)
     if self.priority_result:
         sql = 'SELECT * from account where priority=1 and action_computer="%s"' % self.hostname
     else:
         sql = "SELECT * from account where action_computer='%s' and action_time<'%s' and state=1 and login_times<4 order by action_time asc limit 1" % (
             self.hostname, self.current_time)
     result = read_one_sql(self.conn, sql)
     if result:
         self.account_id = result["id"]
         self.email = result["email"]
         self.pwd = result["pw"]
         self.vpn = result['vpn']
         self.cookie = result['cookie']
         self.domain = result['domain']
         self.agent = result['agent']
         if not self.agent:
             sql = 'SELECT * from user_agent where terminal="computer" and read_time<4 order by RAND() limit 1'
             agent_in_sql = read_one_sql(self.conn, sql)
             if agent_in_sql:
                 self.agent = agent_in_sql['user_agent']
                 agent_id = agent_in_sql['Id']
                 sql = 'UPDATE account set agent="%s" where id=%s' % (
                     self.agent, self.account_id)
                 write_sql(self.conn, sql)
                 sql = 'UPDATE user_agent set read_time=read_time+1 where id=%s' % agent_id
                 write_sql(self.conn, sql)
         print("Start account processing:", "ID:", self.account_id,
               "Email:", self.email, "password", self.pwd)
     else:
         print('Not Data!')
         time.sleep(3)
Esempio n. 3
0
 def follow(self):
     print('Turn on the follow function, count:', self.follow_num)
     sql = '''SELECT * from follow_url order by RAND() limit %s''' % self.follow_num
     results = read_all_sql(self.conn, sql)
     if results:
         for res in results:
             home_url = res['home_url']
             try:
                 self.driver.get(home_url)
             except:
                 pass
             time.sleep(5)
             try:
                 follow_state = self.driver.find_element_by_xpath(
                     '//div[@class="fixedHeader"]//div[3]//div[2]/button/div'
                 ).text
                 if follow_state == 'Follow':
                     self.driver.find_element_by_xpath(
                         '//div[@class="fixedHeader"]//div[3]//div[2]/button'
                     ).click()
                     time.sleep(1)
                     self.driver.execute_script('window.scrollTo(1, 4000)')
                     time.sleep(3)
             except:
                 pass
             try:
                 follow_state = self.driver.find_element_by_xpath(
                     '//div[@class="CreatorFollowButton step0"]//div[2]/div'
                 ).text
                 if follow_state == 'Follow':
                     self.driver.find_element_by_xpath(
                         '//div[@class="CreatorFollowButton step0"]/div/div/div/div'
                     ).click()
                     time.sleep(1)
                     self.driver.execute_script('window.scrollTo(1, 4000)')
                     time.sleep(3)
             except:
                 pass
     write_txt_time()
Esempio n. 4
0
 def change_hardware(self):
     lock_computer = self.hostname[:6]
     sql = 'SELECT * from account where priority>0 and belong="%s"' % lock_computer
     self.priority_result = read_all_sql(self.conn, sql)
     if self.priority_result:
         sql = 'SELECT * from account where priority=1 and computer_state=0 and belong="%s" order by id limit 1' % lock_computer
     else:
         sql = "SELECT * from account where computer_state=0 and belong='%s' and action_time<'%s' and state=1 and login_times<4 order by action_time asc limit 1" % (
             lock_computer, self.current_time)
     next_account = read_one_sql(self.conn, sql)
     if next_account:
         account_id = next_account["id"]
         email = next_account["email"]
         pwd = next_account["pw"]
         vpn = next_account['vpn']
         cookie = next_account['cookie']
         print("Next account processing:", "ID:", account_id, "Email:",
               email)
         self.mac_adress = next_account['mac_adress']
         sql_hostname = next_account['action_computer']
         if self.mac_adress:
             with open('D:\\work\\pin_login_system\\nameandmac.txt',
                       'w') as fp:
                 fp.write(sql_hostname + ',' + self.mac_adress)
         sql = 'UPDATE account set computer_state=1 where id=%s' % account_id
         write_sql(self.conn, sql)
         time.sleep(6)
         p = subprocess.Popen(
             'D:\\work\\pin_login_system\\editor_mac_computername.bat',
             shell=False)
         p.wait()
         print('Is about to restart')
         time.sleep(10)
         os.system('shutdown -r -t 0')
         time.sleep(100)
     else:
         print('Not useable data!')
         time.sleep(3)
Esempio n. 5
0
 def click_specific_pin(self):
     print('Start searching for our company images')
     sql = "SELECT web_url from follow_url"
     results = read_all_sql(self.conn, sql)
     http_in_sql_list = []
     for res in results:
         http_in_sql = res['web_url']
         http_in_sql_list.append(http_in_sql)
     sql = "SELECT * from search_words where us=1 order by RAND() limit %s" % self.search_words_count
     key_wrods = read_all_sql(self.conn, sql)
     if key_wrods:
         pin_count = 0
         for key_wrod in key_wrods:
             search_key_words = key_wrod['word']
             board_name = key_wrod['boards']
             # belong = result['us']
             try:
                 self.driver.find_element_by_name('q').click()
                 time.sleep(1)
                 self.driver.find_element_by_name('q').clear()
                 time.sleep(1)
                 self.driver.find_element_by_name('q').send_keys(
                     search_key_words)
                 time.sleep(1)
                 win32api.keybd_event(13, 0, 0, 0)
                 win32api.keybd_event(13, 0, win32con.KEYEVENTF_KEYUP, 0)
             except:
                 pass
             try:
                 self.driver.find_element_by_name("searchBoxInput").click()
                 time.sleep(1)
                 self.driver.find_element_by_name("searchBoxInput").clear()
                 time.sleep(1)
                 self.driver.find_element_by_name(
                     "searchBoxInput").send_keys(search_key_words)
                 time.sleep(1)
                 win32api.keybd_event(13, 0, 0, 0)
                 win32api.keybd_event(13, 0, win32con.KEYEVENTF_KEYUP, 0)
             except:
                 pass
             time.sleep(8)
             for _ in range(self.scroll_num):
                 try:
                     web_pin_arr = self.driver.find_elements_by_xpath(
                         "//div[@data-grid-item='true']")
                     # print(len(web_pin_arr))
                 except:
                     time.sleep(3)
                     web_pin_arr = self.driver.find_elements_by_xpath(
                         "//div[@data-grid-item='true']")
                 for web_pin_one in web_pin_arr:
                     try:
                         ActionChains(self.driver).move_to_element(
                             web_pin_one).perform()
                         time.sleep(3)
                     except:
                         pass
                     try:
                         web_pin = self.driver.find_element_by_xpath(
                             "//a[@class='navigateLink']//div[2]/div")
                         time.sleep(2)
                         web_pin_url = web_pin.text
                         # print(web_pin_url)
                         if web_pin_url in http_in_sql_list:
                             time.sleep(1)
                             specific_pin_url = web_pin_one.find_element_by_xpath(
                                 './/div[@class="pinWrapper"]/div/a'
                             ).get_attribute('href')
                             time.sleep(1)
                             specific_pin_pic_url = web_pin_one.find_element_by_xpath(
                                 './/div[@class="pinWrapper"]//img'
                             ).get_attribute('src')
                             self.save_pic(
                                 board_name=board_name,
                                 belong=1,
                                 specific_pin_url=specific_pin_url,
                                 specific_pin_pic_url=specific_pin_pic_url)
                             pin_count += 1
                     except Exception as e:
                         pass
                     if pin_count == self.pin_self_count:
                         break
                 if pin_count == self.pin_self_count:
                     break
                 else:
                     win32api.keybd_event(35, 0, 0, 0)
                     win32api.keybd_event(35, 0, win32con.KEYEVENTF_KEYUP,
                                          0)
                     time.sleep(5)
                     write_txt_time()
             if pin_count == self.pin_self_count:
                 break