Curl i łatwy formularz

0

Witam, mój admin zrobił taki myk,że przy kazdym włączeniu komputera po uruchomieniu przeglądarki muszę wpisać w formularz login i hasło (kicia/kicia).

Source strony do logowania: http://nopaste.gamedev.pl/?id=1267

Robie program,który to zautomatyzuje przy pomocy curla. Mam taki kod:

#include <curl/curl.h>

int main()
{
  CURL *curl;
  CURLcode res;
  char *url="http://10.1.10.101";
  char *method_post="username=kicia&password=kicia";
  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "ciacho.txt");
    curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "ciacho.txt");
    curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1);
    curl_easy_setopt(curl, CURLOPT_HEADER, 1);
    curl_easy_setopt(curl, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.6;");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, method_post);

    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }

}

Włączam i ukazuje się moim oczom:

* About to connect() to 10.1.10.101 port 80
*   Trying 10.1.10.101... * connected
* Connected to 10.1.10.101 (10.1.10.101) port 80
> POST / HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.9) Gecko/20071
025 Firefox/2.0.0.6;
Host: 10.1.10.101
Accept: */*
Content-Length: 29
Content-Type: application/x-www-form-urlencoded

username=kicia&password=kicia< HTTP/1.1 303 Hotspot login required
HTTP/1.1 303 Hotspot login required
< Cache-Control: no-cache
Cache-Control: no-cache
< Connection: Keep-Alive
Connection: Keep-Alive
< Content-Length: 135
Content-Length: 135
< Content-Type: text/html
Content-Type: text/html
< Date: Sat, 03 Nov 2007 18:37:32 GMT
Date: Sat, 03 Nov 2007 18:37:32 GMT
< Expires: 0
Expires: 0
< Location: http://10.1.10.101/login
Location: http://10.1.10.101/login

<html>
<head><title>Error 303: Hotspot login required</title></head>
<body>
<h1>Error 303: Hotspot login required</h1>
</body>
</html>
* Connection #0 to host 10.1.10.101 left intact
* Closing connection #0

Co jest źle, że wywala Error 303: Hotspot login required?

Prócz curla próbowałem też w C++/cli w Visual 2005 EE zrobić aplet IE i wrzucić tam przez GET, ale cóż za dużo pamięciożerne i nie wyszło, jak i z Wininiet.

0

Jeszcze skleiłem coś takiego:

#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main()
{
 CURL *easyhandle;
 CURLcode res;
 char* binaryptr;
 
easyhandle = curl_easy_init();
if(easyhandle) 
{
               char *data="username=kicia&password=kicia";   
               curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDS, 0);   
               curl_easy_setopt(easyhandle, CURLOPT_URL, "http://10.1.10.101/");
               curl_easy_perform(easyhandle); 
               struct curl_slist *headers=NULL;  headers = curl_slist_append(headers, "Content-Type: text/xml");
               curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDS, binaryptr);
               curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDSIZE, 23);
               curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, headers);
               curl_easy_perform(easyhandle);
               curl_slist_free_all(headers);
               struct curl_httppost *post=NULL;
               struct curl_httppost *last=NULL;
               curl_formadd(&post, &last,   CURLFORM_COPYNAME, "username",   CURLFORM_COPYCONTENTS, "kicia", CURLFORM_END); 
               curl_formadd(&post, &last,   CURLFORM_COPYNAME, "password",   CURLFORM_COPYCONTENTS, "kicia", CURLFORM_END);  
               curl_easy_setopt(easyhandle, CURLOPT_HTTPPOST, post);

               curl_easy_perform(easyhandle);
               curl_formfree(post); 
               //curl_slist_free_all(post);
               curl_easy_setopt(easyhandle, CURLOPT_HTTPGET, TRUE);
            
}
  
   
 }
0
<form name="login" action="http://10.1.10.101/login" method="post" <b="&lt;b">onSubmit="return doLogin()"</b>>

...

function doLogin() {
document.sendin.username.value = document.login.username.value;
document.sendin.password.value = hexMD5('\170' + document.login.password.value + '\313\337\022\121\376\153\052\027\322\002\117\225\246\275\224\116');
document.sendin.submit();
return false;
}

0

Czyli powinienem tylko zamiast 'kicia' w password zrobić md5("kicia") ?

0

Powinieneś zrobić md5 z ciągu: '\170' + document.login.password.value + '\313\337\022\121\376\153\052\027\322\002\117\225\246\275\224\116'

Ale zakładam, że te dodatkowe liczby to seed, który zmienia się za każdym razem ;)

0

Czyli dupa?. ;-(

Cóż, a jak taki kod cURL'a powinien wyglądać? już bez tego md5 (-;

0

Dlaczego dupa? Skoro używasz już curla, to możesz spokojnie pobrać seed.

Cóż, a jak taki kod cURL'a powinien wyglądać?

kod CURla masz dobry :)

0

O co chodzi z tym seedem? Jak pobrać?
Zaimplementowałem md5.

#include <curl/curl.h>
#include <conio.h>
#include "md5/md5.h"
#include <string>

using namespace std;
int main()
{
    
  CURL *curl;
  CURLcode res;
  char *url="http://10.1.10.101";
  string a,b;
  a = "username=kicia&password=";
  b = "&dst=&popup=true";
  string hash=MD5String("kicia");
  string method_post=a + hash + b;
  
  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookies.txt");
    curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookies.txt");
    curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1);
    curl_easy_setopt(curl, CURLOPT_HEADER, 1);
    curl_easy_setopt(curl, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.6;");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, method_post.c_str());

    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
getch();
}
0

curlem mozesz nie tylko wyslac httprequest ale i odebrac httpresponse.. seed to jest taki losowy ciag krzaczkow, generowany od nowa za kazdym wyswietleniem strony, za kazdym razem *) inny. zeby to obejsc, bezdiesz musial SCIAGNAC strone logowania, PRZEJRZEC to co sciagnales, WYCIAGNAC seed, obliczyc KOD, SPREPAROWAC httprequest logowania i go wyslac.. innymi slowy, zachowywac sie tak jak user i przegladarka

0

A ten seed to w jakiej postaci jest, tzn. w jakim systemie zakodowany?
I czy wysłać mam go w postaci za czy odkodowanej?

1 użytkowników online, w tym zalogowanych: 0, gości: 1