我开始编写一个 bash 脚本来自动渗透网络服务器,在这个例子中我使用了嵌套的情况,但即使我正确地给出了所有缩进,它也会引发错误
代码:
#!/bin/bash
figlet Automated Pentesting
select menu in "Information_gathering" "scanning" "exploitation"
do
case $menu in
"Information_gathering")
echo "###################################################"
select ch in "person" "domain_information" "email" "phonenumber"
do
case $ch in
"Information_gathering")
read -p "Enter Person name:" name
firefox -new-tab -url http://www.spokeo.com/social/profile?q=$name -new-tab -url https://pipl.com/search/protect?q=$name&in=5&l=&sloc=
;;
"domain_information")
read -p "enter the domain:" domain
echo -e "\033[31mwhois information of domain...........\033[m"
whois $domain
echo -e "\033[31mDNS information of domain........\033[m"
dnsrecon -d $domain
echo -e "\033[31mGet IP and hostnames from $domain......\033[m"
fierce -dns $domain -wordlist host.txt
echo -e "\033[31mGet emails of the domain.......\033[m"
theharvester -d $domain -l 500 -b google -h myresults.html
echo "emails are stored in myresults.html file"
;;
"email")
read -p "enter email address:" mal
firefox -new-tab -url http://www.spokeo.com/social/profile?q=$mal -new-tab -url https://pipl.com/search/protect?q=$mal&in=5&l=&sloc=
;;
"phonenumber")
read -p "Enter the phonenumber with countrycode" phnumbr
firefox -new-tab -url https://www.truecaller.com/search/in/$phnumbr
;;
esac
done
"scanning")
read -p "enter the domain to scan" domain
echo "\033[31m scanning with nikto.........\033[m"
nikto -h $domain -output /niktoresults.html
echo "\033[31m vulnerablilty analysis with whatweb.......\033[m"
whatweb $domain
echo "\033[31mscanning with nmap........\033[m"
nmap -sV $domain -oX /nmapresults.xml
;;
"exploitation")
echo "\033[31m exploiting the domain......\033[m"
python metasploitHelper.py -i nmapresults.xml
;;
esac
done
引发的错误是 ./pentest.sh: 第 37 行: 意外标记)' ./pentest.sh: line 37:
“扫描”附近的语法错误)'
答案1
每个案例部分都需要以 结尾;;
。在这种情况下,$menu
在外部case
匹配中执行的部分"Information_gathering"
不会以;;
final 结尾done
。