4

I'm writing a port collision checking function. I need to determine:

  • if a certain port is open
  • the process name of the daemon
  • path of the binary of the daemon

My idea was to run a QProcess executing the native command netstat -abno and parsing the output. But the parameter -b requires elevated rights (UAC) and i don't want to bug users with an UAC prompt.

Is there a Qt lib out there providing such functionality? How would you implement this?

Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
  • What do you mean by port path? Frankly, looking at the title, I was thinking about serialport without seeing the body... – László Papp May 22 '14 at 20:09
  • With port i mean a communications endpoint, like ports: 80, 8080, 5433. – Jens A. Koch May 22 '14 at 20:13
  • I know what a port is :) but I do not know what a port path is and why you need that :) – László Papp May 22 '14 at 20:20
  • "port path"? I mean the path of the executable of the daemon listening on a certain port. I changed the question accordingly. Why? I need the path to check, if the executable/daemon is running from our installation folder or from another dir. – Jens A. Koch May 22 '14 at 20:34
  • Easy to do on Windows. Not without elevation, this is very exploitable information. – Hans Passant May 31 '14 at 18:54
  • @Jens : Have you ever found a solution to the "... path of the binary ..." part? My current knowledge is that you cannot determine the binary of a process without elevation, but maybe you found something? – Martin Ba Jan 11 '23 at 10:45
  • Nope. Accessing this info needs elevation. I ended up with an application startup check and a shutdown dialog, which asked the user of the monitoring tool to restart as admin or grant elevated rights by altering the executable settings to avoid the issue. – Jens A. Koch Jan 12 '23 at 13:55

2 Answers2

2

you can use Tcpvcon.exe which is part of TCPView
TCPView Needs admin rights, tcpvcon does not
use with -an or -acn
you can even specify the application to check afterwards: e.g. Tcpvcon.exe -an Skype

originally found by Dane some time ago:

Use TCPView if you want a GUI for this. It's the old Sysinternals app that Microsoft bought out

Community
  • 1
  • 1
user3684363
  • 113
  • 1
  • 6
1
  • My idea was to run a QProcess executing the native command netstat -abno and parsing the output

To do this you can just:

QProcess cmdProcess;
...
cmdProccess.start(..);
while(cmdProcess.waitForReadyRead(-1)) someParseFunction(cmdProcess.readAllStandardOutput());
IGHOR
  • 691
  • 6
  • 22