Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Nessus: plugins

nasl question : split and arrays

 

 

Nessus plugins RSS feed   Index | Next | Previous | View Threaded


peter.ve at corelan

Jan 31, 2009, 6:29 AM

Post #1 of 3 (2191 views)
Permalink
nasl question : split and arrays

Hello,

I have a string that looks like this

mystring="value1=1 value2=a value3=cd value4=jj";

I would like to be able to put this in individual arrays (each of 2 elements) that can be walked through via a "foreach" iteration

My first idea was to use 2 split functions

array1=split(mystring," ");
then for each array1 member, split it again :
foreach arraymember (array1)
{
arrayentry=split(arraymember,"=");
foreach field (arrayentry)
{
display(string("item :",field,"\n");
}
}

but this does not seem to work... I get the entire string every time, so it looks like the split function is not doing anything
(however, when I do a split without parameters on a large chunck of text, trying to split this text into lines, it works fine.. but as soon as I want to use a separator, it stops working)

what is wrong here ?

thanks



____________________________________________________

Peter Van Eeckhoutte
peter.ve [at] telenet - peter.ve [at] corelan
____________________________________________________

My Blog : http://www.corelan.be:8800 (IPv4 and IPv6)
My Tools : http://freetools.corelan.be
RIPE Handle PVE50-RIPE
a.k.a. c0d3r on various forums
____________________________________________________



This transmission is intended only for use by the intended recipient(s). If you are not an intended recipient you should not read, disclose, copy, circulate or in any other way use the information contained in this transmission. The information contained in this transmission may be confidential and/or privileged. If you have received this transmission in error, please notify the sender immediately and delete this transmission including any attachments.
_______________________________________________
Plugins-writers mailing list
Plugins-writers [at] list
http://mail.nessus.org/mailman/listinfo/plugins-writers


mikhail at nessus

Jan 31, 2009, 7:30 AM

Post #2 of 3 (2063 views)
Permalink
Re: nasl question : split and arrays [In reply to]

On Sat, 31 Jan 2009 15:29:32 +0100
"Peter Van Eeckhoutte (corelan)" <peter.ve [at] corelan> wrote:

> array1=split(mystring," ");

The separator is a named argument: sep: " ".
And You probably want to remove it: "keep: 0"

This works:

mystring="value1=1 value2=a value3=cd value4=jj";
array1=split(mystring, sep: " ", keep: 0);
foreach arraymember (array1)
{
arrayentry=split(arraymember, sep: "=", keep: 0);
foreach field (arrayentry)
{
display("item :",field,"\n");
}
}
_______________________________________________
Plugins-writers mailing list
Plugins-writers [at] list
http://mail.nessus.org/mailman/listinfo/plugins-writers


peter.ve at corelan

Jan 31, 2009, 5:13 PM

Post #3 of 3 (2046 views)
Permalink
Re: nasl question : split and arrays [In reply to]

Great, thanks !

I have published my plugin on my blog...
It basically is a wrapper/output parser for ike-scan,
more info can be found at

http://www.corelan.be:8800/index.php/2009/01/31/nessus-wrapper-for-ike-scan/

(it still may be a bit buggy, it most likely can be improved and extended, the code probably needs some cleaning up... but hey, this is my first script, so this is a learning process for me...)

Any comments/feedback/... is more than welcome


____________________________________________________

Peter Van Eeckhoutte
peter.ve [at] telenet - peter.ve [at] corelan
____________________________________________________

My Blog : http://www.corelan.be:8800 (IPv4 and IPv6)
My Tools : http://freetools.corelan.be
RIPE Handle PVE50-RIPE
a.k.a. c0d3r on various forums
____________________________________________________

-----Original Message-----
From: Michel Arboi [mailto:mikhail [at] nessus]
Sent: zaterdag 31 januari 2009 16:31
To: Peter Van Eeckhoutte (corelan)
Cc: Plugins-writers [at] list
Subject: Re: [Plugins-writers] nasl question : split and arrays

On Sat, 31 Jan 2009 15:29:32 +0100
"Peter Van Eeckhoutte (corelan)" <peter.ve [at] corelan> wrote:

> array1=split(mystring," ");

The separator is a named argument: sep: " ".
And You probably want to remove it: "keep: 0"

This works:

mystring="value1=1 value2=a value3=cd value4=jj";
array1=split(mystring, sep: " ", keep: 0);
foreach arraymember (array1)
{
arrayentry=split(arraymember, sep: "=", keep: 0);
foreach field (arrayentry)
{
display("item :",field,"\n");
}
}

This transmission is intended only for use by the intended recipient(s). If you are not an intended recipient you should not read, disclose, copy, circulate or in any other way use the information contained in this transmission. The information contained in this transmission may be confidential and/or privileged. If you have received this transmission in error, please notify the sender immediately and delete this transmission including any attachments.
_______________________________________________
Plugins-writers mailing list
Plugins-writers [at] list
http://mail.nessus.org/mailman/listinfo/plugins-writers

Nessus plugins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.