Nmap Development mailing list archives
Implementing Nmap within a Java Program
From: "Supratim Sarkar" <supratimsarkar () gmail com>
Date: Wed, 28 May 2008 16:47:58 +0530
Hi everybody,
Cheers to Fyodor first for having created such a freat tool.
Now I was trying to develop a Scanner/Asset Management kind of tool with
nmap. I started on with java.(JDK 1.6) Platform is Win XP Pro.
I am executing the nmap.exe from a java method using the runtime.execute
method. Now the problem is that if I directly run the nmap command along
with the options , it starts up but does not terminate. So I created a C
wrapper which is turn will be executed from the java. Now that also creates
the same issue.
I am attaching some snippets of the code so that I can give some idea.
========================Snippet===============================================================================
// This part gets the nmap options and the target
String nmapCmd = NMAP_COMMAND_STR
+ " " + scanner.getScanConfig().getParam()
+ " -oX " + SCAN_DATA_FILE + " "
+ Utility.getNmapIPRange(ipRange);
if(ipRange.getExclude()!=null) {
nmapCmd = nmapCmd + " --exclude " +
ipRange.getExclude();
}
System.out.println("Executing : " + nmapCmd);
String cmd1 = "NETSCAN.exe \"" + nmapCmd + "\"";------the
"netscan.exe" is just a C wrapper program which passes the options to nmap
//uncomment for real testing to run nmap
Process proc = Runtime.getRuntime().exec(nmapCmd);
Process proc = Runtime.getRuntime().exec(cmd1);
proc.waitFor();
The nmap cmd string is something like this :
nmap.exe -sSU -pT:*,U:53,67,161 -sV --version-light -T4-v -P0 -n -PU -oX
data.xml xx.xx.xx.xx-xx
The cmd1 string looks like
NETSCAN.exe "nmap.exe -sT -pT:*,U:53,67,161 -sV --version-light -T4-v -P0 -n
-PU -oX dataone.xml xx.xx.xx.xx-xx"
===================================================================================================================
Now the thing is that the nmap program starts as I can checkout by running
task manager and that the xml file is also generated. But it keeps going on
and does not terminate.Its like nmap hangs somewhere in the middle of the
scan
Do let me know if I could make clear my problem ..otherwise I can put some
more details
It would be of great help if someone can help me out with this
Thanks,
Supratim
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org
Current thread:
- Implementing Nmap within a Java Program Supratim Sarkar (May 29)
- Re: Implementing Nmap within a Java Program Kris Katterjohn (May 29)
- Re: Implementing Nmap within a Java Program Supratim Sarkar (May 29)
- Re: Implementing Nmap within a Java Program Brandon Enright (May 30)
- Re: Implementing Nmap within a Java Program Supratim Sarkar (May 29)
- Re: Implementing Nmap within a Java Program Kris Katterjohn (May 29)
