Hackt jemand zufällig C++?

Systembastelstube: Toto-Experten präsentieren ihre Systeme sowie Gratis-Tools und auch aktuelle News über das Toto kommen nicht zu kurz.
Antworten
Benutzeravatar
dali
Tipp-Spezialist (dal)
Tipp-Spezialist (dal)
Beiträge: 1971
Registriert: 11. Feb 2013, 14:25

Hackt jemand zufällig C++?

Beitrag von dali »

Hallo, ich versuche gerade den Spielplan von westlotto
https://www.westlotto.com/wlinfo/WL_Inf ... elplanToto
in C++ einzulesen (mittels curlpp). Mit dem curl tool auf der commandozeile klappt das ganz gut:

curl -v https://www.westlotto.com/wlinfo/WL_Inf ... elplanToto

Code: Alles auswählen

*   Trying 194.25.144.211...
* TCP_NODELAY set
* Connected to www.westlotto.com (194.25.144.211) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: jurisdictionC=DE; jurisdictionL=M�nster; businessCategory=Private Organization; ST=Nordrhein-Westfalen; 
O=Westdeutsche Lotterie GmbH & Co. OHG; OU=Datacenter Management; CN=www.westlotto.com
*  start date: Apr  4 00:00:00 2016 GMT
*  expire date: Sep 18 23:59:59 2017 GMT
*  subjectAltName: host "www.westlotto.com" matched cert's "www.westlotto.com"
*  issuer: C=US; O=GeoTrust Inc.; CN=GeoTrust Extended Validation SHA256 SSL CA
*  SSL certificate verify ok.
> GET /wlinfo/WL_InfoService?gruppe=SpielplanToto HTTP/1.1
> Host: www.westlotto.com
> User-Agent: curl/7.50.3
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Wed, 30 Aug 2017 10:00:49 GMT
< X-Xss-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: https://www.westlotto.com
< Warning: 299 - "Call is deprecated and may be removed in a future release, please contact westlotto (OE 322)." 
"Wed, 30 Aug 2017 10:00:49 GMT"
< Last-Modified: Wed, 30 Aug 2017 10:00:49 GMT
< Content-Length: 12741
< Vary: User-Agent
< Access-Control-Allow-Origin: *
< Cache-Control: must-revalidate
< Content-Type: text/xml;charset=ISO-8859-15
< Server: WestLotto
< Strict-Transport-Security: max-age=16070400
< Set-Cookie: WLSessCookie=NBBFCBAK; Expires=Wed, 30-Aug-2017 10:05:49 GMT; Path=/
< 
<?xml version='1.0' encoding="ISO-8859-15" ?>
<root>
<exception></exception>
	<version>1.0</version>
	<datum>02.09.2017 - 03.09.2017</datum>
	<ausspielung>35</ausspielung>

	<spiele>
		<nr>1</nr>
		<heimverein>New England Revolution</heimverein>
		<gastverein>Orlando City</gastverein>
		<tendenz>3-4-3</tendenz>
		<torergebnis></torergebnis>
		<gewinnzahlew></gewinnzahlew>
		<gewinnzahlaw></gewinnzahlaw>
		<ersatzwertung></ersatzwertung>
	</spiele>
	<spiele>
		<nr>2</nr>
		<heimverein>Montreal Impact</heimverein>
		<gastverein>Chicago Fire</gastverein>
		<tendenz>2-4-4</tendenz>
		<torergebnis></torergebnis>
		<gewinnzahlew></gewinnzahlew>
		<gewinnzahlaw></gewinnzahlaw>
		<ersatzwertung></ersatzwertung>
	</spiele>
	...
</root>
wenn ich es aber unter C++ versuche, bekomme ich ein HTML document das request denied sagt.

Code: Alles auswählen

    curlpp::Cleanup myCleanup;
    curlpp::Easy myRequest;
    myRequest.setOpt<Url>("http://www.westlotto.com/wlinfo/WL_InfoService?gruppe=SpielplanToto");
    myRequest.perform();

OUTPUT: 
<html>
<title>Request Denied!</title>
<body><center>
<h1>Request Denied!</h1>
<p>www.westlotto.de</p>
<p>If you have any questions contact the admin.</p>
</center></body></html>
Hat jemand ahnung von dem Zeug?

Dnake! :wave
Zuletzt geändert von dali am 1. Sep 2017, 12:48, insgesamt 1-mal geändert.
Toto-Bilanz 2016-2023: 1-10-96-619 (+19.314,90 € -- 129.9%)
Toto-Bilanz 2024: 0-0-1-13 (-461,20€ -- 52.5%)

(28.02.2024)
Benutzeravatar
dali
Tipp-Spezialist (dal)
Tipp-Spezialist (dal)
Beiträge: 1971
Registriert: 11. Feb 2013, 14:25

Re: Hackt jemand zufällig C++?

Beitrag von dali »

:wave

Ich habe es wie folgt gelöst (vvlt. ja hilfreich für andere). Das curl command line tool bietet die option --libcurl die den entsprechenden code erzeugt der durch die Abfrage generiert wird:

curl --libcurl code.c https://www.westlotto.com/wlinfo/WL_Inf ... elplanToto

Im file "code.c" steht dann der entsprechende code, in diesem Fall:

Code: Alles auswählen

  CURLcode ret;
  CURL *hnd;

  hnd = curl_easy_init();
  curl_easy_setopt(hnd, CURLOPT_URL, "https://www.westlotto.com/wlinfo/WL_InfoService?gruppe=SpielplanToto");
  curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.50.3");
  curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
  curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
  
  ret = curl_easy_perform(hnd);
Die wichtige Option ist dabei der CURLOPT_USERAGENT ; ohne diese Zeile geht es nicht (also kommt die Reqest-denied Seite von oben als Ergebnis).
Will man das ganze noch in einem string speichern muss man noch einen callback einbauen:

Code: Alles auswählen

static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) {
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

CURLcode ret;
CURL *hnd;
std::string readBuffer;

hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, "https://www.westlotto.com/wlinfo/WL_InfoService?gruppe=SpielplanToto");
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.50.3");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, &readBuffer);

ret = curl_easy_perform(hnd);

curl_easy_cleanup(hnd);
hnd = NULL;

std::cerr << readBuffer << std::endl;
Dann steht der Spielplan als xml im readBuffer string und kann an den xml-parser weitergereicht werden. :gruebel

Mal schauen ob man so auch die Durchschnittsquoten von betexplorer abschnorcheln kann :cool:
Toto-Bilanz 2016-2023: 1-10-96-619 (+19.314,90 € -- 129.9%)
Toto-Bilanz 2024: 0-0-1-13 (-461,20€ -- 52.5%)

(28.02.2024)
Antworten

Zurück zu „Toto-Werkstatt: Systeme, Tools und News“