To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
Code CritiqueHaving someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.
I was bored tonight so I wrote up a little port scanner in php. Took me less then an hour and the file is under 120 lines of code including comments, html and white space. On top of that it's valid xhtml.
Sometimes the simplicity of this language scares me. Anyway here it is, phport scanner.
This is educational software and not intended to be used for hacking or any other illegal activity.
Originally posted by laserlight Invalid English comments too, with "at the end of teh form"
There's also $_POST[scan_btn], I think, though I doubt scan_btn will ever be a reserved word in PHP.
Actually, could there be a slight problem with your "if the person entered an ip resolve it to the domain name" regex?
Cos it doesnt seem to take into account that a domain name contains periods (and dashes) as well.
Yeah I guess I should quote my array indecies. What I do with the regex is say if it has letters, any letters, then it's a domain name otherwise it's an ip address. It's a very loose check but I was writting as an example of how easy port scans are in php.
one thing of note......... the current timeout limit of 10 allows for only two full timeouts... not enough time to check all ports. If there are too mny failures, the script itself wil timeout after 30 seconds. if you're goign to use this, timeout=3 and set_time_limit(0); wouldnt be a bad idea.
__________________
there's no place i can be, since i found serenity.
Originally posted by Moonglobe one thing of note......... the current timeout limit of 10 allows for only two full timeouts... not enough time to check all ports. If there are too mny failures, the script itself wil timeout after 30 seconds. if you're goign to use this, timeout=3 and set_time_limit(0); wouldnt be a bad idea.
I don't think time spent in these functions affects the script running time.
Halfabee
__________________
The lazy man always finds the best way!
Q: Who invented the auto-pilot?
A: The lazy pilot!