Exemplo n.º 1
0
        /*
         *
         *
         */
        public static HTTPRedirect getInstance()
        {
            if (cInstance == null)
            cInstance = new HTTPRedirect();

              return (cInstance);
        }
Exemplo n.º 2
0
        /*
         *
         *
         */
        public static HTTPRedirect getInstance()
        {
            if (cInstance == null)
            {
                cInstance = new HTTPRedirect();
            }

            return(cInstance);
        }
Exemplo n.º 3
0
        /*
         *
         *
         */
        private static void DoHttpsProcessing(String pSrcMAC, String pSrcIP, String pSrcPort, Stream pClientStream)
        {
            //      Stream lClientStream = client.GetStream();
            Stream       lOutStream          = pClientStream;
            StreamReader lClientStreamReader = new StreamReader(pClientStream);

            String[]  lReqSplitBuffer;
            String    lMethod      = String.Empty;
            String    lRemoteURI   = String.Empty;
            String    lURL         = String.Empty;
            Version   lVersion     = new Version(1, 0);
            int       lContentLen  = 0;
            String    lHTTPData    = String.Empty;
            String    lHTTPCommand = String.Empty;
            String    lLine        = String.Empty;
            String    lTmpStr      = String.Empty;
            String    lTmpBuf      = String.Empty;
            Hashtable lHeaders     = new Hashtable();

            try
            {
                // Read the first line HTTP command
                lHTTPCommand = lClientStreamReader.ReadLine();

                /*
                 * Header corrupted. Stop thread execution.
                 */
                if (String.IsNullOrEmpty(lHTTPCommand))
                {
                    lClientStreamReader.Close();
                    pClientStream.Close();

                    return;
                }


                /*
                 * Break up the line into three components
                 */
                lReqSplitBuffer = lHTTPCommand.Split(lSpaceSplit, 3);
                lMethod         = lReqSplitBuffer[0];
                lRemoteURI      = lReqSplitBuffer[1];
                lURL            = String.Empty;

                // Read the request headers from the client and copy them to our request
                lContentLen = ReadRequestHeaders(lClientStreamReader, ref lHeaders);

                // Build the URI
                if (lHeaders != null && lHeaders.ContainsKey("host") && lHeaders["host"].ToString().Length > 0)
                {
                    lURL = string.Format("https://{0}:{1}{2}", lHeaders["host"].ToString(), cRemotePort, lRemoteURI);
                }
                else
                {
                    lURL = string.Format("https://{0}:{1}{2}", cRemoteHost, cRemotePort, lRemoteURI);
                }


                /*
                 * Redirect URL
                 */
                if (!String.IsNullOrEmpty(cRedirectURL) && lMethod.ToLower() == "get")
                {
                    HTTPRedirect.getInstance().processRequest(lOutStream, cRedirectURL, lHeaders);


                    /*
                     * Process HTTP request
                     */
                }
                else
                {
                    // StreamReader pClientStreamReader, Stream pOutStream, String pMethod, String pURL, Hashtable pHeaders, int pContentLen, String pHTTPCommand, String pPOSTData
                    HTTPProxy.getInstance().processRequest(lClientStreamReader, lOutStream, lMethod, lURL, lHeaders, lContentLen, lHTTPCommand, out lHTTPData);

                    String lPipeData = String.Format("TCP||{0}||{1}||{2}||{3}||{4}||{5}\r\n", pSrcMAC, pSrcIP, pSrcPort, cRemoteIP, cRemotePort, lHTTPData);
                    Program.WriteToPipe(lPipeData);

                    if (Program.cDebuggingOn)
                    {
                        Console.WriteLine(lPipeData.TrimEnd());
                    }
                } // if (!String.IsNullOrEmpty(cR...
            }
            catch (Exception lEx)
            {
                if (Program.cDebuggingOn)
                {
                    Console.WriteLine(String.Format("ERROR: {0}\r\n{1}", lEx.Message, lEx.StackTrace));
                }

                return;
            }
            finally
            {
                if (lClientStreamReader != null)
                {
                    lClientStreamReader.Close();
                }

                if (pClientStream != null)
                {
                    pClientStream.Close();
                }

                if (lOutStream != null)
                {
                    lOutStream.Close();
                }
            }
        }