Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Extended passive mode to the core ftp module. #11798

Merged
merged 1 commit into from
Jun 7, 2019

Conversation

bigendiansmalls
Copy link
Contributor

@bigendiansmalls bigendiansmalls commented Apr 30, 2019

Extended passive mode (EPSV), as documented in RFC2428 is similar to the PASSive mode in that it requests that the server open a port and wait for a data connection. However, in unlike PASSive mode, Extended Passive mode returns only the port on which the server listens for the data connection, not the IP + Port. The client is expected to use the existing IP (e.g. the one it used to create the initial control channel connection) to connect to the new data port.

Where this becomes important is if the server is behind some type of natting device, EPSV will work in this case, PASS may not.

Existing example using PASSive mode (how MSF currently works)

User 192.168.1.1
Server public ip: 100.25.25.25
Server private ip: 170.20.20.1

  • User -> AWS server via public IP via FTP
  • Connection 192.168.1.1 - EST - 100.25.25.25 (nat'd 170.20.20.1)
  • User switches to standard passive move (PASV)
  • Server replies with IP & Port to connect to (e.g. 170.20.20.1 port: 1367)
  • User issues any data command (ls, put, get, etc.)
  • User ftp client tries to connect to 170.20.20.1:1367 and fails.

Screenshot of the above

image

Using EPSV

Same setup as above

  • User -> AWS server via public IP via FTP
  • Connection 192.168.1.1 - EST - 100.25.25.25 (nat'd 170.20.20.1)
  • User switches to extended passive move (EPSV) via Advanced Option (set PassiveMode true)
  • Server replies with Port only (no IP) to connect to (e.g. port: 1367)
  • User issues any data command (ls, put, get, etc.)
  • User ftp client tries to connect to original IP + data port 100.25.25.25:1367 and succeeds.

Screenshot of the above

image

Verification (using any Ftp-based exploit)

  • Start msfconsole
  • use exploit/mainframe/ftp/ftp_jcl_creds
  • set payload cmd/mainframe/apf_privesc_jcl
  • set ftpuser user
  • set ftppass password
  • set apflib HLQ.LINKLIB
  • set rhosts 127.0.0.1

Other Screenshots

image

Extended passive mode (EPSV), as documented in RFC2428
is similar to the PASSive mode in that it requests that
the server open a port and wait for a data connection.
However, in unlike PASSive mode, Extended Passive mode
returns only the port on which the server listens for
the data connection, not the IP + Port.  The client is
expected to use the existing IP (e.g. the one it used to
create the initial control channel connection) to connect
to the new data port.

Where this becomes important is if the server is behind
some type of natting device, EPSV will work in this case,
PASS may not.
@bigendiansmalls bigendiansmalls marked this pull request as ready for review April 30, 2019 18:57
@busterb busterb self-assigned this May 2, 2019
@bigendiansmalls
Copy link
Contributor Author

Hey @busterb any questions on this one?

@busterb
Copy link
Member

busterb commented Jun 7, 2019

I didn't have the exact target, but this works fine for me. Thanks @bigendiansmalls

@busterb busterb merged commit 3289d89 into rapid7:master Jun 7, 2019
busterb added a commit that referenced this pull request Jun 7, 2019
Merge remote-tracking branch 'upstream/pr/11798' into upstream-master
@busterb
Copy link
Member

busterb commented Jun 7, 2019

Release Notes

The Metasploit FTP client (EPSV) now includes Extended Passive Mode support which enables it to more easily traverse a NAT than with regular passive mode.

msjenkins-r7 pushed a commit that referenced this pull request Jun 7, 2019
Merge remote-tracking branch 'upstream/pr/11798' into upstream-master
@bigendiansmalls
Copy link
Contributor Author

Cheers.

@bigendiansmalls bigendiansmalls deleted the ftp_epsv_support branch June 7, 2019 20:15
@tdoan-r7 tdoan-r7 added the rn-enhancement release notes enhancement label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants