Mailing List Archive

Bug in htonl (network_func.nasl) and help needed in building packe payload
Hi Gents,



I found a possible bug in htonl function located in network_func.nasl:

1 function htonl(n)

2 {

3 local_var i, j, s;



4 j = n;

5 for (i = 0; j < 4; j ++) ######## Here, shouldn't it be i < 4;
i++ ###########

6 {

7 s[i] = j & 0xFF;

8 j >>>= 8;

9 }

10 return raw_string(s[3], s[2], s[1], s[0]);

11 }



In line 5, shouldn't it be 'for( i = 0; i < 4; i++ )'?



I have checked nessus version 2.2.4 and 2.2.5, but got the same code.



I also have a question that needs your help: how can I forge ICMP
payload data?

I need 2 bytes source port, 2 bytes destination port, and 4 bytes
sequence #,

So I wrote like 'data = raw_string( htons(sport), htons(dport),
htonl(seq) );' but it's not working. Any idea?



Thank you for the help!



Jingyu Dong
Re: Bug in htonl (network_func.nasl) and help needed in building packe payload [ In reply to ]
On Wed Aug 17 2005 at 16:16, Jingyu Dong wrote:

> I also have a question that needs your help: how can I forge ICMP
> payload data?

In some cases (host unreachable...), forging an IP packet then
truncating it to keep the 1st 64 bits should work.

> I need 2 bytes source port, 2 bytes destination port, and 4 bytes
> sequence #,

> So I wrote like 'data = raw_string( htons(sport), htons(dport),
> htonl(seq) );'

Use strcat, not raw_string