msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

18 Apr 07 nmap/nbtscan scan for å finne pc med åpen port

Posted by

Dette scriptet scanner IP-er fra ei fil og finner ut hvem som har en spesiell port åpen.

Lim inn følgende script kode i fila portLookup.sh

#!/bin/bash
NETWORKTARGET=$1
PORT=$2
FN="port"

# Scan Network Input File for active hosts saving IPS to $FNips.txt
nmap -sS -p $PORT -n -iL $NETWORKTARGET -oG - | grep open | awk '/[1-9].[1-9]/ {print $2}' > ${FN}ips.txt

# use nbtscan to find hostnames and generate the ip to name $FNlookup file
nbtscan -f ${FN}ips.txt | awk '/[1-9].[1-9]/ {print $1 " " $2}' > ${FN}lookup.txt

echo "Scan Complete"
echo "Port Scanned: "$PORT
NUMIPS=`cat ${FN}ips.txt | wc -l`
NUMHOSTS=`cat ${FN}lookup.txt | wc -l`
echo "Number of IPs Found: "$NUMIPS " See file ${FN}ips.txt"
echo "Number of Netbios Names Found: "$NUMHOSTS " See file ${FN}lookup.txt"

Scriptet henter data/IP-adresser fra ei tekstfil og du angir hvilken port som skal scannes på følgende måte:

portLookup.sh tekstfil portnr
portLookup.sh hosts.txt 80

Eksemplet ovenfor henter ut IP-adresser fra fila hosts.txt og scanner etter PCer med port 80 åpen.

En enkel måte å generere ei slik fil kan leses på generate a list of target hosts to nmap scan/

Resultatet legges i filene portips.txt og portlookup.txt

Tags: , , , ,

Leave a Comment

You must be logged in to post a comment.