Example #1
0
        public static void PostHttp(MyWebClient wc, string baseUrl, string paramConcat)
        {
            try
            {
                wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                var response = wc.UploadString(baseUrl, paramConcat);
            }
            catch (WebException ex)
            {
                logger.Error("Impossibile eseguire la post: " + ex.Message);
                throw new Exception("Impossibile eseguire la post: " + ex.Message);
            }
            Console.ForegroundColor = ConsoleColor.Green;
            logger.Info("ResponseHeaders:" + Environment.NewLine + "{0}", wc.ResponseHeaders);
            var cc = wc._mContainer.GetCookies(new Uri("http://www.fastweb.it"));

            foreach (var cookie in cc)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                logger.Info("Cookie: {0}", cookie);
            }
            Console.ForegroundColor = ConsoleColor.White;
            logger.Info("Redirect Location: {0}", wc._responseUri);

            foreach (var param in wc.responseParams)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                logger.Info("Fragment: {0} = {1}", param.Key, param.Value);
            }
        }
Example #2
0
        public static void PostHttp(MyWebClient wc, string baseUrl, string paramConcat)
        {
            try
            {
                wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                var response = wc.UploadString(baseUrl, paramConcat);
            }
            catch (WebException ex)
            {
                logger.Error("Impossibile eseguire la post: " + ex.Message);
                throw new Exception("Impossibile eseguire la post: " + ex.Message);
            }
            Console.ForegroundColor = ConsoleColor.Green;
            logger.Info("ResponseHeaders:" + Environment.NewLine + "{0}", wc.ResponseHeaders);
            var cc = wc._mContainer.GetCookies(new Uri("http://www.fastweb.it"));
            foreach (var cookie in cc)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                logger.Info("Cookie: {0}", cookie);
            }
            Console.ForegroundColor = ConsoleColor.White;
            logger.Info("Redirect Location: {0}", wc._responseUri);

            foreach (var param in wc.responseParams)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                logger.Info("Fragment: {0} = {1}", param.Key, param.Value);
            }
        }
Example #3
0
        public static bool MFPManual(MyWebClient wc)
        {
            // Se siamo nella pagina giusta procedo alla costruzione della POST finale
            if (wc.responseParams.ContainsKey("identifycode"))
            {
                StringBuilder sb = new StringBuilder(
                    "current=2" +
                    "&step=3" +
                    "&ctrl=" +
                    "&portmap_action=manual_setup" +
                    "&channel=" + wc.responseParams["channel"] +
                    "&account=" + wc.responseParams["account"] +
                    "&username="******"username"] +
                    "&service=" + wc.responseParams["service"] +
                    "&actionid=" +
                    "&status=" + wc.responseParams["status"] +
                    "&segmento=" + wc.responseParams["segmento"] +
                    "&selcode=" + wc.responseParams["selcode"] +
                    "&origin=" + wc.responseParams["origin"] +
                    "&checksum=" + wc.responseParams["checksum"] +
                    "&identifycode=" + wc.responseParams["identifycode"] +
                    "&previous=1" + "&aVarsParam=HTTP/1.1");
                logger.Info("http://fastmomi.fastweb.it/app/services/cfg-ngrg/RES-Bought.php?" + sb.ToString());
                PostHttp(wc, "http://fastmomi.fastweb.it/app/services/cfg-ngrg/RES-Bought.php?", sb.ToString());

                // per ora non scriviamo la risposta
                //logger.Info(response);
                //File.WriteAllText("response.html", response);

                Dictionary <string, string> dic = GetComputersFromHtml(wc);
                string mymac = dic[GetIpAddress()];

                wc.responseParams["pmaction"] = "UPDATE";
                //wc.responseParams["ipCpe"]; //gia assegnato
                wc.responseParams["ID"]             = ""; //chissa' che cosa e'
                wc.responseParams["ExternalPort"]   = EmuleAdunanzaGetTcpPort();
                wc.responseParams["InternalPort"]   = EmuleAdunanzaGetTcpPort();
                wc.responseParams["Protocol"]       = "TCP";
                wc.responseParams["InternalClient"] = GetIpAddress();
                wc.responseParams["Description"]    = "AdunanzA TCP";
                wc.responseParams["Chaddr"]         = mymac;

                StringBuilder sb2 = new StringBuilder(
                    "pmaction=" + wc.responseParams["pmaction"] +
                    "&ipCpe=" + wc.responseParams["ipCpe"] +
                    "&ID=" +
                    "&ExternalPort=" + wc.responseParams["ExternalPort"] +
                    "&InternalPort=" + wc.responseParams["InternalPort"] +
                    "&Protocol=" + wc.responseParams["Protocol"] +
                    "&InternalClient=" + wc.responseParams["InternalClient"] +
                    "&Description=" + wc.responseParams["Description"] +
                    "&Chaddr=" + wc.responseParams["Chaddr"]
                    );
                //"pmaction=UPDATE&ipCpe=10.45.43.222&ID=&ExternalPort=7002&InternalPort=7002&Protocol=TCP&InternalClient=192.168.1.129&Description=&Chaddr=4c:ed:de:e8:7e:73";
                var response = wc.UploadString("http://fastmomi.fastweb.it/app/services/cfg-ngrg/Ajax_writePortMapping.php", "POST", sb2.ToString());

                //logger.Info(response);

                if (wc._responseUri.ToString().Contains("esito") && wc._responseUri.ToString().Contains("OK"))
                {
                    logger.Info("Procedura apertura porte Manuale avvenuta con successo!");
                    return(true);
                }
                else
                {
                    logger.Error("Procedura apertura porte Manuale Fallita.");
                    return(false);
                }
            }
            else
            {
                logger.Info("Procedura apertura porte automatica Fallita.");
                return(false);
            }
        }
