Machine-Learning-Web-Application-Firewall-and-Dataset
Machine-Learning-Web-Application-Firewall-and-Dataset copied to clipboard
maybe i found some bugs in function get2Grams and get3Grams
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.