Contenidos
Servidor (recibe el contenido de la DLL y la almacena en un fichero, carga la DLL y ejecuta un método)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
## Server $ip = New-Object System.Net.IPEndPoint ([IPAddress]::Loopback,0) $udp = New-Object System.Net.Sockets.UdpClient 2020 [System.IO.File]::WriteAllBytes('C:\Users\juan\copiadll.dll',$udp.Receive([ref]$ip)) $udp.Close() $carga = [Reflection.Assembly]::LoadFile("C:\Users\juan\copiadll.dll") # Cargar la DLL recibida ## Ver el nombre de los métodos declarados $carga | select ExportedTypes [ClassLibrary3.Class1].DeclaredMethods.Name [ClassLibrary3.Class1]::AbrirNotepad() [ClassLibrary3.Class1]::AbrirPaint() |
Cliente (envía la DLL)
1 2 3 4 5 6 7 8 9 10 |
## Cliente $bytes = [System.IO.File]::ReadAllBytes('C:\Users\juan\source\repos\ClassLibrary3\ClassLibrary3\bin\Debug\ClassLibrary3.dll') $ip = New-Object System.Net.IPEndPoint ([IPAddress]::Loopback,2020) $udp = New-Object System.Net.Sockets.UdpClient $udp.Send($bytes,$bytes.length,$ip) | Out-Null $udp.Close() |