Author Topic: script for scanning random specific port with nmap  (Read 1011 times)

0 Members and 2 Guests are viewing this topic.

Offline zoup

  • Serf
  • *
  • Posts: 29
  • Cookies: 3
  • I don't understand anything here !
    • View Profile
script for scanning random specific port with nmap
« on: 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:

Code: [Select]
#!/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

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #1 on: 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:

Code: [Select]
#!/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.
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline zoup

  • Serf
  • *
  • Posts: 29
  • Cookies: 3
  • I don't understand anything here !
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #2 on: September 16, 2014, 08:16:04 pm »
Some hint where could i start how nmap this manages ? Thank you.

Offline Architect

  • Sir
  • ***
  • Posts: 428
  • Cookies: 56
  • STFU
    • View Profile
    • Rootd IRC
Re: script for scanning random specific port with nmap
« Reply #3 on: September 16, 2014, 09:25:12 pm »
Can you start with learning at least legible English? Thanks.

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #4 on: 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:
Code: [Select]
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.
« Last Edit: September 16, 2014, 10:06:32 pm by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline zoup

  • Serf
  • *
  • Posts: 29
  • Cookies: 3
  • I don't understand anything here !
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #5 on: 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.

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #6 on: 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
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #7 on: 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:
Code: [Select]
nmap -iR 1000 -p 445 -n -Pn --open
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline zoup

  • Serf
  • *
  • Posts: 29
  • Cookies: 3
  • I don't understand anything here !
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #8 on: September 18, 2014, 07:08:55 pm »
Thank you and sorry for asking stupid questions.

Offline rocketballz

  • /dev/null
  • *
  • Posts: 17
  • Cookies: -3
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #9 on: 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~


Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: script for scanning random specific port with nmap
« Reply #10 on: 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
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python