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 ClamAV Remote Command Transmitter #6980

Merged
merged 9 commits into from Jun 22, 2016

Conversation

bwatters-r7
Copy link
Contributor

@bwatters-r7 bwatters-r7 commented Jun 15, 2016

What This Module Does

This module takes advantage of a possible misconfiguration in the ClamAV service on release 0.99.2. If the service is tied to a socket, the ClamAV service listens for commands on all addresses; this module connects to the ClamAV service port and sends the proper commands for VERSION and SHUTDOWN.

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • use auxiliary/admin/misc/clamav_control
  • set rhost xxx.xxx.xxx.xxx
  • set action VERSION
  • run
  • Verify It returns the correct version
  • set action SHUTDOWN
  • run
  • Verify It shuts down the service
  • set action VERSION
  • run
  • Verify It does not return a version (Should timeout)

@bwatters-r7
Copy link
Contributor Author

@wvu-r7 can you add a little bit of a description on how to set up the ClamAV so it is vulnerable?

rescue Rex::ConnectionRefused, Rex::ConnectionTimeout, Rex::HostUnreachable => e
fail_with(Failure::Unreachable, e)
rescue EOFError
print_error('Successfully shut down ClamAV Service')
Copy link
Contributor

Choose a reason for hiding this comment

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

If shutting down ClamAV is the intention, then I guess it should be print_good()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Derp.

@nixawk
Copy link
Contributor

nixawk commented Jun 16, 2016

ClamAV Lab Setup

debian / ubuntu

$ sudo apt-get install clamav clamav-daemon
$ sudo freshclam
$ sudo clamd --config-file=/etc/clamav/clamd.conf

If clamd fails to listen on port 3310, please add the following content in /etc/clamav/clamd.conf

# TCP port address.
# Default: no
TCPSocket 3310

# TCP address.
# By default we bind to INADDR_ANY, probably not wise.
# Enable the following to provide some degree of protection
# from the outside world.
# Default: no
TCPAddr 0.0.0.0

# Maximum length the queue of pending connections may grow to.
# Default: 15
MaxConnectionQueueLength 30

# Clamd uses FTP-like protocol to receive data from remote clients.
# If you are using clamav-milter to balance load between remote clamd daemons
# on firewall servers you may need to tune the options below.

# Close the connection when the data size limit is exceeded.
# The value should match your MTA's limit for a maximum attachment size.
# Default: 10M
StreamMaxLength 55M

# Limit port range.
# Default: 1024
#StreamMinPort 30000
# Default: 2048
#StreamMaxPort 32000

# Maximum number of threads running at the same time.
# Default: 10
MaxThreads 50

# Waiting for data from a client socket will timeout after this time (seconds).
# Value of 0 disables the timeout.
# Default: 120
ReadTimeout 300

# Waiting for a new job will timeout after this time (seconds).
# Default: 30
#IdleTimeout 60

# Maximum depth directories are scanned at.
# Default: 15
#MaxDirectoryRecursion 20

@bwatters-r7
Copy link
Contributor Author

Thanks, @wchen-r7, @join-us; great points!
I added the suggested user documentation and changed that print statement.
Then, I realized I screwed up my tests...... so....... fixed that, too.
Please let me know if you notice anything else.

require 'msf/core'

class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::Tcp
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to see this utilize Msf::Auxiliary::Scanner so you can more easily run this against larger swaths of targets without additional work.

@bwatters-r7
Copy link
Contributor Author

@jhart-r7 Thanks for the suggestion to make it a scanner! New version is now a scanner.

@wchen-r7
Copy link
Contributor

@join-us I'm trying to set up the box on Ubuntu, but I'm getting this:

$ sudo clamd --config-file=/etc/clamav/clamd.conf
ERROR: initgroups() failed

Any suggestions?

@wchen-r7
Copy link
Contributor

@join-us Never mind. I did this instead:

sudo /etc/init.d/clamav-daemon start

@wchen-r7 wchen-r7 self-assigned this Jun 22, 2016
@wchen-r7
Copy link
Contributor

Verified:

msf auxiliary(clamav_control) > run

[+] 192.168.1.203:3310    - ClamAV 0.98.7/21772/Wed Jun 22 12:54:15 2016

[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(clamav_control) > 
...
msf auxiliary(clamav_control) > run

[+] 192.168.1.203:3310    - Successfully shut down ClamAV Service
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(clamav_control) > set action VERSION
action => VERSION
msf auxiliary(clamav_control) > run

[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(clamav_control) >

@wchen-r7 wchen-r7 merged commit c02a05f into rapid7:master Jun 22, 2016
wchen-r7 added a commit that referenced this pull request Jun 22, 2016
@wvu
Copy link
Contributor

wvu commented Jun 22, 2016

Congrats on your first module, @bwatters-r7!! History has been made!

@wchen-r7 wchen-r7 added this to the v4.12.0-2016062701 milestone Jun 29, 2016
@bwatters-r7 bwatters-r7 deleted the feature/clamav branch January 29, 2019 19:43
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