public static O2_Web_Proxy add_WebProxy(this Control panel)
        {
            var o2WebProxy = new O2_Web_Proxy().createGui_Proxy_SimpleView(panel);

            o2WebProxy.startWebProxy();
            return(o2WebProxy);
        }
        public static Panel show_WebProxyGui(this O2_Web_Proxy o2WebProxy)
        {
            var topPanel = "O2 Web Proxy".popupWindow(300, 400);

            o2WebProxy.createGui_Proxy_SimpleView(topPanel);
            return(topPanel);
        }
Ejemplo n.º 3
0
		public static O2_Web_Proxy get_WebProxy(this string url)
		{
			var o2WebProxy = new O2_Web_Proxy();
			o2WebProxy.startWebProxy();
			url.html();
			return o2WebProxy;
		}
        public static O2_Web_Proxy get_WebProxy(this string url)
        {
            var o2WebProxy = new O2_Web_Proxy();

            o2WebProxy.startWebProxy();
            url.html();
            return(o2WebProxy);
        }
Ejemplo n.º 5
0
        public static O2_Web_Proxy setBrowserProxy(this O2_Web_Proxy o2WebProxy)
        {
            var proxyLocation = o2WebProxy.proxyLocation();

            "setting proxy location to: {0}".info(proxyLocation);
            API_WinProxy.SetProxy(proxyLocation);
            return(o2WebProxy);
        }
Ejemplo n.º 6
0
 public static bool startWebProxy(this O2_Web_Proxy o2WebProxy)
 {
     if (o2WebProxy.Proxy.ProxyStarted)
     {
         "There was already a proxy started so reusing exising proxy object and port".info();
         return(true);
     }
     //if (o2WebProxy.Port == o2WebProxy.DEFAULT_PORT)
     o2WebProxy.Port = o2WebProxy.DEFAULT_PORT + 1000.randomNumber();
     return(o2WebProxy.startWebProxy(o2WebProxy.Port));
 }
        public static bool loadWafRule(this O2_Web_Proxy o2WebProxy, string wafRuleFile, bool logCallBacks)
        {
            if (wafRuleFile.fileExists().isFalse())
            {
                wafRuleFile = wafRuleFile.local();
            }
            if (wafRuleFile.fileExists().isFalse())
            {
                "[O2_Web_Proxy] in loadWafRule, could not find rule file: {0}".error(wafRuleFile);
            }
            else
            {
                "[O2_Web_Proxy]: loading Waf Rule file: {0}".info(wafRuleFile);
                //var assembly = new O2.DotNetWrappers.DotNet.CompileEngine().compileSourceFile(ruleToLoad);
                var assembly = wafRuleFile.compile();
                if (assembly.isNull())
                {
                    "failed to compiled rule: {0}".error(wafRuleFile);
                }
                else
                {
                    "[O2_Web_Proxy]: Compiled ok".info();
                    var ruleType = assembly.type(wafRuleFile.fileName_WithoutExtension());
                    if (ruleType.isNull())
                    {
                        "failed to find type: {0}".error(wafRuleFile.fileName_WithoutExtension());
                    }
                    else
                    {
                        "[O2_Web_Proxy]: Found rule type ok".info();
                        o2WebProxy.WafRule = ruleType.ctor();
                        o2WebProxy.WafRule.prop("LogCallbacks", logCallBacks);
                        "[O2_Web_Proxy]: Rule Loaded".info();
                        //setWafRuleLinkViewerCallback();
                        //browserPanel.set_Text("Browser with rule loaded: {0}".format(ruleToLoad.fileName_WithoutExtension()));

                        ProxyServer.InterceptWebRequest = (webRequest) => { o2WebProxy.WafRule.invoke("InterceptWebRequest", webRequest); };
                        //ProxyServer.OnResponseReceived        = (requestResponseData)=>                   { o2WebProxy.WafRule.invoke("InterceptOnResponseReceived", requestResponseData);};
                        ProxyServer.InterceptRemoteUrl    = (remoteUrl) => { return((string)o2WebProxy.WafRule.invoke("InterceptRemoteUrl", remoteUrl)); };
                        ProxyServer.InterceptResponseHtml = (uri) => { return((bool)o2WebProxy.WafRule.invoke("InterceptResponseHtml", uri)); };
                        ProxyServer.HtmlContentReplace    = (uri, content) => { return((string)o2WebProxy.WafRule.invoke("HtmlContentReplace", uri, content)); };

                        return(true);
                    }
                }
                //var wafRule = "WAF_Rule.cs".local().compile().types()[0].ctor();
                //WafRule.o2WebProxy = wafRuleFile.compile().type("fileName_WithoutExtension").ctor();
                //object wafRuleObject =    "WAF_Rule_NoPorto.cs".local().compile().types()[0].ctor();
            }
            //setWafRuleLinkViewerCallback();
            return(false);
        }
