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

Add citrix_directory_traversal module to /modules/auxiliary/scanner/h… #12813

Merged
merged 3 commits into from
Jan 14, 2020
Merged

Add citrix_directory_traversal module to /modules/auxiliary/scanner/h… #12813

merged 3 commits into from
Jan 14, 2020

Conversation

ErikWynter
Copy link
Contributor

About

This change adds a new module to /modules/auxiliary/scanner/http/ that can be used to verify whether or not a web server is vulnerable to CVE-2019-19781 - a directory traversal in in Citrix Application Delivery Controller (ADC) and Gateway 10.5, 11.1, 12.0, 12.1, and 13.0. For more info about this vulnerability, see: https://nvd.nist.gov/vuln/detail/CVE-2019-19781

Vulnerable System

Citrix ADC (NetScalers) systems vulnerable to directory traversal (CVE-2019-19781).

Verification Steps

  1. Select a webserver to target.
  2. Do: use auxiliary/scanner/http/citrix_directory_traversal
  3. Do: set RHOSTS [target IP or hostname]
  4. Do: run
  5. The module will issue an HTTP GET request for [TARGET]/vpn/../vpns/cfg/smb.conf. If HTTP response code 200 is received, it will indicate that the target is vulnerable to CVE-2019-19781.

Options

  1. Proxies . This option is not set by default.
  2. RPORT . The default setting is 80. To use: set RPORT [target port, default is 80]
  3. SSL . The default setting is false.
  4. THREADS . The default setting is 1.
  5. VHOST . This option is not set by default.

Scenarios

msf5 auxiliary(scanner/http/citrix_directory_traversal) > run

[*] Found 127.0.0.1/vpn/../vpns/cfg/smb.conf.
[+] The target is vulnerable to CVE-2019-19781.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

@wvu wvu self-assigned this Jan 12, 2020
@wvu wvu mentioned this pull request Jan 13, 2020
2 tasks
@wvu
Copy link
Contributor

wvu commented Jan 13, 2020

Hi! Thanks for this. We'll be making some final changes to the module and landing with #12816, using this module as the exploit's check method, if possible. I'll let you know when I'm ready to merge this. Thanks!

@ErikWynter
Copy link
Contributor Author

Hi! Thanks for your message. Please let us know if we can help with additional documentation or anything else at this stage. And it would indeed be great if you could keep us updated about when and in what form you will be including the module. Thanks in advance!

@wvu
Copy link
Contributor

wvu commented Jan 13, 2020

@kalba-security: If you could write module documentation, that would be a task off my list.

FYI, there are some sweeping functional and stylistic changes that need to be done in order to merge this. I'll keep you posted before anything hits master, but we have a bit of a deadline here. Thank you.

def initialize
super(
'Name' => 'Citrix ADC Directory Traversal',
'Description' => 'This module exploits a directory traversal vulnerability (CVE-2019-19781) within Citrix ADC (NetScalers). It requests the smb.conf file located in the /vpns/cfg directory by issuing the request /vpn/../vpns/cfg/smb.conf. It then checks if the server is vulnerable by looking for the presense of a "global" variable in smb.conf, which this file should always contain.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the code to check for global, since this check is not currently present. Please stand by until I can push my commits for viewing. Thanks!

@ErikWynter
Copy link
Contributor Author

ErikWynter commented Jan 13, 2020 via email

@wvu
Copy link
Contributor

wvu commented Jan 13, 2020

@kalba-security: Feel free to push the docs! Thanks!

@wvu
Copy link
Contributor

wvu commented Jan 13, 2020

You ROCK! Thank you so much. I'll update the docs if the code changes can be reflected.

@wvu
Copy link
Contributor

wvu commented Jan 13, 2020

Here is the updated code: master...wvu-r7:pr/12813. I'm happy to explain and justify anything. I will need to merge all of this in the next couple hours.

@altjx
Copy link
Contributor

altjx commented Jan 13, 2020

Looks good!!! @wvu-r7. Quick question, we're not allowed to put email addresses or Twitter handles in by chance are we? Can't remember if that was restricted or not.

@ErikWynter
Copy link
Contributor Author

ErikWynter commented Jan 13, 2020

Yeah looks great @wvu-r7!! In the documentation I already referenced the global check you added btw.

@wvu
Copy link
Contributor

wvu commented Jan 13, 2020

@altjx: Nope, but it's okay to tack them on as a comment! What Twitter handles do y'all want to use? It's easier to avoid conflicts if I make the commit. Sorry for the situation. :(

@wvu
Copy link
Contributor

wvu commented Jan 13, 2020

Btw, we're planning to convert all CVE references to NVD soon enough, since CVE Details has been... lacking. So I removed the NVD URL reference for now.

@altjx
Copy link
Contributor

altjx commented Jan 13, 2020

Sounds great! We can use the following:

No worries! I'm on a plane anyway so I wouldn't be able to do it LOL. Thanks so much!

@wvu
Copy link
Contributor

wvu commented Jan 13, 2020

I've improved the smb.conf check and added a PATH option. There are many traversal options, including obfuscation...

@altjx
Copy link
Contributor

altjx commented Jan 13, 2020

Gotcha!

wvu added a commit that referenced this pull request Jan 14, 2020
@wvu wvu merged commit c30cd8e into rapid7:master Jan 14, 2020
@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

Release Notes

This adds a scanner for CVE-2019-19781, a directory traversal vulnerability in Citrix Application Delivery Controller (NetScaler).

msjenkins-r7 pushed a commit that referenced this pull request Jan 14, 2020
@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

Commits I've added:

f1cc40b
d7deb4e
94b6b6d
332afe8
3354e69
4ac7f81
99235c7

Thanks again!

@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

Off to finish #12816!

@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

@altjx
Copy link
Contributor

altjx commented Jan 14, 2020

Thanks so much!! @wvu-r7 I apologize but I typod my Twitter handle. should have been @altonjx sorry about that

@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

Doh! No problem, let me fix that for ya.

@altjx
Copy link
Contributor

altjx commented Jan 14, 2020

Thanks again!! 🙏🏽

@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

All fixed. :-)


