Exemple #1
0
        public static List <IWebscarabConversation> loadConversationsFile(this API_WebScarab webScarab, string conversationFile)
        {
            var webScarabConversations = new List <IWebscarabConversation>();

            if (!File.Exists(conversationFile))
            {
                "Could not find webscarab conversation file: {0}".error(conversationFile);
            }
            else
            {
                List <string> fileLines = Files.getFileLines(conversationFile);
                string        requestAndResponseFiles = Path.Combine(Path.GetDirectoryName(conversationFile), "conversations");
                "There are {0} lines in the loaded file: {1}".info(fileLines.Count, conversationFile);
                IWebscarabConversation currentConversation = null;
                foreach (string line in fileLines)
                {
                    DictionaryEntry parsedLine = getParsedLine(line);
                    if (parsedLine.Key != null)
                    {
                        switch (parsedLine.Key.ToString())
                        {
                        case "### Conversation ":
                            if (currentConversation != null)
                            {
                                webScarabConversations.Add(currentConversation);
                            }
                            currentConversation    = new WebscarabConversation();
                            currentConversation.id = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "RESPONSE_SIZE":
                            currentConversation.RESPONSE_SIZE = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "WHEN":
                            currentConversation.WHEN = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "METHOD":
                            currentConversation.METHOD = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "COOKIE":
                            currentConversation.COOKIE = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "STATUS":
                            currentConversation.STATUS = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "URL":
                            currentConversation.URL = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "TAG":
                            currentConversation.TAG = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "ORIGIN":
                            currentConversation.ORIGIN = parsedLine.Value.ToString();
                            goto Label_039B;

                        case "XSS-GET":
                            currentConversation.XSS_GET.Add(parsedLine.Value.ToString());
                            goto Label_039B;

                        case "CRLF-GET":
                            currentConversation.CRLF_GET.Add(parsedLine.Value.ToString());
                            goto Label_039B;

                        case "SET-COOKIE":
                            currentConversation.SET_COOKIE.Add(parsedLine.Value.ToString());
                            goto Label_039B;

                        case "XSS-POST":
                            currentConversation.XSS_POST.Add(parsedLine.Value.ToString());
                            goto Label_039B;
                        }
                        "Key value not handled: {0} for {1}".error(parsedLine.Key.ToString(), parsedLine.Value.ToString());
                    }
Label_039B:
                    if (currentConversation != null)
                    {
                        currentConversation.request  = string.Format(@"{0}\{1}-request", requestAndResponseFiles, currentConversation.id);
                        currentConversation.response = string.Format(@"{0}\{1}-response", requestAndResponseFiles, currentConversation.id);
                    }
                }
            }
            return(webScarabConversations);
        }
        public static IO2Assessment createO2AssessmentFromWebScarabFile(string conversationFile)
        {
            var o2Assessment = new O2Assessment();

            try
            {
                o2Assessment.name = "Webscarab Import of: " + conversationFile;
                var webScarabConversations = new List <IWebscarabConversation>();
                if (false == File.Exists(conversationFile))
                {
                    DI.log.error("Could not find webscarab conversation file: {0}", conversationFile);
                }
                else
                {
                    var fileLines = Files.getFileLines(conversationFile);
                    var requestAndResponseFiles = Path.Combine(Path.GetDirectoryName(conversationFile), "conversations");
                    DI.log.info("There are {0} lines in the loaded file: {1}", fileLines.Count, conversationFile);
                    IWebscarabConversation currentConversation = null;
                    foreach (var line in fileLines)
                    {
                        var parsedLine = getParsedLine(line);
                        if (parsedLine.Key != null)
                        {
                            switch (parsedLine.Key.ToString())
                            {
                            case "### Conversation ":
                                if (currentConversation != null)
                                {
                                    webScarabConversations.Add(currentConversation);
                                }
                                currentConversation    = new WebscarabConversation();
                                currentConversation.id = parsedLine.Value.ToString();
                                //log.info("{0}   =  :  = {1} ", parsedLine.Key , parsedLine.Value);
                                break;

                            case "RESPONSE_SIZE":
                                currentConversation.RESPONSE_SIZE = parsedLine.Value.ToString();
                                break;

                            case "WHEN":
                                currentConversation.WHEN = parsedLine.Value.ToString();
                                break;

                            case "METHOD":
                                currentConversation.METHOD = parsedLine.Value.ToString();
                                break;

                            case "COOKIE":
                                currentConversation.COOKIE = parsedLine.Value.ToString();
                                break;

                            case "STATUS":
                                currentConversation.STATUS = parsedLine.Value.ToString();
                                break;

                            case "URL":
                                currentConversation.URL = parsedLine.Value.ToString();
                                break;

                            case "TAG":
                                currentConversation.TAG = parsedLine.Value.ToString();
                                break;

                            case "ORIGIN":
                                currentConversation.ORIGIN = parsedLine.Value.ToString();
                                break;

                            case "XSS-GET":
                                currentConversation.XSS_GET.Add(parsedLine.Value.ToString());
                                break;

                            case "CRLF-GET":
                                currentConversation.CRLF_GET.Add(parsedLine.Value.ToString());
                                break;

                            case "SET-COOKIE":
                                currentConversation.SET_COOKIE.Add(parsedLine.Value.ToString());
                                break;

                            case "XSS-POST":
                                currentConversation.XSS_POST.Add(parsedLine.Value.ToString());
                                break;

                            default:
                                DI.log.error("Key value not handled: {0} for {1}", parsedLine.Key.ToString(),
                                             parsedLine.Value.ToString());
                                break;
                            }
                        }


                        if (currentConversation != null)
                        {
                            currentConversation.request  = String.Format("{0}\\{1}-request", requestAndResponseFiles, currentConversation.id);
                            currentConversation.response = String.Format("{0}\\{1}-response", requestAndResponseFiles, currentConversation.id);
                        }
                    }
                }
                var o2Findings = createFindingsFromConversation(webScarabConversations);
                o2Assessment.o2Findings = o2Findings;
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "in createO2AssessmentFromWebScarabFile");
            }
            return(o2Assessment);
        }