Mailing List Archive

How To Code \r\n In Banner Check?
I have the following code in a plugin:

send(socket:soc,data:http_get(item:"/",port:port));
banner=recv(socket:soc,length:1024);
device_banner="Widget 5000";

The data/banner is several lines. If I envoke:

if(ereg(pattern:device_banner,string:banner))

"if" will be true because "device_banner" is a subset of "banner".
However, I would like "device_banner" to contain the entire known banner
of the Widget 5000 which is a multi-line string. I've tried several
variations of \r\n, but to no avail...

How can I have the following be assigned to the variable "device_banner"?

# Begin banner.
Widget 5000
Version 1.2.3
Bla bla bla
# End banner

Much thanks.
--
George
Re: How To Code \r\n In Banner Check? [ In reply to ]
On Tue, Oct 01, 2002 at 05:12:59PM -0500, George Stone wrote:
> I have the following code in a plugin:
>
> send(socket:soc,data:http_get(item:"/",port:port));
> banner=recv(socket:soc,length:1024);
> device_banner="Widget 5000";
>
> The data/banner is several lines. If I envoke:
>
> if(ereg(pattern:device_banner,string:banner))
>
> "if" will be true because "device_banner" is a subset of "banner".
> However, I would like "device_banner" to contain the entire known banner
> of the Widget 5000 which is a multi-line string. I've tried several
> variations of \r\n, but to no avail...
>
> How can I have the following be assigned to the variable "device_banner"?
>
> # Begin banner.
> Widget 5000
> Version 1.2.3
> Bla bla bla
> # End banner

What about using multiple calls to egrep() ?


if(egrep(pattern:"^Widget 5000", string:banner) &&
egrep(pattern:"^Version .*", string:banner) &&
egrep(pattern:"^Bla bla.*", string:banner))do_stuff();


It will match on a banner set on a reverse order, but this should do.

If your banner is static, you may also simply use the "><" operator:


if(device_banner >< banner)do_stuff();


-- Renaud