• 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

Enviar varios mensajes entre un cliente y un servidor utilizando el mismo canal de comunicación por UDP en PowerShell (hacerlo de forma simple)

Contenidos

  • 1 Servidor
  • 2 Cliente

Servidor

PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
##Server
$port=2021
$endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Any,$port)
$udpclient=new-Object System.Net.Sockets.UdpClient $port
 
$content=$udpclient.Receive([ref]$endpoint)
$convert=[Text.Encoding]::ASCII.GetString($content)
$convert
 
$content=$udpclient.Receive([ref]$endpoint)
$convert=[Text.Encoding]::ASCII.GetString($content)
$convert
 
$udpclient.Close()

Cliente

PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
##Cliente
$port=2021
$endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Loopback,$port)
$udpclient=new-Object System.Net.Sockets.UdpClient
 
$val="user*pass"
$b=[Text.Encoding]::ASCII.GetBytes($val.ToString())
$bytesSent=$udpclient.Send($b,$b.length,$endpoint)
 
$val="user*pass2"
$b=[Text.Encoding]::ASCII.GetBytes($val.ToString())
$bytesSent=$udpclient.Send($b,$b.length,$endpoint)
Publicado el día 23 de enero de 2021

CATEGORÍAS

PowerShell, Red

ETIQUETAS

.NET, ASCII.GetBytes, IPAddress, Jesús Niño, Jesús Niño Camazón, Length, New-Object, Server, Sockets, System.Net.IPEndPoint, System.Net.Sockets.UdpClient, Text.Encoding, ToString, UDP, User

MÁS

  • Ejercicios de seguridad: simular el funcionamiento de una VPN desde PowerShell
  • 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: enviar el código de una página web mediante UDP entre un cliente y un servidor después de realizar una comprobación del nombre de usuario
  • 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
  • Programación de comunicaciones en red (Programación de servicios y procesos)