• EnglishSpanishGermanFrenchPolishChinese (Traditional)


EnglishSpanishGermanFrenchPolishChinese (Traditional)

Operating systems, scripting, PowerShell and security

Operating systems, software development, scripting, PowerShell tips, network and security

Menú principal
  • Categorías
  • Cursos
  • Libro de PowerShell
  • Lo mejor
  • Lo último
  • Proyectos
  • Contactar
Ir al contenido

Ejercicios de seguridad: simular el funcionamiento de un proxy caché mediante una conexión UDP entre un cliente y un servidor que solicitan una imagen y si la imagen ya se ha descargado se indica en un mensaje

Contenidos

  • 1 Servidor
  • 2 Cliente

Servidor

PowerShell
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
##Server
$port=2020
$endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Any,$port)
$udpclient=new-Object System.Net.Sockets.UdpClient $port
$content=$udpclient.Receive([ref]$endpoint)
$udpclient.Close()
$imagen = [Text.Encoding]::ASCII.GetString($content)
if(Test-Path $imagen)
{
    $port=2020
    $endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Loopback,$port)
    $udpclient=new-Object System.Net.Sockets.UdpClient
    $b=[Text.Encoding]::ASCII.GetBytes('esta perro')
    $bytesSent=$udpclient.Send($b,$b.length,$endpoint)
    $udpclient.Close()
}
else
{
    iwr "https://www.jesusninoc.com/wp-content/uploads/2017/01/Cliente-Ejecutar-un-cmdlet-remotamente-en-un-equipos-utilizando-sockets-UDP.png" -OutFile perro.jpg
    $port=2020
    $endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Loopback,$port)
    $udpclient=new-Object System.Net.Sockets.UdpClient
    $b=[Text.Encoding]::ASCII.GetBytes('no estaba perro')
    $bytesSent=$udpclient.Send($b,$b.length,$endpoint)
    $udpclient.Close()
}

Cliente

PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
##Client
$port=2020
$endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Loopback,$port)
$udpclient=new-Object System.Net.Sockets.UdpClient
$b=[Text.Encoding]::ASCII.GetBytes('perro.jpg')
$bytesSent=$udpclient.Send($b,$b.length,$endpoint)
$udpclient.Close()
 
$port=2020
$endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Any,$port)
$udpclient=new-Object System.Net.Sockets.UdpClient $port
$content=$udpclient.Receive([ref]$endpoint)
$udpclient.Close()
$imagen = [Text.Encoding]::ASCII.GetString($content)
$imagen
Publicado el día 15 de enero de 2021

CATEGORÍAS

PowerShell, Red

ETIQUETAS

.NET, ASCII.GetBytes, client, Ejercicios de seguridad, HTTPS, IPAddress, iwr, Jesús Niño, Jesús Niño Camazón, Length, New-Object, Path, Proxy, Server, Sockets, System.Net.IPEndPoint, System.Net.Sockets.UdpClient, Text.Encoding, UDP

MÁS

  • Enviar un mensaje a un servidor con UDP y que el servidor responda con "Hola cliente" independientemente del nombre del usuario
  • Enviar varios mensajes entre un cliente y un servidor utilizando el mismo canal de comunicación por UDP en PowerShell (hacerlo de forma simple)
  • Conexión de sistemas en red (Sistemas informáticos)
  • Ejercicios de PowerShell: registrar un evento cuando se logre realizar una conexión entre un cliente y un servidor mediante UDP (almacenar la dirección IP de la conexión del cliente o del servidor)
  • Ejercicios de PowerShell: realizar operaciones en un equipo remoto
  • Programación de comunicaciones en red (Programación de servicios y procesos)