Facebook
From sfdg, 3 Years ago, written in Plain Text.
This paste is a reply to sfdg from sfdg - view diff
Embed
Download Paste or View Raw
Hits: 196
  1. import socket
  2. import requests
  3. from time import sleep
  4. import traceback
  5. from sshtunnel import SSHTunnelForwarder, create_logger
  6. from _thread import start_new_thread
  7. endpoint = "13.233.109.178"
  8. endpoint2 = "13.127.237.215"
  9. while True:
  10.     try:
  11.         limited = 0
  12.         ok = []
  13.         print ("Getting data from endpoint...")
  14.         req = requests.get(f"http://{endpoint}/dynuip.php?proxy_host=mybalancer.mywire.org",headers={'Cache-Control': 'no-cache'}, timeout=150).json()
  15.         print ("resived. checking ipis...")
  16.         ip_list = []
  17.         for proxy in req:
  18.             ip_list.append(proxy)
  19.         ip_list = list(set(ip_list))
  20.        # ip_list.remove('13.232.95.86')
  21.         print(len(ip_list))
  22.         for ip_addr in ip_list:
  23.             if True:
  24.                 success = False
  25.                 server = SSHTunnelForwarder(
  26.                     (ip_addr,2222),
  27.                     ssh_username="centos",
  28.                     ssh_password="Fatem100",
  29.                     remote_bind_address=('127.0.0.1', 5820),
  30.                     local_bind_address=('127.0.0.1', 5819),
  31.                     logger=create_logger(loglevel=1)
  32.                 )
  33.                 z = 0
  34.                 while z <3:
  35.                     z = z + 1
  36.                     def run():
  37.                         global success
  38.                         server.start()
  39.                         success = True
  40.                         print(success)
  41.                     start_new_thread(run, ())
  42.                     x = 0
  43.                     while x < 22:
  44.                         if success:
  45.                             print("Ip is ok ",ip_addr)
  46.                             ok.append(ip_addr)
  47.                             server.close()
  48.                             break
  49.                         else:
  50.                             print(success)
  51.                             sleep(0.25)
  52.                             x += 1
  53.                         if x == 22:
  54.                             server.close()
  55.                             break
  56.                     if success:
  57.                         break
  58.                     elif z == 3:
  59.                         requests.get(f"http://{endpoint}/blocked.php?proxy_host=mybalancer.mywire.org&filtered_ip={ip_addr}",headers={'Cache-Control': 'no-cache'}, timeout=150)
  60.                         #requests.get(f"http://{endpoint2}/blocked.php?proxy_host={proxy['host']}&filtered_ip={ip_addr}",headers={'Cache-Control': 'no-cache'})
  61.                         limited = limited + 1
  62.                         print("limited ",ip_addr)
  63.         requests.get(f"http://{endpoint}/all_{len(ip_list)}_ok_{len(ok)}_limited_{limited}_Asiatech",headers={'Cache-Control': 'no-cache'}, timeout=150)
  64.         print("All : ",len(ip_list)," OK : ",len(ok)," Limited : ",limited)
  65.         limited2 = 0
  66.         ok2 = []
  67.         req2 = requests.get(f"http://{endpoint2}/dynuip.php?proxy_host=mybalancer.mywire.org",headers={'Cache-Control': 'no-cache'}, timeout=150).json()
  68.         ip_list2 = []
  69.         for proxy2 in req2:
  70.             ip_list2.append(proxy2)
  71.         ip_list2 = list(set(ip_list2))
  72.         print(len(ip_list2))
  73.         for ip_addr in ip_list2:
  74.             if True:
  75.                 server.close()
  76.                 success = False
  77.                 server = SSHTunnelForwarder(
  78.                     (ip_addr,2222),
  79.                     ssh_username="centos",
  80.                     ssh_password="Fatem100",
  81.                     remote_bind_address=('127.0.0.1', 8820),
  82.                     local_bind_address=('127.0.0.1', 8821),
  83.                     logger=create_logger(loglevel=1)
  84.                 )
  85.                 z = 0
  86.                 while z <3:
  87.                     z = z + 1
  88.                     def run():
  89.                         global success
  90.                         server.start()
  91.                         success = True
  92.                         print(success)
  93.                     start_new_thread(run, ())
  94.                     x = 0
  95.                     while x < 12:
  96.                         if success:
  97.                             print("Ip is ok ",ip_addr)
  98.                             ok2.append(ip_addr)
  99.                             server.close()
  100.                             break
  101.                         else:
  102.                             print(success)
  103.                             sleep(0.25)
  104.                             x += 1
  105.                         if x == 12:
  106.                             server.close()
  107.                             break
  108.                     if success:
  109.                         break
  110.                     elif z == 3:
  111.                         requests.get(f"http://{endpoint2}/blocked.php?proxy_host=mybalancer.mywire.org&filtered_ip={ip_addr}",headers={'Cache-Control': 'no-cache'}, timeout=150)
  112.                         #requests.get(f"http://{endpoint2}/blocked.php?proxy_host={proxy['host']}&filtered_ip={ip_addr}",headers={'Cache-Control': 'no-cache'})
  113.                         limited2 = limited2 + 1
  114.                         print("limited ",ip_addr)
  115.                
  116.         print("All : ",len(ip_list2)," OK : ",len(ok2)," Limited : ",limited2)
  117.         requests.get(f"http://{endpoint2}/all_{len(ip_list2)}_ok_{len(ok2)}_limited_{limited2}_Asiatech",headers={'Cache-Control': 'no-cache'})
  118.        # listf = json.dumps(ok)
  119.         #requests.get(f"http://{endpoint}/ipdns.php?iplist={listf}",headers={'Cache-Control': 'no-cache'})
  120.         #requests.get(f"http://{endpoint}/ipdns.php", data={'id_list': ['x', 'y', 'z']})
  121.     except:
  122.         traceback.print_exc()
  123.         print("Retrying in 10 seconds...")
  124.         sleep(3)
  125.         continue
  126.     if limited == 0:
  127.         print("Check is done. Sleeping for 20 seconds")
  128.         sleep(20)
  129.     else:
  130.         print("Check is done. Sleeping for 0 sec")
  131.         sleep(0.2)
  132.