Ejemplo n.º 1
0
        private MyWebClient PostHttp(MyWebClient wc, string baseUrl, string paramConcat)
        {
            wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            response = wc.UploadString(baseUrl, paramConcat);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(Environment.NewLine + "Scaricata prima pagina: {0}", BaseURI);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("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;
                Console.WriteLine("Cookie: {0}", cookie);
            }
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Redirect Location: {0}", wc._responseUri);

            foreach (var param in wc.responseParams)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Fragment: {0} = {1}", param.Key, param.Value);
            }
            return(wc);
        }
Ejemplo n.º 2
0
        private void ManualSetup()
        {
            // 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");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("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());
                Console.ReadKey();
                // per ora non scriviamo la risposta
                //Console.WriteLine(response);
                //File.WriteAllText("response.html", response);

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

                wc.responseParams["pmaction"] = "UPDATE";
                //wc.responseParams["ipCpe"]; //gia assegnato
                wc.responseParams["ID"]             = ""; //chissa' che cosa e'
                wc.responseParams["ExternalPort"]   = GetEmuleAdunanzATcpPort();
                wc.responseParams["InternalPort"]   = GetEmuleAdunanzATcpPort();
                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";
                response = wc.UploadString("http://fastmomi.fastweb.it/app/services/cfg-ngrg/Ajax_writePortMapping.php", "POST", sb2.ToString());

                Console.WriteLine(response);
                Console.WriteLine("Premere un tasto per la POST di apertura porte");
                Console.ReadKey();

                // SIAMO QUI
                if (wc._responseUri.ToString().Contains("esito") && wc._responseUri.ToString().Contains("OK"))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Procedura apertura porte automatica avvenuta con successo!");

                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine("Il tuo indirizzo IP esterno e' :" + GetIpAddressExt());
                    Console.WriteLine("Il tuo indirizzo IP interno e' :" + GetIpAddress() + Environment.NewLine);
                    Console.ForegroundColor = ConsoleColor.Red;

                    Console.WriteLine("Usa le seguenti porte con eMule AdunanzA inserendole in Opzioni -> Connessione");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("TCP: " + GetTcpPortToUse(GetIpAddress()));
                    Console.WriteLine("UDP: " + GetUdpPortToUse(GetIpAddress()));
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Procedura apertura porte automatica Fallita.");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Procedura apertura porte automatica Fallita.");
                Console.ForegroundColor = ConsoleColor.Gray;
            }
        }
Ejemplo n.º 3
0
        private MyWebClient PostHttp(MyWebClient wc, string baseUrl, string paramConcat)
        {
            wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            response = wc.UploadString(baseUrl, paramConcat);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(Environment.NewLine + "Scaricata prima pagina: {0}", BaseURI);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("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;
                Console.WriteLine("Cookie: {0}", cookie);
            }
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Redirect Location: {0}", wc._responseUri);

            foreach (var param in wc.responseParams)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Fragment: {0} = {1}", param.Key, param.Value);
            }
            return wc;
        }