Skip to content

Instantly share code, notes, and snippets.

@satta
satta / rand-rule.lua
Last active February 8, 2017 13:49
Script to create 'worst case' rules with long random patterns, to stress Suricata's AC-based MPM engine.
#!/usr/bin/env lua
math.randomseed(os.time())
function string.random(length)
local t = {}
for i = 1,length do
table.insert(t, math.random(97,122))
end
return string.char(unpack(t))
package main
import (
"fmt"
"log"
"unsafe"
sophia "github.com/pzhin/go-sophia"
)
#include <stdio.h>
int main() {
int optind = 99, optreset = 98;
#if defined __GLIBC__
/* glibc needs to have optind set to 0 instead of the "traditional
value" of 1 */
optind = 0;
#else
/* 1 is the value that optind should be initialized to according to