EvilZone

Programming and Scripting => Scripting Languages => : zoup September 16, 2014, 07:33:12 PM

: script for scanning random specific port with nmap
: zoup September 16, 2014, 07:33:12 PM
I had this idea using nmap for random scanning for a specific port.
Maybe a bit stupid but useful. This is what i did:

:
#!/bin/bash

port="$1"

if [ "$port" = "" ]
then
echo "port misssing"
exit
fi

f='filtered'
while [ "$f" != 'open' ]
do
a=$(nmap -sS -Pn -p $port -iR 1 -o tmp | grep $port/ ) # )
f=$(echo $a | cut -f2 -d ' ')
echo $f
done

 :o
: Re: script for scanning random specific port with nmap
: proxx September 16, 2014, 07:34:32 PM
I had this idea using nmap for random scanning for a specific port.
Maybe a bit stupid but useful. This is what i did:

:
#!/bin/bash

port="$1"

if [ "$port" = "" ]
then
echo "port misssing"
exit
fi

f='filtered'
while [ "$f" != 'open' ]
do
a=$(nmap -sS -Pn -p $port -iR 1 -o tmp | grep $port/ ) # )
f=$(echo $a | cut -f2 -d ' ')
echo $f
done

 :o

Nice try but I would suggest you just use NMAP's built in functions which can do what you are doing and much more and be a bit more efficient.
: Re: script for scanning random specific port with nmap
: zoup September 16, 2014, 08:16:04 PM
Some hint where could i start how nmap this manages ? Thank you.
: Re: script for scanning random specific port with nmap
: Architect September 16, 2014, 09:25:12 PM
Can you start with learning at least legible English? Thanks.
: Re: script for scanning random specific port with nmap
: lucid September 16, 2014, 10:01:46 PM
Some hint where could i start how nmap this manages ? Thank you.
man nmap

Also, I just relooked at your code and realized you are already using nmap for this. Why even bother making a script like this when you can just run:
:
nmap -sS -Pn -p 445 -T5 192.168.1.1
Or whatever. All you need is the -p 445, and it will tell you(with greater accuracy then your script) if the port is open, closed, or filtered(firewalled). Trust me, if you think of something pertaining to port or host scanning, nmap has probably thought of it already.
: Re: script for scanning random specific port with nmap
: zoup September 17, 2014, 04:22:54 PM
@Architect
Sorry for my bad english. I am not a native english.

Ok. I try it the nmap way. The idea behind this was that i wanted to scan RANDOM targets until
this specific port is found.
: Re: script for scanning random specific port with nmap
: proxx September 17, 2014, 06:54:57 PM
@Architect
Sorry for my bad english. I am not a native english.

Ok. I try it the nmap way. The idea behind this was that i wanted to scan RANDOM targets until
this specific port is found.
From the top of my head that is the -iR flag, rtfm
: Re: script for scanning random specific port with nmap
: lucid September 17, 2014, 06:55:13 PM
@Architect
Sorry for my bad english. I am not a native english.

Ok. I try it the nmap way. The idea behind this was that i wanted to scan RANDOM targets until
this specific port is found.
In that case try this:
:
nmap -iR 1000 -p 445 -n -Pn --open
: Re: script for scanning random specific port with nmap
: zoup September 18, 2014, 07:08:55 PM
Thank you and sorry for asking stupid questions.
: Re: script for scanning random specific port with nmap
: rocketballz November 03, 2014, 06:41:49 AM
You can just add -P 20-80 at the end of the command for whatever ports you want scanned

~APH ADMIN~

: Re: script for scanning random specific port with nmap
: lucid November 03, 2014, 06:20:33 PM
You can just add -P 20-80 at the end of the command for whatever ports you want scanned

~APH ADMIN~
That's not even correct information. It would be -p, not -P. Don't give out advice if you aren't 100% sure that you know what you are talking about. Spreading misinformation is the devil's work :P