Sertan,

2009/1/21 Sertan Kolat <ser...@mlists.olympos.org>:
> Hi developers,
>
> Here is a regular expression recommendation that will match private IP 
> addresses.
> This matches only valid rfc1918, local loopback and the link local block IP 
> addresses.
>
> (?:(?:10|127)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|192\.168|169\.254|172\.0?(?:1[6-9]|2[0-9]|3[01]))(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){2}
>
> I also included this as an attachment since mailing may break it.
> This regex returns 9 IP addresses against my test bed (Private IP 
> addresses.txt).
>
> It will return a list when used with re.findall and will return a match
> object that will fit w3af code in privateIP.py when used with re.search.

Excellent contribution, I needed that! This will reduce the amount of
false positives in the plugin to (I hope) zero.

>
> PS: To get an exact match, \b might be added to both sides of the
> expression.

Well, I've been testing the regex and I found out that this string
matches "192.168.1.1111". After adding the \b, I don't get any matches
:(   . Could you try to fix the regex? Thanks!

>>> re.findall('(?:(?:10|127)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|192\.168|169\.254|172\.0?(?:1[6-9]|2[0-9]|3[01]))(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){2}','
>>>  192.168.1.111 ')
['192.168.1.111']
>>> re.findall('(?:(?:10|127)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|192\.168|169\.254|172\.0?(?:1[6-9]|2[0-9]|3[01]))(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){2}\b','
>>>  192.168.1.111 ')
[]
>>> re.findall('\b(?:(?:10|127)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|192\.168|169\.254|172\.0?(?:1[6-9]|2[0-9]|3[01]))(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){2}\b','
>>>  192.168.1.111 ')
[]
>>>

Thanks!!


> Best regards,
> Sertan
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> W3af-develop mailing list
> W3af-develop@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/w3af-develop
>
>



-- 
Andres Riancho
http://w3af.sourceforge.net/
Web Application Attack and Audit Framework

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
W3af-develop mailing list
W3af-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/w3af-develop

Reply via email to