Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [CURL][PHPBB] logowanie do panelu admina, na zwyklego usera dziala, a do panelu nie
blexth
post 4.02.2008, 20:26:43
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 18.11.2006

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


witam, mam klasę do logowania się przez curl do phpbb na usera, żeby można po prostu napisać temat itp, a w jaki sposób można zalogować się do panelu admina (znając oczywiście dane?), próbowałem po prostu zmienić ścieżkę z login.php na admin/index.php, ale nie działa any idea?
Go to the top of the page
+Quote Post
Cysiaczek
post 4.02.2008, 20:29:26
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




To nie ma nic wspólnego z OOP.

Przenoszę na Gotowe rozwiązania -> Skrypty forum


Wydaje mi się, że musisz podać więcej szczegółów.

Pozdrawiam.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
blexth
post 4.02.2008, 20:37:53
Post #3





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 18.11.2006

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


no to podaję funkcję logującą

  1. <?php
  2. function login($username, $password)
  3. {
  4. global $_SERVER;
  5.  
  6. // Generate post string
  7. $post_fields = $this->array_to_http(array(
  8. 'username' => $username,
  9. 'password' => $password,
  10. 'autologin' => 1,
  11. 'redirect' => 'admin/index.php',
  12. 'login' => 'Log In',
  13. ));
  14. // Init curl
  15. $this->curl = curl_init();
  16. // Set options
  17. curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'login.php?redirect=admin/index.php' );
  18. curl_setopt ( $this->curl, CURLOPT_POST, true );
  19. curl_setopt ($ch, CURLOPT_REFERER, "http://adresforum.pl/admin/index.php"); 
  20. curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
  21. curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
  22. curl_setopt ( $this->curl, CURLOPT_HEADER, false );
  23. curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
  24. curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
  25. curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
  26. curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  27. // Execute request
  28. $result = curl_exec ( $this->curl );
  29. // Error handling
  30. if ( curl_errno ( $this->curl ) )
  31. {
  32. $this->error = array(
  33. curl_errno($this->curl),
  34. curl_error($this->curl),
  35. );
  36. curl_close ( $this->curl );
  37. return false;
  38. }
  39. // Close connection
  40. curl_close ( $this->curl );
  41. // Return result
  42. return true;
  43. }
  44. ?>


ten sposób po prostu nie działa, nie wychodzi logowanie na admina
Go to the top of the page
+Quote Post
nowotny
post 4.02.2008, 21:00:00
Post #4





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

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


Ja bym podsniffował jak przebiega logowanie do admina... jak wygląda POST i wtedy odpowiednio zmodyfikował $post_fields...
Go to the top of the page
+Quote Post
blexth
post 5.02.2008, 17:02:05
Post #5





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 18.11.2006

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


przejrzalem, jedyna roznica to zamiast Log in jest 'zaloguj', ale ciagle nie dziala.

czyli nie da sie?
Go to the top of the page
+Quote Post
nowotny
post 5.02.2008, 19:22:24
Post #6





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

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


Skąd wiesz że nie działa...? jak to sprawdzasz...?

Pokaż no to co wysniffowałeś... cały nagłówek...
Go to the top of the page
+Quote Post
blexth
post 5.02.2008, 21:34:52
Post #7





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 18.11.2006

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


bo odpalam file_get_contents (index.php) i w indeksie jest spoko zalogowany a jak odpalam na admin/index.php to nie jest ];

wysniffowane:
Kod
POST /forum/login.php HTTP/1.1

Host: adres.pl

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20060629 Firefox/1.0.4 (Debian package 1.0.4-2sarge9)

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: en-us,en;q=0.7,pl;q=0.3

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Referer: http://adres/forum/login.php?redirect=admin/index.php&admin=1&sid=6fd93ab3829593e52eb47b3262c64f52

Cookie: phpbb3_gs1bp_k=; style_cookie=printonly; phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bs%3A1%3A%222%22%3B%7D; phpbb3_gs1bp_sid=230ee99d52e0fb0e9d3e9824523b74fd; phpbb3_gs1bp_u=2; __utmz=38071927.1200687138.104.8.utmccn=(referral)|utmcsr=shou.pl:2082|utmcct=/frontend/x3/stats/lastvisit.html|utmcmd=referral; __utma=38071927.229132273.1195373403.1202232064.1202243595.122; PHPSESSID=0283166399260e2f6690582bf7b0cf18; __utmb=38071927; __utmc=38071927; phpbb2mysql_sid=6fd93ab3829593e52eb47b3262c64f52

Content-Type: application/x-www-form-urlencoded

Content-Length: 94

username=login&password=pass&redirect=admin%2Findex.php%3Fadmin%3D1&admin=1&login=Zaloguj
Go to the top of the page
+Quote Post
nowotny
post 5.02.2008, 21:47:29
Post #8





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

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


Tak to wg. mnie powinno wyglądać:
  1. <?php
  2. function login($username, $password)
  3. {
  4. global $_SERVER;
  5.  
  6. // Generate post string
  7. $post_fields = $this->array_to_http(array(
  8. 'username' => $username,
  9. 'password' => $password,
  10. 'autologin' => 1,
  11. 'redirect' => 'admin/index.php?admin=1',
  12. 'admin' => 1
  13. 'login' => 'Zaloguj',
  14. ));
  15. // Init curl
  16. $this->curl = curl_init();
  17. // Set options
  18. curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'login.php' );
  19. curl_setopt ($this->curl, CURLOPT_FOLLOWLOCATION,1);
  20.  curl_setopt ( $this->curl, CURLOPT_POST, true );
  21. curl_setopt ($this->curl, CURLOPT_REFERER, $this->phpbb_url.'login.php?redirect=admin/index.php&admin=1'); 
  22.  curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
  23. curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
  24. curl_setopt ( $this->curl, CURLOPT_HEADER, false );
  25. curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
  26. curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
  27. curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
  28. curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  29. // Execute request
  30. $result = curl_exec ( $this->curl );
  31. // Error handling
  32. if ( curl_errno ( $this->curl ) )
  33. {
  34. $this->error = array(
  35. curl_errno($this->curl),
  36. curl_error($this->curl),
  37. );
  38. curl_close ( $this->curl );
  39. return false;
  40. }
  41. // Close connection
  42. curl_close ( $this->curl );
  43. // Return result
  44. return true;
  45. }
  46. ?>
Go to the top of the page
+Quote Post

Reply to this 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: 31.07.2025 - 07:52