H
Ok also ich habe mich seehr blöd ausgedrückt ich meinte das so das ich über TCP
eine verbindung mit einem PHP script hestelle dabei muss ich die daten an den PHP script wie folgt übermitteln : Alle Daten in MD5 , Password,Benutzername,zeit und datum. Dann entschlüsselt der PHP script die Daten schaut in der Datenbank und gibt ein Wert zurück mein bisheriger code ist :
#include <stdafx.h>
#include <stdio.h>
#include "winsock2.h"
#include <iostream>
#include <windows.h>
#pragma comment(lib, "wininet.lib")
#pragma comment(lib, "Ws2_32.lib")
using namespace std;
#define DEFAULT_BUFLEN 512
#define DEFAULT_PORT 27015
int main() {
//----------------------
// Declare and initialize variables.
int iResult;
WSADATA wsaData;
SOCKET ConnectSocket;
struct sockaddr_in clientService;
int recvbuflen = DEFAULT_BUFLEN;
char *sendbuf = "POST /check.php HTTP/1.1\nHost: farmcrawler.funpic.fa.de\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.3 (de) (TL-FF)\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\nAccept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\nKeep-Alive: 300\nConnection: keep-alive\nContent-Type: application/x-www-form-urlencoded\nContent-Length: 132\n\nquery0=";
char recvbuf[DEFAULT_BUFLEN] = "";
char post[255] = "1234567890";
int len;
//len = strlen (buffer);
//----------------------
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != NO_ERROR) {
printf("WSAStartup failed with error: %d\n", iResult);
return 1;
}
//----------------------
// Create a SOCKET for connecting to server
ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (ConnectSocket == INVALID_SOCKET) {
printf("socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return 1;
}
//----------------------
// The sockaddr_in structure specifies the address family,
// IP address, and port of the server to be connected to.
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr( "213.202.225.55" );
clientService.sin_port = htons(80);
//----------------------
// Connect to server.
iResult = connect( ConnectSocket, (SOCKADDR*) &clientService, sizeof(clientService) );
if (iResult == SOCKET_ERROR) {
printf( "connect failed with error: %d\n", WSAGetLastError() );
closesocket(ConnectSocket);
WSACleanup();
int x = 1;
cin >> x;
return 1;
}
//----------------------
// Send an initial buffer
iResult = send( ConnectSocket, sendbuf, (int)strlen(sendbuf), 0 );
if (iResult == SOCKET_ERROR) {
printf("send() failed with error: %d\n", WSAGetLastError());
closesocket(ConnectSocket);
WSACleanup();
return 1;
}
printf("Bytes Sent: %d\n", iResult);
// shutdown the connection since no more data will be sent
iResult = shutdown(ConnectSocket, SD_SEND);
if (iResult == SOCKET_ERROR) {
printf("shutdown failed with error: %d\n", WSAGetLastError());
closesocket(ConnectSocket);
WSACleanup();
int x = 1;
cin >> x;
return 1;
}
// Receive until the peer closes the connection
do {
iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
if ( iResult > 0 )
printf("Bytes received: %d\n", iResult);
else if ( iResult == 0 )
printf("Connection closed\n");
else
printf("recv failed with error: %d\n", WSAGetLastError());
} while( iResult > 0 );
// cleanup
closesocket(ConnectSocket);
WSACleanup();
int x = 1;
cin >> x;
return 0;
}
Ich möchte jetzt noch dies dazu machen... "query0="&query0&"&query1="&query1&"&query2="&query2&"&query3="&query3"
wenn jemand autoit kann hier ist mal der code in autoit da konnte ich das schon realisieren ^^
Local $sIp, $iSocket, $sPost, $sHeader, $sHost, $sRecv, $sResult
TCPStartup()
$sServer = StringLower($sServer)
$sHost = StringReplace(StringReplace($sServer,'http://',''),'www.','')
MsgBox("","",$sHost)
$sIp = TCPNameToIP($sServer)
msgbox("","",$sIp)
$iSocket = TCPConnect($sIp,80)
$sPost = "query0="&$query0&"&query1="&$query1&"&query2="&$query2&"&query3="&$query3
$sHeader = "POST /check.php HTTP/1.1" & @CRLF & _
"Host: " & $sHost & @CRLF & _
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.3 (de) (TL-FF)" & @CRLF & _
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & @CRLF & _
"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" & @CRLF & _
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & @CRLF & _
"Keep-Alive: 300" & @CRLF & _
"Connection: keep-alive" & @CRLF & _
"Content-Type: application/x-www-form-urlencoded" & @CRLF & _
"Content-Length: "& StringLen($sPost) & @CRLF & @CRLF & $sPost
$iSend = TCPSend($iSocket, $sHeader)
$sRecv = TCPRecv($iSocket,1024)
$infoo = StringLen($sPost)
MsgBox("","",$infoo)
While 1
$sRecv &= TCPRecv($iSocket,1024)
If StringInStr($sRecv,'[/return]') OR @error Then ExitLoop
WEnd
$sResult = _stringbetween($sRecv,'[return]','[/return]')
TCPShutdown()
If IsArray($sResult) Then
Return $sResult[0]
Else
Return 'servererror'
EndIf