public static bool loadWafRule(this O2_Web_Proxy o2WebProxy, string wafRuleFile)
 {
     return(o2WebProxy.loadWafRule(wafRuleFile, false));
 }
Beispiel #2
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);
        }