Vnz


SUBMITTED BY: Guest

DATE: Feb. 20, 2015, 1:57 a.m.

FORMAT: PHP

SIZE: 6.1 kB

HITS: 879

  1. <?php
  2. $_C00KIES = "cookies.txt";
  3. $aVideos = array("http://www.youtube.com/watch?v=868NCW0jGrU");
  4. $aUsers = array();
  5. $aUsers[0] = array("somemail@gmail.com","password_here");
  6. //$aUsers[1] = array("somemail@gmail.com","password_here");
  7. for($x=0;$x<count($aVideos);$x++){
  8. for($y=0;$y<count($aUsers);$y++){
  9. if(file_exists($_C00KIES)){
  10. @unlink($_C00KIES);
  11. }
  12. $sYTLink = $aVideos[$x];
  13. $sUser = $aUsers[$y][0];
  14. $sPass = $aUsers[$y][1];
  15. if(false!==($iPos = strpos($sYTLink,"&"))){
  16. $sYTLink = substr($sYTLink,0,$iPos);
  17. }
  18. $aVID = explode("=",$sYTLink);
  19. if(!isset($aVID[1])){
  20. die("Invalid video");
  21. }
  22. $sVID = $aVID[1];
  23. // open gmail and get dynamic field values everytime we start a login attempt
  24. $ch = curl_init("https://accounts.google.com/ServiceLogin?continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_sign​in%3Dtrue%26feature%3Dsign_in_button%26hl%3Dnl_NL%26next%3D%252F%26nomobiletemp%​3D1&passive=true&service=youtube&uilel=3&hl=nl_NL");
  25. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  27. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  28. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  29. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  30. curl_setopt($ch, CURLOPT_COOKIEFILE, $_C00KIES);
  31. $sData = curl_exec($ch);
  32. // get login form
  33. $sPattern = "/<form(?=[^>]*novalidate id=\"gaia_loginform\")[^>].+<\/form>/Uis";
  34. preg_match($sPattern,$sData,$aData);
  35. if(isset($aData[0])){
  36. // get action
  37. $sPattern = "/action=\"([^\"]+)/is";
  38. preg_match($sPattern,$aData[0],$aTarget);
  39. $sTarget = $aTarget[1];
  40. // get all inputs
  41. $sPattern = "/<input[^>]+/is";
  42. preg_match_all($sPattern,$aData[0],$aInput);
  43. // go through the inputs and extract the vars and their values
  44. $sPost = "";
  45. for($y=0;$y<count($aInput[0]);$y++){
  46. if($y>0){
  47. $sPost .= "&";
  48. }
  49. // get var names
  50. $sPattern = "/name=\"([^\"]+)/is";
  51. preg_match($sPattern,$aInput[0][$y],$aVar);
  52. if(!isset($aVar[1])){
  53. // no name
  54. continue;
  55. }
  56. $sPost .= $aVar[1]."=";
  57. // add pass
  58. if($aVar[1]=="Passwd"){
  59. $sPost .= $sPass;
  60. continue;
  61. }
  62. // add email/user
  63. if($aVar[1]=="Email"){
  64. $sPost .= $sUser;
  65. continue;
  66. }
  67. // get values
  68. $sPattern = "/value=\"([^\"]+)/is";
  69. preg_match($sPattern,$aInput[0][$y],$aVal);
  70. if(!isset($aVal[1]) || empty($aVal[1])){
  71. // no value
  72. continue;
  73. }
  74. $sPost .= $aVal[1];
  75. }
  76. // in case we are skipping an input with no name
  77. $sPost = str_replace("&&","&",$sPost);
  78. curl_setopt($ch, CURLOPT_URL, $sTarget);
  79. curl_setopt($ch, CURLOPT_POST, true);
  80. curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
  81. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  82. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  83. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
  84. $sResponse = curl_exec($ch);
  85. // find the user style string if it is there, login was successful
  86. $iPos = strpos($sResponse,"refresh");
  87. if($iPos){
  88. // ok we have logged in, go to youtube and get the video
  89. curl_setopt($ch, CURLOPT_URL, $sYTLink);
  90. curl_setopt($ch, CURLOPT_POST, false);
  91. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  92. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  93. $sResponse = curl_exec($ch);
  94. preg_match('/\'PLAYBACK_ID\':\s+\"(.*)\"/',$sResponse,$aPID);
  95. preg_match('/yt\.setAjaxToken\(\'watch_actions_ajax\',\s+\"(.*)\"/',$sResponse,$aSessionToken);
  96. if(!isset($aPID[1])){
  97. echo"No playback id found";
  98. }
  99. elseif(!isset($aSessionToken[1])){
  100. echo"No session id found";
  101. }
  102. else{
  103. // like this video
  104. curl_setopt($ch, CURLOPT_URL, "http://www.youtube.com/watch_actions_ajax?action_like_video=1&video_id=".$sVID."&plid=".$aPID[1]);
  105. curl_setopt($ch, CURLOPT_POST, true);
  106. curl_setopt($ch, CURLOPT_POSTFIELDS, "session_token=".$aSessionToken[1]."&screen=".rawurlencode("h=800&w=1280&d=24"));
  107. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  108. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  109. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
  110. $sResponse = curl_exec($ch);
  111. curl_close($ch);
  112. //echo $sResponse;
  113. }
  114. }
  115. else{
  116. echo "Login failed";
  117. }
  118. }
  119. else{
  120. die("Unable to find login form, terminating script\n");
  121. }
  122. }
  123. }
  124. ?>

comments powered by Disqus