Because vulnerable servers allow for directory traversal, they will accept the request `GET /vpn/../vpns/` and process it as a request for `GET /vpns/`, a directory that contains PERL scripts that can be targeted to allow for limited file writing on the vulnerable host.

This module checks if a target server is vulnerable by issuing an HTTP GET request for `/vpn/../vpns/cfg/smb.conf`and then checking the response for `global`since this configuration file should contain global variables. If ``global``is found, the server is vulnerable to CVE-2019-19781.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This module checks if a target server is vulnerable by issuing an HTTP GET request for `/vpn/../vpns/cfg/smb.conf`and then checking the response for `global`since this configuration file should contain global variables. If ``global``is found, the server is vulnerable to CVE-2019-19781.
This module checks if a target server is vulnerable by issuing an HTTP GET request for `/vpn/../vpns/cfg/smb.conf`and then checking the response for `global` since this configuration file should contain global variables. If `global` is found, the server is vulnerable to CVE-2019-19781.

Comment on lines +24 to +28
1. `Proxies` . This option is not set by default.
2. `RPORT` . The default setting is `80`. To use: `set RPORT [PORT]`
3. `SSL` . The default setting is `false`.
4. `THREADS` . The default setting is `1`.
5. `VHOST` . This option is not set by default.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting is inconsistent with existing documentation. See examples:

Comment on lines +21 to +22
'Erik Wynter',
'altonjx',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traditionally, the author's role is provided in comments. ie:

[
  'someone', # discovery and PoC
  'someone else', # metasploit
]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one's fair.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing over in #12816.

@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

@bcoles: Please review against master. Added commits are in #12813 (comment). I wasn't able to push to their branch, and a PR wouldn't make my deadline. If you have further changes, I would appreciate a PR!

@bcoles
Copy link
Contributor

bcoles commented Jan 14, 2020

@bcoles: Please review against master. Added commits are in #12813 (comment). I wasn't able to push to their branch, and a PR wouldn't make my deadline. If you have further changes, I would appreciate a PR!

A case statement seems a little ridiculous for a single branch conditional. Future proofing?

Also, turi.to_s.end_with?('smb.conf') would be preferred over a regex for readability.

@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

Yes, future-proofing. Indeed ridiculous for a single branch. I have other cases I would like to add, but I reached a deadline.

ETA: It was originally just if and end_with?. Agreed that it read better!

@wvu
Copy link
Contributor

wvu commented Jan 14, 2020

Screw it. I added the PATH option. Reverted to if/end_with? over in #12816.

@alanyee
Copy link

alanyee commented Apr 9, 2020

Since it's not documentation anywhere else, the files have been renamed to
https://github.com/rapid7/metasploit-framework/blob/master/documentation/modules/auxiliary/scanner/http/citrix_dir_traversal.md
https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/http/citrix_dir_traversal.rb

So, use

use auxiliary/scanner/http/citrix_dir_traversal

@wvu
Copy link
Contributor

wvu commented Apr 10, 2020

The files were renamed while merging into master, so if anyone has been grabbing the file from this PR, they should update normally.

See f1cc40b from #12813 (comment), tbh.

I understand everyone wants the code, but PRs are technically WIP until they're merged. Updating is the responsibility of the user in that case. So thanks for dropping a note! The rest of y'all are slackers. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants