def main()

in cortado/rtas/network_connection_iexplore_rundll32.py [0:0]


def main():
    EXE_FILE = _common.get_resource_path("bin/renamed_posh.exe")
    PS1_FILE = _common.get_resource_path("bin/Invoke-ImageLoad.ps1")
    RENAMER = _common.get_resource_path("bin/rcedit-x64.exe")

    rundll32 = "C:\\Users\\Public\\rundll32.exe"
    iexplore = "C:\\Users\\Public\\iexplore.exe"
    user32 = "C:\\Windows\\System32\\user32.dll"
    dll = "C:\\Users\\Public\\IEProxy.dll"
    ps1 = "C:\\Users\\Public\\Invoke-ImageLoad.ps1"
    rcedit = "C:\\Users\\Public\\rcedit.exe"
    _common.copy_file(user32, dll)
    _common.copy_file(PS1_FILE, ps1)
    _common.copy_file(RENAMER, rcedit)
    _common.copy_file(EXE_FILE, rundll32)
    _common.copy_file(EXE_FILE, iexplore)

    log.info("Modifying the OriginalFileName attribute")
    _ = _common.execute_command([rcedit, dll, "--set-version-string", "OriginalFilename", "IEProxy.dll"])

    log.info("Loading IEProxy.dll")
    _ = _common.execute_command([rundll32, "-c", f"Import-Module {ps1}; Invoke-ImageLoad {dll}"], timeout_secs=10)

    _ = _common.execute_command([iexplore, "/c", "echo", "-Embedding", f";{iexplore}"], timeout_secs=2)
    _ = _common.execute_command(
        [iexplore, "/c", "Test-NetConnection -ComputerName google.com -Port 443"], timeout_secs=10
    )

    _common.remove_files([dll, ps1, rcedit, rundll32, iexplore])