我正在使用脚本调用来快速安装 Metasploit,当我将脚本粘贴到终端时,出现了错误
./msfinstall: line 1:syntax error near unexpected token 'newline'
./msfinstall: line1: '<DOCTYPE html>'
出现了。我该如何修复这个问题?
答案1
您下载的脚本似乎有问题。我刚刚试过,运行正常。
从终端运行gedit ./msfinstall
(假设您仍位于运行原始命令的目录中)以打开脚本进行编辑。
删除那里的所有内容并粘贴以下内容:
#!/bin/sh
print_pgp_key() {
cat <<-EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQINBFDAy/0BEAC8I5bw5gLQqHKx5JCacYcXFL6AZowl3qIOTxo5yfBl8CepNpWY
OOERvIUJb17WehhhbWOo9WjpBalDXBRtI1NvfArewOT8fLm7BdhYe8U45moBfkYi
xFtNrPw3pdIltHQISrB8PufhliN8obQuq0rcxYV8NblvYo4gIGNjBfO1QGvBNmp7
kBtjlAuZguScZmUTdPOwfv8fqN52X9tCv1ahQk1hg8XG9YwW0vXb5z93jkLXBb5b
sRCnou4m9IV6vOv2HVNRyMKT7uht3z4FqflP9NkySl4daCdZgmXbf169vvLdwLrC
lVymwAbwvuyILZv4JW1w0Kx8nWiTuK5A886882i83lxnkh1vC9jInva4/5hTrbRw
XJb7qOyh7sxa5GOfgq1NwVfLkrvVCMystrPu18sF1ORfg1UTFcz86RYdxpmoZvk7
EeABiLCQDZKOf0fV3U9CxLj8gXPjPY1Lu6udZUN6NG1ALJjsPkGnbpQEqEJlKNAG
+rF+tp73TrG0PW8C/THL7fN93ET3wn5tfNu86Liui9wd8ZLuPJNEYeE6eyPAgXJ4
p69Yb4ou5um5jWnzaVameECBZvtc4HOhy3nTEiVMDcKv/o8XxKOCLpjW1RSDirKl
ZRIsJYPx2yuJSVMCsN5Sghp5+OCsQ+On4OFWxCskemvy97ftkv/fwUI7mQARAQAB
tCJNZXRhc3Bsb2l0IDxtZXRhc3Bsb2l0QHJhcGlkNy5jb20+iQI9BBMBCgAnAhsD
BQsJCAcDBRUKCQgLBRYCA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yP7Qf5cO5mgFYxCfhZp8GkvK
lX5PgGasG3u3kHBl
=t69L
-----END PGP PUBLIC KEY BLOCK-----
EOF
}
install_deb() {
LIST_FILE=/etc/apt/sources.list.d/metasploit-framework.list
PREF_FILE=/etc/apt/preferences.d/pin-metasploit.pref
if [ ! -f $LIST_FILE ]; then
echo -n "Adding metasploit-framework to your repository list.."
echo "deb $DOWNLOAD_URI/apt lucid main" > $LIST_FILE
print_pgp_key | apt-key add -
fi
if [ ! -f $PREF_FILE ]; then
mkdir -p /etc/apt/preferences.d/
cat > $PREF_FILE <<EOF
Package: metasploit*
Pin: origin downloads.metasploit.com
Pin-Priority: 1000
EOF
fi
echo -n "Updating package cache.."
apt-get update > /dev/null
echo "OK"
echo "Checking for and installing update.."
apt-get install -y --force-yes metasploit-framework
}
install_rpm() {
echo "Checking for and installing update.."
REPO_FILE=/etc/yum.repos.d/metasploit-framework.repo
GPG_KEY_FILE=/etc/pki/rpm-gpg/RPM-GPG-KEY-Metasploit
if [ ! -f $REPO_FILE ]; then
echo -n "Adding metasploit-framework to your repository list.."
cat > /etc/yum.repos.d/metasploit-framework.repo <<EOF
[metasploit]
name=Metasploit
baseurl=$DOWNLOAD_URI/rpm
gpgcheck=1
gpgkey=file://$GPG_KEY_FILE
enabled=1
EOF
print_pgp_key > ${GPG_KEY_FILE}
fi
yum install -y metasploit-framework
}
install_pkg()
{
(
cd ~/Downloads
echo "Downloading package..."
curl -O "$DOWNLOAD_URI/osx/metasploitframework-latest.pkg"
echo "Checking signature..."
if pkgutil --check-signature metasploitframework-latest.pkg; then
echo "Installing package..."
installer -pkg metasploitframework-latest.pkg -target /
fi
echo "Cleaning up..."
rm -fv metasploitframework-latest.pkg
)
}
DOWNLOAD_URI=http://downloads.metasploit.com/data/releases/metasploit-framework
PKGTYPE=unknown
ID=`id -u`
if [ -f /etc/redhat-release ] ; then
PKGTYPE=rpm
else
if uname -sv | grep 'Darwin' > /dev/null; then
PKGTYPE=pkg
else
PKGTYPE=deb
fi
fi
if [ "$ID" -ne 0 ]; then
if ! hash sudo 2>/dev/null; then
echo "This script must be executed as the 'root' user or with sudo"
exit 1
else
echo "Switching to root user to update the package"
sudo -E $0 $@
exit 0
fi
fi
case $PKGTYPE in
deb)
install_deb
;;
rpm)
install_rpm
;;
*)
install_pkg
esac
保存文件,然后./msfinstall
再次运行。