Пример #1
0
    Spider.prototype.getResults = function() {
        var xssMarks = [];
        var failedPages = [];
        var jsErrors = [];
        var failedEvents = [];

        var page = null;
        for (var i = 0, count = this.pagesQueue.length; i < count; i++) {
            page = this.pagesQueue[i];
            if (!helper.isEmpty(page.jsErrors)) {
                page.jsErrors.forEach(function(item) {
                    jsErrors.push({
                        'url': this.url,
                        'error': item
                    })
                }, page);
            }

            if (!helper.isEmpty(page.xss)) {
                page.xss.forEach(function(item) {
                    xssMarks.push({
                        'url': this.url,
                        'xss': item
                    })
                }, page);
            }

            if (!helper.isEmpty(page.allEvents)) {
                page.allEvents.forEach(function(event) {
                    if (!helper.isEmpty(event.xss)) {
                        this.xss.forEach(function(xss) {
                            xssMarks.push({
                                'url': page.url,
                                'event': {
                                    'type': event.eventType,
                                    'path': event.path
                                },
                                'xss': xss
                            })
                        }, event);
                    }

                    if (event.status != 'completed') {
                        failedEvents.push(event);
                    }
                }, page);
            }
        }

        return {
            'xssMarks': xssMarks,
            'failedPages': failedPages,
            'jsErrors': jsErrors,
            'failedEvents': failedEvents
        }
    };
Пример #2
0
    Spider.prototype.initializeProperties = function(properties) {

        var defaults = {
            targetUri: 'test_content/index.html',
            maxEventDepth: 50,
            eventContainer: undefined, //'div#workarea'
            skipEventPath: '^id\\("(lhe_|lfm_)',
            singlePage: false,
            maxPages: 0
        };
        this.properties = utils.mergeObjects(defaults, properties);
        this.properties.targetHost = this.properties.targetUri.replace(/^(http[s]?:\/\/[^\/]+).*$/, '$1');
        if (this.properties.skipEventPath !== null)
            this.properties.skipEventPath = new RegExp(this.properties.skipEventPath, 'i');

        if (!this.properties.acceptableUrlPattern) {
            var escapedUri = helper.escapeRegExpPattern(this.properties.targetUri);
            var escapedDir = this.properties.targetUri.replace(/^(http[s]?:\/\/[^\/]+)(.*)$/, '$2');
            if (!escapedDir)
                escapedDir = '/';
            escapedDir = helper.escapeRegExpPattern(escapedDir);

            this.properties.acceptableUrlPattern = '^(?:' + escapedUri + '|' + escapedDir + '|\\?|[a-z_\\-]*\\.)';
            this.properties.acceptableUrlRegExp = new RegExp(this.properties.acceptableUrlPattern, 'i');
        }

        this.mouseEvents = {
            click: true,
            dblclick: true,
            mousedown: true,
            mousemove: true,
            mouseout: true,
            mouseover: true,
            mouseup: true
        };

        this.status = '';
        this.completed = false;

        this.pages = [new Page(this.properties.targetUri)];
        this.pagesQueue = IterifyArray([this.pages[0]]);

        this.networkActivity = 0;
        this.requestsIDs = [];
        this.reloadNeeded = false;
        this.reloaded = false;

        this.context = this.pages[0];
    };
Пример #3
0
                page.allEvents.forEach(function(event) {
                    if (!helper.isEmpty(event.xss)) {
                        this.xss.forEach(function(xss) {
                            xssMarks.push({
                                'url': page.url,
                                'event': {
                                    'type': event.eventType,
                                    'path': event.path
                                },
                                'xss': xss
                            })
                        }, event);
                    }

                    if (event.status != 'completed') {
                        failedEvents.push(event);
                    }
                }, page);
Пример #4
0
    PageEvent.prototype.addMultipleXss = function(xssArray) {
        if (helper.isEmpty(xssArray))
            return;

        xssArray.forEach(this.processNewXss, this);
    };