Skip to content

Modifying a frozen string cause an error in Exploit::Remote::Ftp mixin #21597

Description

@cdelafuente-r7

Since we are requiring # frozen_string_literal: true on new files now (see AGENTS.md). The recv_ftp_resp method in the Exploit::Remote::Ftp mixin is failing. This method tries to modify @ftpbuff string (e.g. @ftpbuff << resp, @ftpbuff << left).

Steps to reproduce

How'd you do it?

  1. Start a vsftp server with docker:
docker run -d --rm -v ${PWD}:/home/vsftpd -p 2020:20 -p 2121:21 -e FTP_USER=myuser -e FTP_PASS=mypass --name vsftpd fauria/vsftpd
  1. Add # frozen_string_literal: true at the top of the modules/auxiliary/dos/ftp/vsftpd_232.rb file.
  2. Run msfconsole
  3. Load the module: use auxiliary/dos/ftp/vsftpd_232
  4. run it: run verbose=true rhosts=127.0.0.1 rport=2121 username=myuser password=mypass

Were you following a specific guide/tutorial or reading documentation?

No.

Expected behavior

The module runs fine.

Current behavior

It breaks:

msf auxiliary(dos/ftp/vsftpd_232) > run verbose=true rhosts=127.0.0.1 rport=2121 username=myuser password=mypass
[*] Running module against 127.0.0.1
[*] 127.0.0.1:2121 - Running automatic check ("set AutoCheck false" to disable)
[*] 127.0.0.1:2121 - Connecting to FTP server...
[*] 127.0.0.1:2121 - Connected to target FTP server
[*] 127.0.0.1:2121 - FTP banner: vsFTPd 3.0.2
[-] 127.0.0.1:2121 - Auxiliary failed: FrozenError can't modify frozen String: ""
[-] 127.0.0.1:2121 - Call stack:
[-] 127.0.0.1:2121 -   /home/msf/src/metasploit-framework/modules/auxiliary/dos/ftp/vsftpd_232.rb:81:in `block in check'
[-] 127.0.0.1:2121 -   <internal:kernel>:187:in `loop'
[-] 127.0.0.1:2121 -   /home/msf/src/metasploit-framework/modules/auxiliary/dos/ftp/vsftpd_232.rb:74:in `check'
[-] 127.0.0.1:2121 -   /home/msf/src/metasploit-framework/lib/msf/core/exploit/remote/auto_check.rb:43:in `with_prepended_auto_check'
[-] 127.0.0.1:2121 -   /home/msf/src/metasploit-framework/lib/msf/core/exploit/remote/auto_check.rb:20:in `run'

Metasploit version

Framework: 6.4.141-dev-81648e60715
Console  : 6.4.141-dev-81648e60715

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions