JunOS config checking
Today I’ve been automating Juniper router configuration assessment. Basically issuing a “show configuration” from the CLI and then using a Nessus .nasl script to parse the results.
The main problem is that JunOS uses multiline config statements, so to check if HTTP is enabled, you end up having to go through this lot:
system {
services {
web-management {
http {
interface em0.0;
}
}
}
}
So you have to use a combination of functions – ereg() which can look for a multiline regex and return true/false, egrep() which can return a single matching line from a multiline string and eregmatch() which returns just the matching portion of that single line!