Ejemplo n.º 8
0
 public static bool startWebProxy(this O2_Web_Proxy o2WebProxy, int port)
 {
     o2WebProxy.Port = port;
     ProxyServer.Server.ListeningPort = o2WebProxy.Port;
     o2WebProxy.setBrowserProxy();
     if (ProxyServer.Server.Start(o2WebProxy.CertLocation))
     {
         "Proxy started Ok on ip:port: {0}".info(o2WebProxy.proxyLocation());
         return(true);
     }
     "Proxy failed to start on ip:port: {0}".error(o2WebProxy.proxyLocation());
     return(false);
 }
Ejemplo n.º 9
0
        public static Panel add_Proxy_ActionsPanel(this O2_Web_Proxy o2WebProxy, Control topPanel)
        {
            var actionsPanel = topPanel.insert_Above(40, "actions");

            actionsPanel.add_Label("O2 Proxy")
            .append_Link("View Proxy Object", () => o2WebProxy.details())
            .append_Link("Proxy Start", () => o2WebProxy.startWebProxy())
            .append_Link("Proxy Stop", () => o2WebProxy.stopWebProxy())
            .append_Link("Set Browser Proxy", () => o2WebProxy.setBrowserProxy())
            .append_Link("Clear Browser Proxy", () => o2WebProxy.clearBrowserProxy())
            .append_Link("Stop Current Process", () => Processes.getCurrentProcess().stop());
            return(actionsPanel);
        }
Ejemplo n.º 10
0
 public static O2_Web_Proxy stopWebProxy(this O2_Web_Proxy o2WebProxy)
 {
     try
     {
         o2WebProxy.clearBrowserProxy();
         "Stopping Web Proxy".info();
         ProxyServer.Server.Stop();
     }
     catch (Exception ex)
     {
         "[O2_Web_Proxy] stopWebProxy : {0}".error(ex.Message);
     }
     return(o2WebProxy);
 }
Ejemplo n.º 11
0
        //createGui_Proxy_LargeView
        public static O2_Web_Proxy createGui_Proxy_LargeView(this O2_Web_Proxy o2WebProxy, Control panel)
        {
            var topPanel = panel.clear().add_Panel();

            topPanel.insert_LogViewer();
            o2WebProxy.stopOnFormClose(topPanel)
            .add_Proxy_ActionsPanel(topPanel)
            .add_Proxy_ToolsPanel();

            var requestsList       = topPanel.add_GroupBox("Requests List").add_TreeView();
            var requestDetails     = topPanel.insert_Right();
            var requestProperties  = requestDetails.add_GroupBox("Request details").add_PropertyGrid().helpVisible(false);
            var responseProperties = requestDetails.insert_Right("Response details").add_PropertyGrid().helpVisible(false);
            var requestData        = requestProperties.insert_Below(100, "Request Data").add_TextArea();
            var responseData       = responseProperties.insert_Below(100, "Response Data").add_SourceCodeViewer();

            responseData.textEditorControl().fill().bringToFront();


            requestsList.add_ContextMenu()
            .add_MenuItem("clear list", false, () => requestsList.clear());

            ProxyServer.OnResponseReceived = (requestResponseData) => requestsList.add_Node(requestResponseData);

            requestsList.afterSelect <RequestResponseData>(
                (requestResponseData) => {
                requestProperties.show(requestResponseData.WebRequest);
                responseProperties.show(requestResponseData.WebResponse);
                responseData.set_Text(requestResponseData.Response_String);
                requestData.set_Text(requestResponseData.Request_PostString);
            });
            requestsList.onDoubleClick <RequestResponseData>(
                (requestResponseData) => {
                "showing requestResponseData details".info();
                requestResponseData.details();
                "done".debug();
            });

            return(o2WebProxy);
        }
 public static bool loadWafRule(this O2_Web_Proxy o2WebProxy, string wafRuleFile)
 {
     return(o2WebProxy.loadWafRule(wafRuleFile, false));
 }
