Changeset 410


Ignore:
Timestamp:
04/03/12 10:24:49 (12 years ago)
Author:
sherbold
Message:
  • improved detection of invalid sequences in de.ugoe.cs.eventbench.web.WeblogParser?
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/WeblogParser.java

    r363 r410  
    297297                                        String path = uri.getPath(); 
    298298                                        List<String> getVars = extractGetVarsFromUri(uri); 
    299  
     299                                         
    300300                                        WebEvent event = new WebEvent(url, path, timestamp, 
    301301                                                        postedVars, getVars); 
     
    446446         *            URI that is parsed 
    447447         * @return a list with all GET variables 
    448          */ 
    449         private List<String> extractGetVarsFromUri(URI uri) { 
     448         * @throws URISyntaxException 
     449         *             thrown if one of the variables seems to indicate that the 
     450         *             request is a malicious attack on the web application 
     451         */ 
     452        private List<String> extractGetVarsFromUri(URI uri) 
     453                        throws URISyntaxException { 
    450454                List<String> getVars = new ArrayList<String>(); 
    451455                String query = uri.getQuery(); 
     
    455459                                String[] paramSplit = paramPair.split("="); 
    456460                                if (!isBrokenVariable(paramSplit[0])) { 
     461                                        for (int i = 1; i < paramSplit.length; i++) { 
     462                                                checkForAttack(paramSplit[i]); 
     463                                        } 
    457464                                        getVars.add(paramSplit[0]); 
    458465                                } 
     
    473480         */ 
    474481        private boolean isBrokenVariable(String var) { 
    475                 // TODO improve filtering of broken variables 
    476482                return var.contains("and"); 
    477483        } 
     484 
     485        /** 
     486         * <p> 
     487         * Checks if the variable name send with a request seems like an attack on the server. 
     488         * </p> 
     489         * @param value 
     490         * @throws URISyntaxException 
     491         */ 
     492        private void checkForAttack(String value) throws URISyntaxException { 
     493                if (value.contains("UNION+") || value.contains("SELECT+")) { 
     494                        throw new URISyntaxException(value, "possible injection attack"); 
     495                } 
     496        } 
    478497} 
Note: See TracChangeset for help on using the changeset viewer.