I have the following python script that gets values from a txt and construct a file with some needed values:
f = open("url-threatview.txt")
data = f.read().strip().split("\n")
f.close()
for line in data:
protocol,null,hostport,*url = line.split("/")
uri = "/".join(url)
host,*port = hostport.split(":")
def makerule(host,port,uri):
return 'alert http any %s -> any any (http.host;content:"%s";http.uri;content:"%s";classtype:bad-url;)' % (port,host,uri)
What i want to do is to insert a new field into each one of the alert rule that is created. This field must be a number always different from each rule that is created when executing the script. For example:
alert http any 8080 -> any any (http.host;content:"www.sermifleksiks.com";http.uri;content:"tab_home_active.js";classtype:bad-url;id:20)
alert http any 8080 -> any any (http.host;content:"www.sermifleksiks.com";http.uri;content:"tab_home_active.js";classtype:bad-url;id:21)`
Tried to use count function but i cannot make that work because i am not a python expert