Example #4
0
        public static bool MFPManual(MyWebClient wc)
        {
            // Se siamo nella pagina giusta procedo alla costruzione della POST finale
            if (wc.responseParams.ContainsKey("identifycode"))
            {
                StringBuilder sb = new StringBuilder(
                "current=2" +
                "&step=3" +
                "&ctrl=" +
                "&portmap_action=manual_setup" +
                "&channel=" + wc.responseParams["channel"] +
                "&account=" + wc.responseParams["account"] +
                "&username="******"username"] +
                "&service=" + wc.responseParams["service"] +
                "&actionid=" +
                "&status=" + wc.responseParams["status"] +
                "&segmento=" + wc.responseParams["segmento"] +
                "&selcode=" + wc.responseParams["selcode"] +
                "&origin=" + wc.responseParams["origin"] +
                "&checksum=" + wc.responseParams["checksum"] +
                "&identifycode=" + wc.responseParams["identifycode"] +
                "&previous=1" + "&aVarsParam=HTTP/1.1");
                logger.Info("http://fastmomi.fastweb.it/app/services/cfg-ngrg/RES-Bought.php?" + sb.ToString());
                PostHttp(wc, "http://fastmomi.fastweb.it/app/services/cfg-ngrg/RES-Bought.php?", sb.ToString());

                // per ora non scriviamo la risposta
                //logger.Info(response);
                //File.WriteAllText("response.html", response);

                Dictionary<string, string> dic = GetComputersFromHtml(wc);
                string mymac = dic[GetIpAddress()];

                wc.responseParams["pmaction"] = "UPDATE";
                //wc.responseParams["ipCpe"]; //gia assegnato
                wc.responseParams["ID"] = ""; //chissa' che cosa e'
                wc.responseParams["ExternalPort"] = EmuleAdunanzaGetTcpPort();
                wc.responseParams["InternalPort"] = EmuleAdunanzaGetTcpPort();
                wc.responseParams["Protocol"] = "TCP";
                wc.responseParams["InternalClient"] = GetIpAddress();
                wc.responseParams["Description"] = "AdunanzA TCP";
                wc.responseParams["Chaddr"] = mymac;

                StringBuilder sb2 = new StringBuilder(
                "pmaction=" + wc.responseParams["pmaction"] +
                "&ipCpe=" + wc.responseParams["ipCpe"] +
                "&ID=" +
                "&ExternalPort=" + wc.responseParams["ExternalPort"] +
                "&InternalPort=" + wc.responseParams["InternalPort"] +
                "&Protocol=" + wc.responseParams["Protocol"] +
                "&InternalClient=" + wc.responseParams["InternalClient"] +
                "&Description=" + wc.responseParams["Description"] +
                "&Chaddr=" + wc.responseParams["Chaddr"]
                );
                //"pmaction=UPDATE&ipCpe=10.45.43.222&ID=&ExternalPort=7002&InternalPort=7002&Protocol=TCP&InternalClient=192.168.1.129&Description=&Chaddr=4c:ed:de:e8:7e:73";
                var response = wc.UploadString("http://fastmomi.fastweb.it/app/services/cfg-ngrg/Ajax_writePortMapping.php", "POST", sb2.ToString());

                //logger.Info(response);

                if (wc._responseUri.ToString().Contains("esito") && wc._responseUri.ToString().Contains("OK"))
                {
                    logger.Info("Procedura apertura porte Manuale avvenuta con successo!");
                    return true;
                }
                else
                {
                    logger.Error("Procedura apertura porte Manuale Fallita.");
                    return false;
                }
            }
            else
            {
                logger.Info("Procedura apertura porte automatica Fallita.");
                return false;
            }
        }