Page 1 of 1

Checking networkports

Posted: Thu Mar 31, 2005 7:19 pm
by Hroudtwolf
Hello everybody,


Do anyone knows, how to check all networkports at the same time
for activity ?

Is there an API-Hook ?

Posted: Fri Apr 01, 2005 12:16 am
by Hroudtwolf
Is this a mysterious secret?
The first problem, that nobody can solve ?



I just want to get any event of incoming network activity !?

Posted: Fri Apr 01, 2005 2:48 am
by NoahPhense
Yeah, I'd be interested in some network stuff too..

Posted: Fri Apr 01, 2005 11:37 am
by dige
It's very easy, you have to start the same programm for 65.000 times
using the port number as parameter ;-)

Posted: Fri Apr 01, 2005 11:46 am
by Hroudtwolf
Yes, but this way needs much CPU-Work.

I need an event-hook for the windownetwork. Sometime I had read therefrom.

Posted: Fri Apr 01, 2005 1:01 pm
by HeX0R

Posted: Fri Apr 01, 2005 1:50 pm
by Hroudtwolf
Thanks...


..but this must work without any extern resources libs and DLLs...
I know, this function are implemented in the system. Windowsaplications are using this function,too.

Posted: Fri Apr 01, 2005 2:31 pm
by NoahPhense
Hroudtwolf wrote:Thanks...


..but this must work without any extern resources libs and DLLs...
I know, this function are implemented in the system. Windowsaplications are using this function,too.
Yeah, I think we need to hook into the stack.

- np

Posted: Fri Apr 01, 2005 4:08 pm
by Tommeh
..but this must work without any extern resources libs and DLLs...
That example uses netstat, if you pipe out the result of that, its exactly what you need...

On the other hand, if you want to do it to a remote machine (port scanning) then something like...

Code: Select all

Procedure OpenSocket(portnum)
OpenNetworkConnection("127.0.0.1", portnum)
EndProcedure

For t=1 to 65000
CreateThread(@OpenSocket(), t)
Next t
That stuff is just off the top of my head, but that will tie up your internet connection while its doing it.

Posted: Fri Apr 01, 2005 4:18 pm
by Hroudtwolf
Thanks. I will test it now.....

Posted: Fri Apr 01, 2005 4:38 pm
by Tommeh
You will want to do error checking with each one, otherwise you won't know if its opened/closed :)

Posted: Fri Apr 01, 2005 4:57 pm
by Hroudtwolf
I want know if any accesses comes to a port.

Posted: Fri Apr 01, 2005 5:26 pm
by Tommeh
Yes...


Simple port scanner:

Code: Select all

InitNetwork()

Procedure OpenSocket(portnum)
If OpenNetworkConnection("127.0.0.1", portnum)
Debug "OPEN! [port:"+Str(portnum)
EndIf
EndProcedure

For t=1 To 65000
CreateThread(@OpenSocket(), t)
Next t
Again, please be carefull with this, even to localhost, if you have no delays, it will kill your net connection, it did to me on 1mb after 2 seconds :)

Posted: Fri Apr 01, 2005 7:37 pm
by Kale
For t=1 To 65000
CreateThread(@OpenSocket(), t)
Whats the maximum number of threads that can be started on windows? i though it was < 65000?

Posted: Fri Apr 01, 2005 7:56 pm
by NoahPhense
We need to locate some kind of hook. There are much easier ways to
do what we're trying to do.

For example.. I use a freeware program, called active ports. It does no
scanning, yet, it tells me on the fly.. ports and ip addresses that are
being opened and closed.

- np