---
tags: 滲透, Metasploit
---
# Metasploit安裝與使用
環境:WSL Kali
## APT更新方法
https://askubuntu.com/a/1410768
```
wget https://apt.metasploit.com/metasploit-framework.gpg.key
gpg --no-default-keyring --keyring ./metasploit-framework_keyring.gpg --import metasploit-framework.gpg.key
gpg --no-default-keyring --keyring ./metasploit-framework_keyring.gpg --export > ./metasploit-framework.gpg
sudo mv ./metasploit-framework.gpg /etc/apt/trusted.gpg.d/
apt update
```
## 安裝Metasploit
環境Kali:
參考:
https://www.fosslinux.com/48112/install-metasploit-kali-linux.htm
安裝/更新Metasploit
```
sudo apt install metasploit-framework
```
Starting the Kali PostgreSQL service
以下指令調用將導入 Rapid7 簽名密鑰並為支持的 Linux 系統設置包。
```shell=
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb> msfinstall && chmod 755 msfinstall && ./msfinstall
```
其他平台請參考
https://techofide.com/blogs/how-to-install-metasploit-on-windows-and-linux-step-by-step-guide/
https://docs.rapid7.com/metasploit/installing-the-metasploit-framework/
## 加入支援Cipher aes256-cbc
https://security.stackexchange.com/questions/256053/configure-the-metasploit-ssh-client-to-support-aes256-cbc
1. 找出algorithms.rb 所在地
```
$ find /usr/share/metasploit-framework -type f -name algorithms.rb
/usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/net-ssh-6.1.0/lib/net/ssh/transport/algorithms.rb
```
2. Edit it and add cipher that you need, in **DEFAULT_ALGORITHMS/encryption** section:
在DEFAULT_ALGORITHMS/encryption中加入`aes256-cbc`即可
```
DEFAULT_ALGORITHMS = {
host_key: %w[ecdsa-sha2-nistp521-cert-v01@openssh.com
ecdsa-sha2-nistp384-cert-v01@openssh.com
ecdsa-sha2-nistp256-cert-v01@openssh.com
ecdsa-sha2-nistp521
ecdsa-sha2-nistp384
ecdsa-sha2-nistp256
ssh-rsa-cert-v01@openssh.com
ssh-rsa-cert-v00@openssh.com
ssh-rsa],
kex: %w[ecdh-sha2-nistp521
ecdh-sha2-nistp384
ecdh-sha2-nistp256
diffie-hellman-group-exchange-sha256
diffie-hellman-group14-sha1],
encryption: %w[aes256-ctr aes192-ctr aes128-ctr aes256-cbc],
```