Ejemplo n.º 13
0
 public static O2_Web_Proxy clearBrowserProxy(this O2_Web_Proxy o2WebProxy)
 {
     "remove proxy proxy settings (ie setting it to \"\"".info();
     API_WinProxy.SetProxy("");
     return(o2WebProxy);
 }
 public static string google(this O2_Web_Proxy o2WebProxy)
 {
     return("http://www.google.com".get_Html());
 }
Ejemplo n.º 15
0
 public static O2_Web_Proxy extraLogging(this O2_Web_Proxy o2WebProxy, bool value)
 {
     ProxyServer.ExtraLogging = value;
     return(o2WebProxy);
 }
Ejemplo n.º 16
0
 public static O2_Web_Proxy extraLogging(this O2_Web_Proxy o2WebProxy)
 {
     return(o2WebProxy.extraLogging(true));
 }
 public static ProxyCache proxyCache(this O2_Web_Proxy o2WebProxy)
 {
     return(ProxyServer.proxyCache);
 }
Ejemplo n.º 18
0
        public static O2_Web_Proxy createGui_Proxy_SimpleView(this O2_Web_Proxy o2WebProxy, Control panel)
        {
            var topPanel = panel.clear().add_Panel();

            //topPanel.insert_LogViewer();
            o2WebProxy.stopOnFormClose(topPanel);
            var actions_Panel = topPanel.insert_Above(40, "");
            var requests      = topPanel.add_GroupBox("Requests").add_TableList().title("O2 Web Proxy");
            var properties    = requests.insert_Below(100, "Request & Response Object").add_PropertyGrid()
                                .helpVisible(false)
                                .toolBarVisible(false);
            //actions_Panel.insert_Right(40).add_Proxy_ToolsPanel();
            var showLiveRequests = false;

            var requestId = 0;

            requests.add_Columns("#", "Method", "Status", "Size", "Url");

            Action setColumnsWidth = () => requests.set_ColumnsWidth(30, 60, 60);

            setColumnsWidth();

            requests.onDoubleClick <RequestResponseData>(
                (requestResponseData) => {
                var responseCode = "Html for: {0}".format(requestResponseData.Request_Uri)
                                   .popupWindow()
                                   .add_GroupBox("Response Data")
                                   .add_SourceCodeViewer().maximizeViewer()
                                   .set_Text(requestResponseData.Response_String, ".html");
                if (requestResponseData.Request_PostString.valid())
                {
                    responseCode.parent()
                    .insert_Above(200, "Request Post Data")
                    .add_SourceCodeViewer().maximizeViewer()
                    .set_Text(requestResponseData.Request_PostString, ".html");
                }
            });

            Action <RequestResponseData> add_Row =
                (rrData) => {
                requests.add_Row(rrData,
                                 () => {
                    var rowData = new List <string>()
                    {
                        (++requestId).str(),
                        rrData.WebRequest.Method.str(),
                        rrData.WebResponse.StatusCode.str(),
                        rrData.Response_String.size().str(),
                        rrData.WebRequest.RequestUri.str()
                    };
                    return(rowData);
                });
            };

            requests.afterSelect <RequestResponseData>(
                (requestResponseData) => {
                properties.show(requestResponseData);
            });

            Action showPastRequests =
                () => {
                requests.clearRows();
                requests.title("Showing {0} web Requests".format(o2WebProxy.Proxy.requests().size()));
                foreach (var request in o2WebProxy.Proxy.requests())
                {
                    add_Row(request);
                }
                requests.setWidthToContent();
            };

            Action copySelectedUtlToClipboard =
                () => {
                var selected = requests.selected <RequestResponseData>();
                if (selected.notNull())
                {
                    selected.Request_Uri.str().clipboardText_Set();
                }
            };

            ProxyServer.OnResponseReceived =
                (requestResponseData) => add_Row(requestResponseData);

            requests.add_ContextMenu().add_MenuItem("Copy Utl to clipboard", true, () => copySelectedUtlToClipboard())
            .add_MenuItem("See Selected Row RequestResponseData Object Details", true, () => requests.tag().details())
            .add_MenuItem("Refresh request list ({0} at start)".format(o2WebProxy.Proxy.requests().size()), true, () => showPastRequests())
            .add_MenuItem("Clear list", true, () => requests.clearRows())
            .add_MenuItem("Reset Columns Width", () => { setColumnsWidth(); setColumnsWidth(); });

            actions_Panel.add_Label("Actions:")
            .append_Link("Proxy Start", () => o2WebProxy.startWebProxy())
            .append_Link("Proxy Stop", () => o2WebProxy.stopWebProxy())
            .append_CheckBox("Real-Time View", (value) => showLiveRequests        = value).@check()
            .append_CheckBox("Extra logging", (value) => ProxyServer.ExtraLogging = value);


            actions_Panel.add_Label("Test sites:", 20, 0)
            .append_Link("BBC", () => "http://news.bbc.co.uk".get_Html())
            .append_Link("OWASP", () => "http://www.owasp.org".get_Html())
            .append_Link("google", () => "http://www.google.com".get_Html())
            .append_Label("O2 Utils")
            .append_Link("O2 Log Viewer", () => "O2 Log Viewer".popupWindow().add_LogViewer());
            return(o2WebProxy);
        }
