Masscan& Nmap脚本

时间:2017-09-23 07:07:42

标签: linux bash awk sed

我目前正在学习笔测试和练习册"掌握kali linux进行高级渗透测试 - 第二版"以及他们为Masscan& amp; Nmap(合并)是这样的:

#!/bin/bash
function helptext {
echo "enter the massnmap with the file input with list of IP address      ranges"
}
if [ "$#" -ne 1 ]; then
echo  "Sorry cannot understand the command"
helptext>&2
exit 1
elif [ ! -s $1 ]; then
echo "ooops it is empty"
helptext>&2
exit 1
fi

if [ "$(id -u)" != "0" ]; then
echo "I assunme you are running as root"
helptext>&2
exit 1
fi
for range in $(cat $1); do
  store=$(echo $range | sed -e 's/\//_g')
  echo "I am trying to create a store to dump now hangon"
  mkdir -p pwd/$store;
  iptables -A INPUT -p tcp --dport 60000 -j DROP;
  echo -e "\n alright lets fire masscan ****"
  masscan --open --banners --source-port 60000 -p0-65535 --max-rate 15000          -oBpwd/$store/masscan.bin $range; masscan --read$
  if [ ! -s ./results/$store/masscan-output.txt ]; then
      echo "Thanks for wasting time"
    else
    awk'/open/ {print $4, $3, $2, $1}' ./results/$store/masscan-output.txt | awk'
                                                          /.+/{
                                                          if (! ($1 in Val)) { Key[++i] = $1; }
                                                          Val[$1] = Val[$1] $2 ",";
                                                          END{
for (j = 1; j <= i; j++) {                        printf("%s:%s\n%s", Key[j], Val[Key[j]], (j == i) ? "" : "\n");                       }
                                                                                    }'>}./results/$store/hostsalive.csv
for ips found in $(cat ./results/$store/hostsalive.csv); do
  IP=$(echo $TARGET | awk -F: '{print $1}');
  PORT=$(echo $TARGET | awk -F: '{print$2}' | sed's/,$//');
  FILENAME=$(echo $IP | awk'{print "nmap_"$1}');
  nmap -vv -sV --version-intensity 5 -sT -O --max-rate 5000 -Pn -T3 -p     $PORT -oA ./results/$store/$FILENAME $IP;
                                                                   done
                                                                 fi
                                                                 done

我手工编写它只是为了确保它正确完成,当我在执行chmod + x(filename.sh)之后运行它得到: (运行./filename.sh)我得到&#34;抱歉无法理解命令 输入带有文件输入的massnmap,其中包含IP地址范围列表&#34;

(运行./filename.sh ipran.txt)我得到&#34; ./ anyname.sh:line 37:在$(cat ./results/)中找到的ips意外令牌found' ./anyname.sh: line 37:附近的语法错误$店/ hostsalive.csv);做&#39;&#34;

我本来打算&#34;我正在努力建立一个商店来转储现在的哈顿&#34; &#34;好吧让我们开火#***;&#34;

我尝试过使用不同的ips(在我的ipran.txt文件中) 任何帮助将不胜感激 OS使用-Kali linux

0 个答案:

没有答案