-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change: extended the nasl functions ereg(), egrep(), eregmatch(). (#1044
) * Change: extended the nasl functions ereg(), egrep(), eregmatch(). Now, they accept a new parameter "rnul" (replace null) with . This option will replace the null char '\0' with '\x00'. If you use this option and you want to match the null char (replaced), you must adjust the regex to search for '\\x00' (it is replaces with 4 chars, so the back slash must be escaped as well). Example: ``` string = 'NASL' + raw_string(0x00) + 'Test'; if(egrep(string:string, pattern:"NASL\\x00Test", icase:FALSE, rnul:TRUE)) # <<<<<<<<<< Searchs for the replacement, escaping the backslash. display("egrep succeeded"); else display("egrep failed"); if(eregmatch(string:string, pattern:"NASL.+Test", icase:FALSE, rnul:TRUE)) display("eregmatch succeeded"); else display("eregmatch failed"); if(ereg(string:string, pattern:"NASL.+Test", icase:FALSE, rnul:TRUE)) display("ereg succeeded"); else display("ereg failed"); ``` Output: ``` $ openvas-nasl -X -B -d -i $PLUGINSPATH regex.nasl lib nasl-Message: 08:29:21.150: egrep succeeded lib nasl-Message: 08:29:21.150: eregmatch succeeded lib nasl-Message: 08:29:21.151: ereg succeeded ``` * Make the new nul char replacement, the default behaviour
- Loading branch information
Showing
1 changed file
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters