Nmap Development mailing list archives

Re: Script Help!


From: Daniel Miller <bonsaiviking () gmail com>
Date: Thu, 9 Jan 2014 06:58:32 -0600

Jerry,

First, your Nmap command uses '-iR 0' which means, "Scan random IPs
forever." I don't think this is probably what you want.

I would suggest that instead of using a script here, you simply parse
the results of Nmap's own output. Windows 7 comes with PowerShell, so
this is much easier than it used to be with Windows command shell.
Here's one way to do it:

PS> nmap -p 3389 -oG rdp-scan.gnmap $target
PS> Select-String rdp-scan.gnmap -Pattern "\s3389/open/tcp" |
ForEach-Object { $_.split()[1] } > rdp-ips.txt

Dan

On Wed, Jan 8, 2014 at 3:39 PM, Jerry Scooner <jymandigo () gmail com> wrote:
First of all I would like to congratulate and also thank you for your
awesome contribution to the free world with your amazing programs and
unquestionable knowledge, your patience and time is greatly appreciated.

I have a script which doesn't seem to work with the newer version of nmap
on windows7 system.  This .nse script was not created by me I found it on a
forum and my guess is it worked at some point either on W7/Linux system.  I
run this script with a batch file which scans but there is no output .txt
file with the scanned results.  I want the script to output the results of
the scan as a list of ips with the specified port open in a .txt file e.g
"192.123.234.22".

This is the .bat:
@echo off
for /l %%%x in (1,1,2) do (
start "rdp" /HIGH nmap -n -Pn -p T:3389 -T5 --script rdp.nse -iR 0
)
exit

This is the .nse script:
description=[[
Checks if an RDP port is open.
]]
author = "ROleg"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html";
categories = {"default", "discovery", "external", "intrusive"}
require "shortport"
portrule = shortport.portnumber(3389, "tcp", "open")
action = function(host, port)
    file = io.open ("results.txt","a+")
    file:write (host.ip.."\n")
    file:flush()
    file:close()
end

Please help
Thank you!
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/


Current thread: