我正在尝试调整回溯中的脚本以与 Ubuntu 一起使用。我一直在第 14 行收到错误,这是该if [ $? == 0 ]; then
行。
该脚本位于http://pctechtips.org/script-to-change-mac-and-hostname-in-backtrack/
代码如下:
#!/bin/bash
#author: Jorge L. Vazquez
#purpose: this script will change the mac address to random
#and will pick a random word from password.lst in jtr for hostname
#change variables "interface" and "file" to your settings
#also macchanger needs to be installed
INTERFACE=eth0
FILE=/pentest/passwords/jtr/password.lst
WORD=$(sort -R $FILE | head -1)
#changing mac address to random
ifconfig $INTERFACE down > /dev/null
if [ $? == 0 ]; then
printf "%s\nChanging mac address...\n"
macchanger -r $INTERFACE
else
printf "%sScript encounter an error, sorry...\n"
exit 1
fi
#changing hostname to random word from password.lst
printf "%s\nChanging Hostname...\n"
OLDHOST=$(hostname)
hostname $WORD
if [ $? == 0 ]; then
printf "%sPrevius Hostname: $OLDHOST \n"
printf "%sRandom Hostname: $WORD \n"
else
printf "%sScript encounter an error, sorry...\n"
exit 1
fi
#putting interface up
ifconfig $INTERFACE up > /dev/null
printf "\n"
#END
主机文件 (password.lst) 的单词表文件如下所示
# A couple of merged /etc/hosts files --
#
4000ex
a-lhi-bbn-01
a-lhi-sri-03
a00
a1
a2
我使用运行脚本sh filename.sh
,并为其提供了可执行访问权限并安装了 macchanger,但我仍然收到错误消息14: [: 0: unexpected operator
Script encounter an error, sorry...