
|
|
Quellcode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
#include <cstdlib>
#include <iostream>
#include <winsock2.h>
#include <string>
#include <fstream>
using namespace std;
int WSAStart()
{
WSADATA wsa;
return WSAStartup(MAKEWORD(2,0), &wsa);
}
string StringBetween(const string& input, const string& left, const string& right)
{
size_t posLeft, posRight;
posLeft = input.find(left);
posRight = input.find(right);
if (posLeft == string::npos || posRight == string::npos)
{
return ""; // Nicht gefunden
}
posLeft += left.length();
posRight += right.length();
string ergebnis1 = input.substr(posLeft, input.length() - right.length() - left.length());
int formel = (input.find(right) - posLeft);
string ergebnis2 = ergebnis1.substr(0, formel);
return ergebnis2;
} //=======>GRÖßTER TEIL NICHT VON MIR
const string GetCookieData(const string Cookie, string cookie_name)
{
const size_t found_pos(Cookie.find(cookie_name));
string ReturnString;
if(found_pos != std::string::npos)
for(size_t i(found_pos + cookie_name.length()); // std::string("spgdex")::size() == 6
Cookie[i] != ';';
++i)
ReturnString.push_back(Cookie[i]);
return ReturnString;
} //=====>NICHT VON MIR
void gebaus(char array[])
{
for (int i=0;array[i]!=0;i++)
{
cout << array[i];
}
cout << endl;
}
string WSAgetDataGet(string ip, string host, string ref = "", string seite = "", string cookie_str = "")
{
string data = "GET " + seite + " HTTP/1.0\r\n"
"Host: " + host + "\r\n"
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.16) Gecko/2009120208 Firefox/3.0.16 (.NET CLR 3.5.30729)\r\n"
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n"
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
"Keep-Alive: 300\r\n"
//"Content-Type: application/x-www-form-urlencoded\r\n"
"Connection: keep-alive\r\n";
if (ref!="")
{
data = data + "Referer: " + ref +"\r\n";
}
else
{
data = data + "\r\n";
}
if (cookie_str!="")
{
data = data + cookie_str;
}
data = data + "\r\n\r\n";
return data;
return data;
}
string itostring(int a)
{
char length[10];
itoa(a, length, 10);
string help;
help.assign(length);
return help;
}
string WSAgetDataPost(string ip, string host, string post, string seite = "", string cookie_str = "")
{
string data = "";
//=======================>länge des Stringes ermitteln
string help = itostring(post.length());
//========================>länge des Stringes ermitteln ENDE
if (cookie_str!="")
{
data = "POST " + seite + " HTTP/1.0\r\n"
"Host: " + host + "\r\n"
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.16) Gecko/2009120208 Firefox/3.0.16 (.NET CLR 3.5.30729)\r\n"
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n"
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
"Keep-Alive: 300\r\n"
"Connection: keep-alive\r\n" + cookie_str + "\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: "+help+"\r\n\r\n" + post;
}
else
{
data = "POST " + seite + " HTTP/1.0\r\n"
"Host: " + host + "\r\n"
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.16) Gecko/2009120208 Firefox/3.0.16 (.NET CLR 3.5.30729)\r\n"
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n"
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
"Keep-Alive: 300\r\n"
"Connection: keep-alive\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: "+help+"\r\n\r\n" + post;
}
return data;
}
string WSARequest(string ip, string host, string seite = "", string ref = "", string post = "", string data = "", string cookie_str = "")
{
SOCKET sock;
if (WSAStart()!=0)
{
cout << "WSA konnte nicht gestartet werden!" << endl;
system("pause");
return "-1";
}
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock==INVALID_SOCKET)
{
cout << "Socket konnte nicht erstellt werden!" << endl;
system("pause");
return "-1";
}
//================>Ip Adresse konvertieren
char inet_address[30];
strcpy(inet_address, ip.c_str());
//==================>Ip Adresse konvertieren ENDE
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(80);
addr.sin_addr.s_addr = inet_addr(inet_address);
long rc = connect(sock, (SOCKADDR*)&addr, sizeof(sockaddr));
if (rc==SOCKET_ERROR)
{
cout << "SOCKET_ERROR: Error beim Verbinden mit " << ip << endl;
system("pause");
return "-1";
}
else
{
cout << "Verbindung wurde erfolgreich hergestellt!" << endl;
}
//=======================================================================>
//=================>Verbunden mit Server<================================>
//=======================================================================>
if (data=="") {
if (post=="") //wenn kein Post benutzt werden soll
{
data = WSAgetDataGet(ip, host, ref,seite, cookie_str);
}
else
{
data = WSAgetDataPost(ip, host, post, seite, cookie_str);
}
}
//===>Senden anfang
char buffer[data.length()+1];
strcpy(buffer, data.c_str());
cout << data << endl;
rc = send(sock, buffer, sizeof(buffer), 0);
if (rc==SOCKET_ERROR)
{
cout << "Daten konnten nicht versendet werden!" << endl;
system("pause");
return "-1";
}
//=============>SENDEN ENDE
//=======>EMPFANGEN ANFANG
string source = "";
strcpy(buffer, "");
for(;;)
{
rc = recv(sock, buffer, sizeof(buffer), 0);
if(rc == -1)
{
cout << "Fehler: " << WSAGetLastError() << '\n';
break;
}
if(rc == 0)
{
break;
}
source.append(buffer, rc);
}
return source;
}
string MakeCookieString(string array[])
{
string cookie_string = "Cookie:";
int counter = atoi(array[0].c_str()) +1;
string help;
for (int i = 1;i<counter;i++)
{
cout << array[i] << endl;
help = " " + array[i] + ";";
cookie_string = cookie_string + help;
system("pause");
}
cookie_string = cookie_string.substr(0, cookie_string.length() -1);
return cookie_string;
}
string getRealLocation(string a)
{
return a.substr(0, a.length() - 2);
}
int main(int argc, char *argv[])
{
string post = "anmelden=true&pid=0&zz=-60&old=&x=12&y=3&login=loldgd%40web.de&passwd=test123";
string seite = "/glogin.shtml";
string host = "gde.sp.looki.de";
string ip = "213.202.233.12";
string source = WSARequest(ip, host, seite);
string spcheck = StringBetween(source, "Set-Cookie: ", ";");
//=================================>andere cokkies + location hab ich jetzt
string cookie_string = "Cookie: " + spcheck + ";";
source = WSARequest("213.202.233.12", host, seite,"", post, "", cookie_string);
string location = StringBetween(source, "location: ", "Vary:");
//=======>cookies extrahieren
string spgdex = "spgdex" + GetCookieData(source, "spgdex");
string gsp = "gsp=" + GetCookieData(source, "gsp=");
string splogin = "splogin" + GetCookieData(source, "splogin");
string param_array[5];
param_array[0] = "4";
param_array[1] = spcheck;
param_array[2] = gsp;
param_array[3] = splogin;
param_array[4] = spgdex;
cookie_string = MakeCookieString(param_array);
location = getRealLocation(location);
//=========>alles nötige extrahiert--->weiter gehts
system("cls");
cout << cookie_string << endl;
system("pause");
WSARequest(ip, host, location, "http://gde.sp.looki.de/glogin.shtml", "", "", cookie_string);
//=====>in datei schreiben
fstream f;
f.open("hello.html");
f << source << endl;
f.close();
system("PAUSE");
return EXIT_SUCCESS;
}
|
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »@night@« (17. Januar 2010, 17:04)

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »@night@« (18. Januar 2010, 10:44)

|
|
Quellcode
|
1 |
<a href="HIER DIE URL">Klicken Sie hier um weitergeleitet zu werden</a> |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Deathly Assassin« (18. Januar 2010, 19:11)
|
|
Quellcode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
HTTP/1.1 302 Found Date: Mon, 18 Jan 2010 14:38:51 GMT Server: Apache/2.2.10 (Unix) PHP/5.2.8 mod_python/3.3.2-dev-20080819 Python/2.4.4 node: www11 X-Database: gde Cache-Control: private, no-store, no-cache, must-revalidate Pragma: no-cache Cache-Control: no-cache="set-cookie" Set-Cookie: spcheck=1; path=/ Set-Cookie: spgdex1262142=x69e489d4-ODE2NA-5531-8-NzE3MA; path=/ Set-Cookie: gsp=5055416; path=/; expires=Tue, 18-Jan-2011 14:38:51 GMT Set-Cookie: splogin=loldgd@web.de; path=/; expires=Tue, 18-Jan-2011 14:38:51 GMT location: /gmain.shtml?cid=1262142 Vary: Accept-Encoding Content-Length: 0 Connection: close Content-Type: text/html; charset=utf-8 |
)Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »@night@« (18. Januar 2010, 21:07)
Zitat
Und bist du dir auch sicher, dass du alle cookies richtig übergiebst (auch die neu erhaltenen)? <-- Würd spntan sagen, dass es daran liegt
)
Hits heute: 3 889 | Hits Tagesrekord: 19 503 | Hits gesamt: 874 054 | Hits pro Tag: 2 039,15

