GetStringBetween() public static method

Gets a string inbetween two strings
public static GetStringBetween ( string source, string start, string end ) : string
source string Source string
start string Start string
end string End string
return string
Beispiel #1
0
        /// <summary>
        /// Gets the session from hotmail
        /// </summary>
        public static void GetSession()
        {
            /*Start the request*/
            var webAdd = "https://signup.live.com/signup.aspx?lic=1";
            var webReq = (HttpWebRequest)WebRequest.Create(webAdd);

            /*Add nessesary information to the request so it will be accepted as a legit request*/
            webReq.ContentType     = "application/json; charset=utf-8";
            webReq.Method          = "GET";
            webReq.Host            = "signup.live.com";
            webReq.Accept          = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
            webReq.UserAgent       = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36";
            webReq.ContentType     = "application/x-www-form-urlencoded; charset=UTF-8";
            webReq.KeepAlive       = true;
            webReq.CookieContainer = mCookies;

            /*Read the response*/
            var httpResponse = (HttpWebResponse)webReq.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                /*Scrape all the session details we need to make dirty api requests*/
                var result = streamReader.ReadToEnd();
                mRequest.uaid   = Functions.GetStringBetween(result, "\"uaid\":\"", "\",");
                mRequest.uiflvr = Convert.ToInt32(Functions.GetStringBetween(result, "\"uiflvr\":", ","));
                mRequest.scid   = Convert.ToInt32(Functions.GetStringBetween(result, "\"scid\":", ","));
                mRequest.hpgid  = Convert.ToInt32(Functions.GetStringBetween(result, "\"hpgid\":", ","));
                mApiCanary      = Regex.Unescape(Functions.GetStringBetween(result, "\"apiCanary\":\"", "\","));
                Console.WriteLine("Got Hotmail session");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the steam session
        /// </summary>
        public static string GetSession(Config.Proxy proxy)
        {
            /*Start the request*/
            var webAdd = "https://help.steampowered.com";
            var webReq = (HttpWebRequest)WebRequest.Create(webAdd);

            /*Add nessesary information to the request so it will be accepted as a legit request*/
            webReq.ContentType     = "application/json; charset=utf-8";
            webReq.Method          = "GET";
            webReq.Host            = "help.steampowered.com";
            webReq.Accept          = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
            webReq.UserAgent       = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36";
            webReq.ContentType     = "application/x-www-form-urlencoded; charset=UTF-8";
            webReq.KeepAlive       = true;
            webReq.CookieContainer = mCookies;
            webReq.Proxy           = new WebProxy(proxy.host, proxy.port);

            /*Read the response*/
            var httpResponse = (HttpWebResponse)webReq.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                /*Scrape all the session details we need to make dirty api requests*/
                var result = streamReader.ReadToEnd();
                return(Functions.GetStringBetween(result, "g_sessionID = \"", "\";"));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Parses the response from query
        /// </summary>
        /// <param name="o">Sender</param>
        /// <param name="e">EventArgs - we get page source from result</param>
        private void ParseResponse(object o, DownloadStringCompletedEventArgs e, string steamId)
        {
            try
            {
                string pageSource = e.Result;
                if (pageSource.Contains("This user has not yet set up their Steam Community profile."))
                {
                    /*Get the account name from page title*/
                    string accountName = Functions.GetStringBetween(pageSource, "<title>", "</title>")
                                         .Replace("Steam Community :: ", "");

                    if (!string.IsNullOrEmpty(accountName) && accountName.Length >= 3)
                    {
                        /*Format email and check if it looks okay*/
                        string accountEmail = string.Format("{0}@hotmail.com", accountName);

                        /*If the email is valid and not taken*/
                        if (IsEmailGood(accountEmail))
                        {
                            /*Set up the account*/
                            var account = new Config.Account()
                            {
                                steamid  = steamId,
                                username = accountName,
                                email    = accountEmail
                            };

                            mLog.Write(account);
                            mAccountsFound++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
            }

            /*Release queue position*/
            mSem.Release();
        }