Exemplo n.º 1
0
        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;
        }
        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);
        }