Checking networkports

Windows specific forum
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Checking networkports

Post by Hroudtwolf »

Hello everybody,


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

Is there an API-Hook ?
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post 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 !?
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

Yeah, I'd be interested in some network stuff too..
dige
Addict
Addict
Posts: 1417
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

It's very easy, you have to start the same programm for 65.000 times
using the port number as parameter ;-)
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Yes, but this way needs much CPU-Work.

I need an event-hook for the windownetwork. Sometime I had read therefrom.
User avatar
HeX0R
Addict
Addict
Posts: 1221
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Post by HeX0R »

User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post 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.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post 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
Tommeh
Enthusiast
Enthusiast
Posts: 149
Joined: Sun Aug 29, 2004 2:25 pm
Location: United Kingdom

Post 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.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Thanks. I will test it now.....
Tommeh
Enthusiast
Enthusiast
Posts: 149
Joined: Sun Aug 29, 2004 2:25 pm
Location: United Kingdom

Post by Tommeh »

You will want to do error checking with each one, otherwise you won't know if its opened/closed :)
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

I want know if any accesses comes to a port.
Tommeh
Enthusiast
Enthusiast
Posts: 149
Joined: Sun Aug 29, 2004 2:25 pm
Location: United Kingdom

Post 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 :)
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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?
--Kale

Image
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post 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
Post Reply