News for hackers. Stuff that matters.
Re:LulzSec's 3-line PHP Portscan by PawelDecowski on Friday June 24, 2011 @11:25AM (#2692541)
What's with the weird for loop?

Why not just:

    for ($c = ip2long($argv[1]); $c <= ip2long($argv[2]); $c++)
            if (strpos(@file_get_contents('http://'.long2ip(ip2long($argv[1])+$c), false, stream_context_create(array('http’ => array('timeout’ => $argv[3])))), $argv[4]) !== false)
                    die('H4xed :D — '.long2ip($c));
Re:LulzSec's 3-line PHP Portscan by pak on Friday June 24, 2011 @11:36AM (#2692575)
I think you meant

           if (strpos(@file_get_contents('http://'.long2ip($c), false, stream_context_create(array('http’ => array('timeout’ => $argv[3])))), $argv[4]) !== false)
Re:LulzSec's 3-line PHP Portscan by PawelDecowski on Friday June 24, 2011 @11:39AM (#2692591)
Well spotted.

I forgot to replace it on line 2, only did it on line 3.

Re:LulzSec's 3-line PHP Portscan by zbanks on Friday June 24, 2011 @11:38AM (#2692585)
Your code has a bug on line 2.

@file_get_contents('http://.long2ip(ip2long($argv[1])+$c)

Since $c is the IP address itself, adding the starting IP again will check a completely different IP.

Besides that, you have a point. I feel like the code would be so much cleaner if they just added a 4th line to declare ip2long($argv[1]) as a variable.

Re:LulzSec's 3-line PHP Portscan by PawelDecowski on Friday June 24, 2011 @11:40AM (#2692594)
Yeah, I missed it. Thanks for spotting.