• 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 (nivel medio)
  • Libro de PowerShell (nivel avanzado)
  • 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

  • Servidor
  • 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, HTTP, HTTPS, iOS, IP, IPAddress, iw, iwr, Jesús Niño, Jesús Niño Camazón, Length, New-Object, Path, Proxy, Server, socket, Sockets, System.Net.IPEndPoint, System.Net.Sockets.UdpClient, Text.Encoding, UDP

MÁS

  • Enviar un nombre de usuario a un servidor con UDP y si es correcto, el servidor responde al cliente con el contenido de una página web que el cliente abre con Google Chrome
  • 12. Gestión de una web con WordPress y PowerShell (nivel intermedio)
  • Enviar un fichero junto con su hash entre un cliente y un servidor por UDP desde PowerShell y verificar que el hash es correcto cuando lo recibe el servidor además realizar un login y…
  • Realizar una comunicación entre dos ordenadores por UDP desde PowerShell
  • Ejercicios de seguridad: realizar una comunicación UDP segura (utilizando Cryptographic Message Syntax)
  • Ejercicios de PowerShell: obtener información sobre el sistema operativo y enviarla por la red
Jesusninoc utiliza cookies: saber más aquí.