Beispiel #1
0
        private static string SendPassword(string username, string encryptedBase64, Dictionary<string, object> loginParams)
        {
            // Send the RSA-encrypted password via POST.
            var webRequest = WebRequest.Create(API_DO_LOGIN) as HttpWebRequest;
            webRequest.Method = "POST";

            var timestamp = loginParams["timestamp"] as string;

            var fields = new NameValueCollection();
            fields.Add("username", username);
            fields.Add("password", encryptedBase64);
            fields.Add("emailauth", String.Empty);
            fields.Add("captchagid", String.Empty);
            fields.Add("captcha_text", String.Empty);
            fields.Add("emailsteamid", String.Empty);
            fields.Add("rsatimestamp", timestamp);

            var query = fields.ConstructQueryString();
            var queryData = Encoding.ASCII.GetBytes(query);

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.ContentLength = queryData.Length;
            webRequest.CookieContainer = new CookieContainer();

            // Write the request
            using (Stream stream = webRequest.GetRequestStream())
            {
                stream.Write(queryData, 0, queryData.Length);
            }

            // Perform the request
            var response = webRequest.GetResponse() as HttpWebResponse;

            String res;
            using (Stream stream = response.GetResponseStream())
            {
                res = stream.ReadAll();
            }

            response.Close();

            var reader = new JsonReader();
            var results = reader.Read<Dictionary<string, object>>(res);

            return response.Cookies["steamLogin"].Value;
        }
Beispiel #2
0
        void SetRequestCommonFields(
            HttpWebRequest request, Action<NameValueCollection> headersCallback)
        {
            var fields = new NameValueCollection();
            fields.Add("sessionid", LoginData.SessionId);
            fields.Add("logpos", NextLogPos.ToString());
            fields.Add("version", Version.ToString());

            if (headersCallback != null)
                headersCallback(fields);

            var query = fields.ConstructQueryString();
            var queryData = Encoding.ASCII.GetBytes(query);

            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = queryData.Length;

            try
            {
                // Write the request
                using (Stream stream = request.GetRequestStream())
                    stream.Write(queryData, 0, queryData.Length);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not write query data to request: {0}",
                    ex.ToString());
            }
        }
Beispiel #3
0
        private static Dictionary<string, object> GetKeyRSA(string username)
        {
            // First ask the public RSA key for encryption.
            var webRequest = WebRequest.Create(API_RSA_KEY) as HttpWebRequest;
            webRequest.Method = "POST";

            var fields = new NameValueCollection();
            fields.Add("username", username);

            var query = fields.ConstructQueryString();
            byte[] data = Encoding.ASCII.GetBytes(query);

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.ContentLength = data.Length;

            // Write the request
            using (Stream stream = webRequest.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            // Perform the request
            var response = webRequest.GetResponse();

            String res;
            using (Stream stream = response.GetResponseStream())
            {
                res = stream.ReadAll();
            }

            response.Close();

            var reader = new JsonReader();
            var json = reader.Read<Dictionary<string, object>>(res);

            return json;
        }
Beispiel #4
0
        /// <summary>
        /// Sends a load theirs inventory request.
        /// </summary>
        public void LoadForeignInventory(SteamID backpackId, int appid, int contextid)
        {
            var service = string.Format(TradeURLAction, "foreigninventory");
            var webRequest = CreateSteamRequest(service, LoginData);

            var fields = new NameValueCollection();
            fields.Add("sessionid", LoginData.SessionId);
            fields.Add("steamid", backpackId.ConvertToUInt64().ToString());
            fields.Add("appid", appid.ToString());
            fields.Add("contextid", contextid.ToString());

            var query = fields.ConstructQueryString();
            var queryData = Encoding.ASCII.GetBytes(query);

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.ContentLength = queryData.Length;

            // Write the request
            using (Stream stream = webRequest.GetRequestStream())
            {
                stream.Write(queryData, 0, queryData.Length);
            }

            // Perform the request
            var res = webRequest.BeginGetResponse(
                new AsyncCallback(ProcessForeignInventory), webRequest);
        }