Ejemplo n.º 19
0
 public static O2_Web_Proxy stopOnFormClose(this O2_Web_Proxy o2WebProxy, Control topPanel)
 {
     topPanel.onClosed(() => o2WebProxy.stopWebProxy());
     return(o2WebProxy);
 }
Ejemplo n.º 20
0
        //createGui_WAF
        public static O2_Web_Proxy createGui_WAF <T>(this O2_Web_Proxy o2WebProxy, T panel)
            where T : Control
        {
            var topPanel = panel.clear().add_Panel();

            topPanel.insert_LogViewer();

            o2WebProxy.stopOnFormClose(topPanel)
            .add_Proxy_ActionsPanel(panel)
            .add_Proxy_ToolsPanel();


            //var actionsPanel = topPanel.insert_Above(40,"actions");
            //var toolsPanel = actionsPanel.parent().insert_Right("tools");
            var browserPanel     = topPanel.add_GroupBox("Browser");
            var browser          = browserPanel.add_WebBrowser_Control().add_NavigationBar();
            var httpData         = topPanel.insert_Right(200).add_TreeView();
            var sourceCodeViewer = httpData.insert_Below().add_SourceCodeViewer();
            var rules            = topPanel.insert_Left(400, "WAF Rules").add_TreeView();

            httpData.add_ContextMenu()
            .add_MenuItem("clear list", false, () => httpData.clear());
            //.add_MenuItem("Write Script on ;

            httpData.afterSelect <RequestResponseData>(
                (requestResponseData) => {
                //requestResponseData.str().debug();
                //show.info(requestResponseData.WebResponse);
                //show.info(requestResponseData.WebRequest);
                //"Content for {0} with size {1}".info(requestResponseData, htmlContent.size());
                //htmlContent.info();
                sourceCodeViewer.set_Text(requestResponseData.Response_String, ".html");
            });
//O2File:_Extra_methods_WinForms_Controls.cs
//O2File:Scripts_ExtensionMethods.cs

/*			httpData.onDoubleClick<RequestResponseData>(
 *                              (requestResponseData)=> {
 *                                                                                      "RequestResponseData".popupWindow()
 *                                                                                                                              .add_Script(false)
 *                                                                                                                              .InvocationParameters.Add("bytes",requestResponseData.ResponseBytes);
 *                                                                              });
 */
/*			Action setWafRuleLinkViewerCallback =
 *                                              ()=>{
 *                                                              Action<HttpWebRequest,HttpWebResponse, string> onRequestReceived =
 *                                                                      (webRequest, webResponse, htmlContent)=>
 *                                                                              links.add_Node(webRequest.RequestUri.str(),htmlContent );
 *
 *                                                              o2WebProxy.WafRule.prop("OnRequestReceived" , onRequestReceived);
 *                                                      };
 */
            ProxyServer.OnResponseReceived = (requestResponseData) => httpData.add_Node(requestResponseData);
            Action <string> loadWafRule =
                (wafRuleFile) => {
                O2Thread.mtaThread(
                    () => {
                    if (o2WebProxy.loadWafRule(wafRuleFile))
                    {
                        browserPanel.set_Text("Loaded Rule: {0}".format(wafRuleFile.fileName()));
                    }
                    //setWafRuleLinkViewerCallback();
                });
            };

            rules.onDrop(
                (fileOrFolder) => {
                if (fileOrFolder.fileExists())
                {
                    rules.add_File(fileOrFolder);
                }
                else
                {
                    rules.clear();
                    rules.add_Files(fileOrFolder);
                }
            });

            rules.add_ContextMenu().add_MenuItem("Edit Rule", () => (rules.selected().get_Tag() as String).showInCodeEditor());

            rules.add_Files("WAF_Rule_NoGoogle.cs".local().directoryName().files("WAF*.cs"));
            //rules.add_Node("WAF_Rule_NoPorto.cs", "WAF_Rule_NoPorto.cs".local());

            o2WebProxy.loadWafRule("WAF_Rule.cs", true);

            /*actionsPanel.add_Label("O2 Proxy")
             *                      .append_Link("Proxy Start", ()=> o2WebProxy.startWebProxy())
             *                      .append_Link("Proxy Stop",  ()=> o2WebProxy.stopWebProxy())
             *                      .append_Link("Set Browser Proxy",  ()=> o2WebProxy.setBrowserProxy())
             *                      .append_Link("Clear Browser Proxy",  ()=> o2WebProxy.clearBrowserProxy())
             *                      .append_Link("Stop Current Process", ()=> Processes.getCurrentProcess().stop());
             */


            /*toolsPanel.add_Link("Javascript Format (and Beautify)", ()=> "Util - Javascript Format (and Beautify).h2".local().executeH2Script())
             *                .append_Link("Web Encoding and Decoding",		()=> "Util - Web Encoder (with AntiXss Support).h2".local().executeH2Script());
             */
            ;

            rules.afterSelect <string>  (loadWafRule);
            rules.onDoubleClick <string>(loadWafRule);            //(file) => { o2WebProxy.loadWafRule(file); setWafRuleLinkViewerCallback(); } );
            //setWafRuleLinkViewerCallback();
            return(o2WebProxy);
        }
Ejemplo n.º 21
0
		public static O2_Web_Proxy add_WebProxy(this Control panel)
		{			
			var o2WebProxy = new O2_Web_Proxy().createGui_Proxy_SimpleView(panel);
			o2WebProxy.startWebProxy();			
			return o2WebProxy;
		}
Ejemplo n.º 22
0
 public static string proxyLocation(this O2_Web_Proxy o2WebProxy)
 {
     return("http://{0}:{1}".format(o2WebProxy.IP, o2WebProxy.Port));
 }
 public static O2_Web_Proxy clearRequests(this O2_Web_Proxy o2WebProxy)
 {
     o2WebProxy.requests().Clear();
     return(o2WebProxy);
 }
 public static List <RequestResponseData> requests(this O2_Web_Proxy o2WebProxy)
 {
     return(o2WebProxy.Proxy.requests());
 }