Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. <?php
  2.  
  3. $cookie="cookie.txt";
  4.  
  5. function open($url)
  6. {
  7. $ch = curl_init();
  8.  
  9. curl_setopt($ch, CURLOPT_URL,$url);
  10. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
  11. curl_setopt($ch, CURLOPT_HEADER, 0);
  12. curl_setopt($ch, CURLOPT_COOKIE, 1);
  13. curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie);
  14. curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie);
  15. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  17. curl_setopt ($ch, CURLOPT_REFERER, $url);
  18. $result = curl_exec($ch);
  19. curl_close($ch);
  20.  
  21. return $result;
  22. }
  23.  
  24. function between($string, $start, $end)
  25. {
  26. $out = explode($start, $string);
  27.  
  28. if(isset($out[1]))
  29. {
  30. $string = explode($end, $out[1]);
  31. echo $string[0];
  32. return $string[0];
  33. }
  34.  
  35. return '';
  36. }
  37.  
  38. function get_captcha()
  39. {
  40. $url = 'https://academics.vit.ac.in/student/stud_login.asp';
  41. $open = open($url);
  42. $code = between($open, '<img src='https://academics.vit.ac.in/student/captcha.asp', '">');
  43. return 'https://academics.vit.ac.in/student/captcha.asp' . $code;
  44.  
  45. }
  46.  
  47. function rahul()
  48. {
  49. $capth=htmlspecialchars($_POST['code']);
  50.  
  51. echo $capth;
  52.  
  53. $username="xyz";
  54. $password="abc";
  55. $url=url of the form in which you want to submit your data;
  56. $cookie="cookie.txt";
  57. $veri=$capth;
  58.  
  59. $com="Login";
  60.  
  61. $postdata = "regno=".$username."&passwd=".$password."&vrfcd=".$veri."&submit=".$com;
  62.  
  63. $ch = curl_init();
  64. curl_setopt ($ch, CURLOPT_URL, $url);
  65. curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  66. curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
  67. curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
  68. curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
  69. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  70. curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
  71. curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie); // <-- add this line
  72. curl_setopt ($ch, CURLOPT_REFERER, $url);
  73.  
  74. curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
  75. curl_setopt ($ch, CURLOPT_POST, 1);
  76. $result = curl_exec ($ch);
  77.  
  78. echo $result;
  79.  
  80. $data = curl_exec($ch);
  81. }
  82. ?>
  83.  
  84. <html>
  85. <body>
  86. <form action="" method="post">
  87. <img src="<?php echo get_captcha(); ?>" border="0" /><br />
  88. <input type="text" name="code" value="<?= isset($_POST['code']) ? htmlspecialchars($_POST['code']) : '' ?>" /><br />
  89. <input type="submit" name="submit" value="submit"/>
  90. </form>
  91.  
  92. <?php
  93. if(isset($_POST['submit'])) {
  94. rahul();
  95. }
  96. ?>
  97. </body>
  98. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement