wie der titel schon sagt, versuche ich mich mit mein steam account auf websites einzuloggen. der log in ansich ist nicht das problem allerdings der redirect und ich weis nicht wie ich mit diesen umgehen soll
um genau zu sein, anstelle direkt auf die gewünschte website zu gelangen lande ich auf der steam seite "möchte sie sich mit diesen account auf der website anmelden"
z.b
*edit* wichtigste vergessen*/edit*
FROHE WEIHNACHTEN
PHP Code:
string url = "http://backpack.tf/login";
CookieCollection login = DoLogin(benutzername, paswort);
Fetch(@url, "GET", ((CookieContainer)login));
fetch
der request
login
JSON
PHP Code:
public static string Fetch(string url, string method, NameValueCollection data = null, CookieContainer cookies = null, bool ajax = true)
{
HttpWebResponse response = Request(url, method, data, cookies, ajax);
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(responseStream))
{
return reader.ReadToEnd();
}
}
}
PHP Code:
public static HttpWebResponse Request(string url, string method, NameValueCollection data = null, CookieContainer cookies = null, bool ajax = true, string referer = "")
{
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.AllowAutoRedirect = true;
request.Method = method;
request.Accept = "application/json, text/javascript;q=0.9, */*;q=0.5";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
//request.Host is set automatically
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36";
request.Referer = string.IsNullOrEmpty(referer) ? "http://www.steamgifts.com/giveaway/fO4XE/numba-deluxe" : referer;
request.Timeout = 50000; //Timeout after 50 seconds
if (ajax)
{
request.Headers.Add("X-Requested-With", "XMLHttpRequest");
request.Headers.Add("X-Prototype-Version", "1.7");
}
// Cookies
request.CookieContainer = cookies ?? new CookieContainer();
// Request data
if (data != null)
{
string dataString = String.Join("&", Array.ConvertAll(data.AllKeys, key =>
String.Format("{0}={1}", HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(data[key]))
));
byte[] dataBytes = Encoding.UTF8.GetBytes(dataString);
request.ContentLength = dataBytes.Length;
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(dataBytes, 0, dataBytes.Length);
}
}
// Get the response
return request.GetResponse() as HttpWebResponse;
}
PHP Code:
public static CookieCollection DoLogin(string username, string password)
{
var data = new NameValueCollection();
data.Add("username", username);
string response = Fetch("https://steamcommunity.com/login/getrsakey", "POST", data, null, false);
GetRsaKey rsaJSON = JsonConvert.DeserializeObject<GetRsaKey>(response);
// Validate
if (rsaJSON.success != true)
{
return null;
}
//RSA Encryption
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
RSAParameters rsaParameters = new RSAParameters();
rsaParameters.Exponent = HexToByte(rsaJSON.publickey_exp);
rsaParameters.Modulus = HexToByte(rsaJSON.publickey_mod);
rsa.ImportParameters(rsaParameters);
byte[] bytePassword = Encoding.ASCII.GetBytes(password);
byte[] encodedPassword = rsa.Encrypt(bytePassword, false);
string encryptedBase64Password = Convert.ToBase64String(encodedPassword);
SteamResult loginJson = null;
CookieCollection cookies;
string steamGuardText = "";
string steamGuardId = "";
do
{
Console.WriteLine("SteamWeb: Logging In...");
bool captcha = loginJson != null && loginJson.captcha_needed == true;
bool steamGuard = loginJson != null && loginJson.emailauth_needed == true;
string time = Uri.EscapeDataString(rsaJSON.timestamp);Uri.EscapeDataString(loginJson.captcha_gid);
data = new NameValueCollection();
data.Add("password", encryptedBase64Password);
data.Add("username", username);
// SteamGuard
if (steamGuard)
{
Console.WriteLine("SteamWeb: Captcha is needed.");
SteamGuardWindow sgwindow = new SteamGuardWindow();
sgwindow.ShowDialog();
if (!String.IsNullOrEmpty(sgwindow.Code))
{
steamGuardText = sgwindow.Code;
}
Console.WriteLine("SteamWeb: SteamGuard is needed.");
Console.WriteLine("SteamWeb: Type the code:");
steamGuardText = Uri.EscapeDataString(steamGuardText);
steamGuardId = loginJson.emailsteamid;
}
data.Add("emailauth", steamGuardText);
data.Add("emailsteamid", steamGuardId);
// SteamGuard end
data.Add("rsatimestamp", time);
HttpWebResponse webResponse = Request("https://steamcommunity.com/login/dologin/", "POST", data, null, false);
StreamReader reader = new StreamReader(webResponse.GetResponseStream());
string json = reader.ReadToEnd();
loginJson = JsonConvert.DeserializeObject<SteamResult>(json);
cookies = webResponse.Cookies;
}
while (loginJson.emailauth_needed == true);
if (loginJson.success == true)
{
CookieContainer c = new CookieContainer();
foreach (Cookie cookie in cookies)
{
c.Add(cookie);
}
SubmitCookies(c);
return cookies;
}
else
{
Console.WriteLine("SteamWeb Error: " + loginJson.message);
return null;
}
}
PHP Code:
public class GetRsaKey
{
public bool success { get; set; }
public string publickey_mod { get; set; }
public string publickey_exp { get; set; }
public string timestamp { get; set; }
}
public class SteamResult
{
public bool success { get; set; }
public string message { get; set; }
public bool captcha_needed { get; set; }
public string captcha_gid { get; set; }
public bool emailauth_needed { get; set; }
public string emailsteamid { get; set; }
}






