Machine-Learning-Web-Application-Firewall-and-Dataset icon indicating copy to clipboard operation
Machine-Learning-Web-Application-Firewall-and-Dataset copied to clipboard

maybe i found some bugs in function get2Grams and get3Grams

Open wha000tif opened this issue 8 years ago • 0 comments
trafficstars

the raw code:

def get2Grams(payload_obj):
    '''Divides a string into 2-grams
    
    Example: input - payload: "<script>"
             output- ["<s","sc","cr","ri","ip","pt","t>"]
    '''
    payload = str(payload_obj)
    ngrams = []
    for i in range(0,len(payload)-2):
        ngrams.append(payload[i:i+2])
    return ngrams

def get3Grams(payload_obj):
    '''Divides a string into 3-grams
    
    Example: input - payload: "<script>"
             output- ["<sc","scr","cri","rip","ipt","pt>"]
    '''
    payload = str(payload_obj)
    ngrams = []
    for i in range(0,len(payload)-3):
        ngrams.append(payload[i:i+3])
    return ngrams

I think it should be "for i in range(0,len(payload)-1)" and "for i in range(0,len(payload)-2)" i have try run the script when i in range(0, len(a)-2).and the item "t>"do not in the grams list.

wha000tif avatar Nov 06 '17 12:11 wha000tif