Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> [php][curl]wypełnianie formularza recaptcha
kavillock
post 10.03.2010, 22:13:48
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 25.09.2009

Ostrzeżenie: (0%)
-----


witam na początku fragment kodu
  1. $ok = urlencode('Zostań obywatelem');
  2. //pierwsze dane captcha
  3. if ($_POST['submit'] != 'submit'){
  4. //WYSWIETLANIE FORMULARZA
  5. curl_setopt($hand, CURLOPT_URL, 'http://api.recaptcha.net/noscript?k=6LfEGgIAAAAAABSqQ0rzMd3t-rOU_XrZlC2C9WG2');
  6. curl_setopt($hand, CURLOPT_RETURNTRANSFER, 1);
  7. curl_setopt($hand, CURLPROXY_HTTP, 'proxy');
  8. $p=curl_exec($hand);
  9. preg_match('/<input type="hidden" name="recaptcha_challenge_field" id="recaptcha_challenge_field" value="(.*?)" \/>/',$p,$dana);
  10. $obraz = 'http://api.recaptcha.net/image?c='.$dana[1];
  11. echo '<img src="'.$obraz.'" />';
  12. echo'<form method="POST"><input name="id"><input type="hidden" value="'.$dana[1].'" name="dana"><input type="submit" name="submit" value="submit"></form>';
  13. }else{
  14. //WYSYŁANIE danuch recaptcha
  15. $sub = urlencode('I\'m a Human');
  16. curl_setopt($hand, CURLOPT_URL, 'http://api.recaptcha.net/noscript?k=6LfEGgIAAAAAABSqQ0rzMd3t-rOU_XrZlC2C9WG2');
  17. curl_setopt($hand, CURLOPT_RETURNTRANSFER, 1);
  18. curl_setopt($hand, CURLPROXY_HTTP, 'jakies proxy');
  19. curl_setopt($hand, CURLOPT_POST, 1);
  20. curl_setopt($hand, CURLOPT_POSTFIELDS, array(
  21. 'recaptcha_challenge_field' => $_POST['dana'],
  22. 'recaptcha_response_field' => $_POST['id'],
  23. 'submit' => $sub
  24. ));
  25. $p=curl_exec($hand);
  26. echo $p;
  27. preg_match('/<textarea rows="3" cols="40">(.*?)<\/textarea>/s',$p,$kod);
  28. //pobieranie tokenu captcha
  29. curl_setopt($hand, CURLOPT_URL, 'http://www.erepublik.com/pl/register_captcha');
  30. curl_setopt($hand, CURLOPT_RETURNTRANSFER, 1);
  31. curl_setopt($hand, CURLPROXY_HTTP, 'proxy');
  32. curl_setopt($hand, CURLOPT_COOKIESESSION, true);
  33. curl_setopt($hand, CURLOPT_COOKIEFILE, "/tmp/cookiefiles.txt");
  34. curl_setopt($hand, CURLOPT_COOKIEJAR, "/tmp/cookiefiles.txt");
  35. $p=curl_exec($hand);
  36. $token = token($p);
  37. //wysyłanie danych captcha
  38. curl_setopt($hand, CURLOPT_URL, 'http://www.erepublik.com/pl/register_captcha');
  39. curl_setopt($hand, CURLOPT_RETURNTRANSFER, 1);
  40. curl_setopt($hand, CURLPROXY_HTTP, 'proxy');
  41. curl_setopt($hand, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1)");
  42. curl_setopt($hand, CURLOPT_POST, 1);
  43. curl_setopt($hand, CURLOPT_REFERER, 'http://www.erepublik.com/pl/referrer/nickjakis');
  44. curl_setopt($hand, CURLOPT_POSTFIELDS, array(
  45. 'recaptcha_challenge_field' => $kod[1],
  46. 'recaptcha_response_field' => 'manual_challenge',
  47. '_token' => $token,
  48. 'commit' => $ok
  49. ));
  50. $wynik=curl_exec($hand);
  51. echo $wynik.$kod[1];
  52. }


kod ma na celu zautomatyzowaną rejestracje w erepublik w celach edukacyjnych, fragment kodu jest odpowiedzialny za wpisywanie kodu captcha do przeglądarki z użyciem recaptcha bez użycia JavaScriptu, niestety, na samym końcu w paragrafie //wysyłanie danych captcha - wysyła błąd "CSRF attack detected"
mam 2 przypuszczenia:
nieprawidłowe dane post.
albo kolejny bug związany z niemożnością wpisania kodu bez użycia js

jeśli to 1 to pomóżcie namierzyć gdzie ewentualnie, a leżeli 2-gie to chyba trzeba by było wypełnić recaptchę z włączonym js - nie wiem jak.

Ten post edytował kavillock 10.03.2010, 22:18:13
Go to the top of the page
+Quote Post
nospor
post 10.03.2010, 22:20:50
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Cytat
kod ma na celu zautomatyzowaną rejestracje w erepublik w celach edukacyjnych

Cytat
5.1 You agree that you shall not (and you agree not to allow any third party to):


5.1.3 use any robot, spider, website search/retrieval application, or other automated device, process or means to access, retrieve or index any portion of the Website and/or the eRepublik.com Service, other than for the purposes of using the eAPI System and then only as allowed by the functionality of the eAPI System;

Nic tam nie napisali, ze robią wyjatek dla "celów edukacyjnych". zamykam


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 09:36