A quick example of detecting malicious XSS strings using kNN
training.txt contains the training data. The main-function then asks the user for an input, to which it will determine whether the string is malicious or not.
Made with Python.
hello<script>alert(${document.cookie})</script><IMG SRC=javascript:alert('XSS')>