Package org.owasp.webscarab.model

Examples of org.owasp.webscarab.model.HttpUrl


    public String getStatus() {
        return _model.getStatus();
    }
   
    public void analyse(ConversationID id, Request request, Response response, String origin) {
        HttpUrl base = request.getURL();
        if (response.getStatus().equals("302")) {
            String location = response.getHeader("Location");
            if (location != null) {
                try {
                    HttpUrl url = new HttpUrl(base, location);
                    _model.addUnseenLink(url, base);
                } catch (MalformedURLException mue) {
                    _logger.warning("Badly formed Location header : " + location);
                }
            } else {
View Full Code Here


    }
   
    private void processLink(HttpUrl base, String link) {
        if (link.startsWith("http://") || link.startsWith("https://")) {
            try {
                HttpUrl url = new HttpUrl(link);
                _model.addUnseenLink(url, base);
            } catch (MalformedURLException mue) {
                _logger.warning("Malformed link : " + link);
            }
        } else if (link.toLowerCase().startsWith("mailto:")) {
            // do nothing
        } else if (link.toLowerCase().startsWith("javascript:")) {
            processScript(base, link.substring(10));
        } else if (link.matches("^[a-zA-Z]+://.*")) {
            _logger.info("Encountered an unhandled url scheme " + link);
        } else {
            _logger.fine("Creating a new relative URL with " + base + " and " + link + " '");
            try {
                HttpUrl url = new HttpUrl(base, link);
                _model.addUnseenLink(url, base);
            } catch (MalformedURLException mue) {
                _logger.warning("Bad relative URL (" + base.toString() + ") : " + link);
            }
        }
View Full Code Here

        addColumn(cdm);
       
        cdm = new ColumnDataModel() {
            public Object getValue(Object key) {
                if (_model == null) return null;
                HttpUrl url = _model.getRequestUrl((ConversationID) key);
                return url.getScheme() + "://" + url.getHost() + ":" + url.getPort();
            }
            public String getColumnName() { return "Host"; }
            public Class getColumnClass() { return String.class; }
        };
        addColumn(cdm);
       
        cdm = new ColumnDataModel() {
            public Object getValue(Object key) {
                if (_model == null) return null;
                HttpUrl url = _model.getRequestUrl((ConversationID) key);
                return url.getPath();
            }
            public String getColumnName() { return "Path"; }
            public Class getColumnClass() { return String.class; }
        };
        addColumn(cdm);
       
        cdm = new ColumnDataModel() {
            public Object getValue(Object key) {
                if (_model == null) return null;
                HttpUrl url = _model.getRequestUrl((ConversationID) key);
                return url.getParameters();
            }
            public String getColumnName() { return "Parameters"; }
            public Class getColumnClass() { return String.class; }
        };
        addColumn(cdm);
View Full Code Here

    public static Request convertGetToPost(Request get) {
        if (!"GET".equals(get.getMethod()))
            throw new IllegalArgumentException("Request must be a GET, not a " + get.getMethod());
        Request post = new Request();
        post.setMethod("POST");
        HttpUrl url = get.getURL();
        String query = url.getQuery();
        if (query != null) {
            try {
                post.setContent(query.getBytes("ASCII"));
            } catch (UnsupportedEncodingException uee) {
                _logger.severe("Bizarre! " + uee.getLocalizedMessage());
                RuntimeException e = new IllegalArgumentException("Unknown ASCII encoding!");
                e.initCause(uee);
                throw e;
            }
            String s = url.toString();
            int q = s.indexOf('?');
            s = s.substring(0, q);
            try {
                post.setURL(new HttpUrl(s));
            } catch (MalformedURLException mue) {
                throw new RuntimeException("Couldn't extract the POST url!", mue);
            }
        } else {
            post.setURL(url);
View Full Code Here

        get.deleteHeader("Content-Length");
        String query = "";
        if (content != null) {
            query = new String(content);
            try {
                HttpUrl url = get.getURL();
                if (url.getQuery() != null) {
                    url = new HttpUrl(url.toString() + "&" + query);
                } else if (url.getQuery() == null) {
                    url = new HttpUrl(url.toString() + "?" + query);
                }
                get.setURL(url);
            } catch (MalformedURLException mue) {
                throw new RuntimeException("Couldn't construct the URL", mue);
            }
View Full Code Here

    }
   
    public static void main(String[] args) throws Exception {
        Request get = new Request();
        get.setMethod("GET");
        get.setURL(new HttpUrl("http://localhost/WebGoat/attack;fragment?a=1&b=nanana"));
        get.setVersion("HTTP/1.0");
        get.setHeader("Host", "localhost");
        System.out.println(get +"\r\n=============\r\n");
        Request post = convertGetToPost(get);
        System.out.println(post + "\r\n==============\r\n");
View Full Code Here

TOP

Related Classes of org.owasp.webscarab.model.HttpUrl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.