Question Time: How to get a C# WPF application to run Nmap

Hi all,

I am working on an academic project where I need to be able to run port scans from a C# WPF desktop application.

I had a little brainwave last night (whilst waiting for the longest nmap scan to run in history) on how I can improve my application, but I’m not even sure it is even possible…

The idea would be to download and install Nmap locally to the windows machine and run the commands via my application behind the scenes silently on the command line think of it on the lines of SPARTA.

From my research this can be done by a batch file that I can’t really see working… is there a way to just run this silently?

e.g PowerShell.exe -windowstyle hidden nmap -sV -sT -Pn -sC -T5 -O xxx.xxx.xxx.xxx

I would then take the output from that scan into my application results page.

So add IP address in here…

Then the detailed results end up in here…

For those that are intersted, the full code base is here:

(Yeah, I know the UI is cheesy as hell, its meant to be… (it’s also animated :rofl: ))

Any help or advice on things to google or to take over to stack for a formulated question would be appreciated.

1 Like

Yeah, sure.

Spawn a process which launches nmap with the parameters you need (using System.Diagnostics.Process).

You can redirect the output and parse the results as nmap produces them.

Let me know that’s enough to get you going. :slight_smile:

1 Like

Let the googling begin.

Thank you @hostile.node

Quite welcome. I’ve also just remembered that you’ll want to pass “-v” to nmap if you want to process results as nmap finds them, otherwise you’ll just get the entire output once the process finishes.

Yeah this is a good idea, or i would need to add some sort of progress bar…

Look at this initially its not as easy as i thought, but it would make my application much more interesting.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.