Advertisement
Guest User

Untitled

a guest
May 27th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. import socket, re, time
  2.  
  3. def login_tw():
  4.   user = "";
  5.   passw = "";
  6.   data = "user="+user+"&clear=true&password="+passw+"&server=en50"
  7.   query = "POST /index.php?action=login&server_en50 HTTP/1.1\r\n"
  8.   query = query + "Host: tribalwars.net\r\n"
  9.   query = query + "User-Agent: Mozilla/5.0\r\n"
  10.   query = query + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
  11.   query = query + "Accept-Language: en-us;en;q=0.5\r\n"
  12.   query = query + "Accept-Encoding: gzip, deflate\r\n"
  13.   query = query + "Keep-Alive: 115\r\n"
  14.   query = query + "Connection: keep-alive\r\n"
  15.   query = query + "Content-Type: application/x-www-form-urlencoded\r\n"
  16.   query = query + "Content-Length: "+str(len(data))+"\r\n\r\n"
  17.   query = query + data+"\r\n\r\n"
  18.   site = "tribalwars.net"
  19.   host = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  20.   host.connect((site, 80))
  21.   host.send(query)
  22.   data = host.recv(1024)
  23.   return data
  24. def write_file(data):
  25.   print data
  26.   file = open("session_id.txt","w")
  27.   get_info = re.search("Location: (.*)", data)
  28.  
  29.   if get_info:
  30.    
  31.    file.write(get_info.group(1).strip())
  32.  
  33. write_file(login_tw())
  34. sleep_delay = 3600
  35. while 1:
  36.   write_file(login_tw())
  37.   time.sleep(sleep_delay)
  38.  
  39. -----------------------
  40.  
  41.  
  42. <?php
  43.     // phpinfo();
  44.    
  45.     $file = "C:\Python26\session_id.txt";
  46.     $read_data = fopen($file,"r");
  47.     while(!feof($read_data))
  48.         {
  49.             $content = fread($read_data, 128);
  50.         }
  51.     $ch = curl_init();
  52.     curl_setopt($ch, CURLOPT_URL, $content);
  53.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  54.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  55.     curl_setopt($ch, CURLOPT_COOKIEJAR, "C:\Python26\cookie_id.txt");
  56.     curl_setopt($ch, CURLOPT_COOKIEFILE, "C:\Python26\cookie_id.txt");
  57.     $result = curl_exec($ch);
  58.     curl_close($ch);
  59.     echo $result;
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement