Advertisement
v1ral_ITS

msfinstall shell script

Sep 22nd, 2018
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.39 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. print_pgp_key() {
  4.   cat <<-EOF
  5. -----BEGIN PGP PUBLIC KEY BLOCK-----
  6. Version: GnuPG v1
  7.  
  8. mQINBFDAy/0BEAC8I5bw5gLQqHKx5JCacYcXFL6AZowl3qIOTxo5yfBl8CepNpWY
  9. OOERvIUJb17WehhhbWOo9WjpBalDXBRtI1NvfArewOT8fLm7BdhYe8U45moBfkYi
  10. xFtNrPw3pdIltHQISrB8PufhliN8obQuq0rcxYV8NblvYo4gIGNjBfO1QGvBNmp7
  11. kBtjlAuZguScZmUTdPOwfv8fqN52X9tCv1ahQk1hg8XG9YwW0vXb5z93jkLXBb5b
  12. sRCnou4m9IV6vOv2HVNRyMKT7uht3z4FqflP9NkySl4daCdZgmXbf169vvLdwLrC
  13. lVymwAbwvuyILZv4JW1w0Kx8nWiTuK5A886882i83lxnkh1vC9jInva4/5hTrbRw
  14. XJb7qOyh7sxa5GOfgq1NwVfLkrvVCMystrPu18sF1ORfg1UTFcz86RYdxpmoZvk7
  15. EeABiLCQDZKOf0fV3U9CxLj8gXPjPY1Lu6udZUN6NG1ALJjsPkGnbpQEqEJlKNAG
  16. +rF+tp73TrG0PW8C/THL7fN93ET3wn5tfNu86Liui9wd8ZLuPJNEYeE6eyPAgXJ4
  17. p69Yb4ou5um5jWnzaVameECBZvtc4HOhy3nTEiVMDcKv/o8XxKOCLpjW1RSDirKl
  18. ZRIsJYPx2yuJSVMCsN5Sghp5+OCsQ+On4OFWxCskemvy97ftkv/fwUI7mQARAQAB
  19. tCJNZXRhc3Bsb2l0IDxtZXRhc3Bsb2l0QHJhcGlkNy5jb20+iQI9BBMBCgAnAhsD
  20. BQsJCAcDBRUKCQgLBRYCAwEAAh4BAheABQJXyXj4BQkMrEd3AAoJEM37X6UgB7lU
  21. GBAP/2h3l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dksvQ6cVZqaBt4g2hq78r
  53. Eq+ZyncUD2z3eXXrlVheqJdXZXoayQFaTo4iIAc7wbraZZ6mDr6mxxFMlUqO2qxT
  54. h3RIcafYvaF7yUDA
  55. =hQKe
  56. -----END PGP PUBLIC KEY BLOCK-----
  57. EOF
  58. }
  59.  
  60. install_deb() {
  61.   LIST_FILE=/etc/apt/sources.list.d/metasploit-framework.list
  62.   PREF_FILE=/etc/apt/preferences.d/pin-metasploit.pref
  63.   if [ ! -f $LIST_FILE ]; then
  64.     echo -n "Adding metasploit-framework to your repository list.."
  65.     echo "deb $DOWNLOAD_URI/apt lucid main" > $LIST_FILE
  66.     print_pgp_key | apt-key add -
  67.   fi
  68.   if [ ! -f $PREF_FILE ]; then
  69.     mkdir -p /etc/apt/preferences.d/
  70.     cat > $PREF_FILE <<EOF
  71. Package: metasploit*
  72. Pin: origin downloads.metasploit.com
  73. Pin-Priority: 1000
  74. EOF
  75.   fi
  76.   echo -n "Updating package cache.."
  77.   apt-get update > /dev/null
  78.   echo "OK"
  79.   echo "Checking for and installing update.."
  80.   apt-get install -y --force-yes metasploit-framework
  81. }
  82.  
  83. install_rpm() {
  84.   echo "Checking for and installing update.."
  85.   REPO_FILE=/etc/yum.repos.d/metasploit-framework.repo
  86.   GPG_KEY_FILE=/etc/pki/rpm-gpg/RPM-GPG-KEY-Metasploit
  87.   if [ ! -f $REPO_FILE ]; then
  88.     echo -n "Adding metasploit-framework to your repository list.."
  89.  
  90.     cat > /etc/yum.repos.d/metasploit-framework.repo <<EOF
  91. [metasploit]
  92. name=Metasploit
  93. baseurl=$DOWNLOAD_URI/rpm
  94. gpgcheck=1
  95. gpgkey=file://$GPG_KEY_FILE
  96. enabled=1
  97. EOF
  98.     print_pgp_key > ${GPG_KEY_FILE}
  99.   fi
  100.   yum install -y metasploit-framework
  101. }
  102.  
  103. install_pkg()
  104. {
  105.   (
  106.     cd ~/Downloads
  107.  
  108.     echo "Downloading package..."
  109.     curl -O "$DOWNLOAD_URI/osx/metasploitframework-latest.pkg"
  110.  
  111.     echo "Checking signature..."
  112.  
  113.     if pkgutil --check-signature metasploitframework-latest.pkg; then
  114.       echo "Installing package..."
  115.       installer -pkg metasploitframework-latest.pkg -target /
  116.     fi
  117.  
  118.     echo "Cleaning up..."
  119.     rm -fv metasploitframework-latest.pkg
  120.   )
  121. }
  122.  
  123. DOWNLOAD_URI=http://downloads.metasploit.com/data/releases/metasploit-framework
  124. PKGTYPE=unknown
  125. ID=`id -u`
  126.  
  127. if [ -f /etc/redhat-release ] ; then
  128.   PKGTYPE=rpm
  129. elif [ -f /etc/system-release ] ; then
  130.   # If /etc/system-release is present, this is likely a distro that uses RPM.
  131.   PKGTYPE=rpm
  132. else
  133.   if uname -sv | grep 'Darwin' > /dev/null; then
  134.     PKGTYPE=pkg
  135.   else
  136.     PKGTYPE=deb
  137.   fi
  138. fi
  139.  
  140. if [ "$ID" -ne 0 ]; then
  141.   if ! hash sudo 2>/dev/null; then
  142.     echo "This script must be executed as the 'root' user or with sudo"
  143.     exit 1
  144.   else
  145.     echo "Switching to root user to update the package"
  146.     sudo -E $0 $@
  147.     exit 0
  148.   fi
  149. fi
  150.  
  151. case $PKGTYPE in
  152.   deb)
  153.     install_deb
  154.     ;;
  155.   rpm)
  156.     install_rpm
  157.     ;;
  158.   *)
  159.     install_pkg
  160. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement