Skip to content

Instantly share code, notes, and snippets.

@mwjcomputing
Created November 15, 2012 14:34
Show Gist options
  • Save mwjcomputing/4078917 to your computer and use it in GitHub Desktop.
Save mwjcomputing/4078917 to your computer and use it in GitHub Desktop.
Packet Fun
$Port = 80
$IPAddress = "10.0.1.95"
$Address = [System.Net.IPAddress]::Parse($IPAddress)
$EndPoint = New-Object System.Net.IPEndPoint $Address, $Port
$AddressFamily = [System.Net.Sockets.AddressFamily]::InterNetwork
$SocketType = [System.Net.Sockets.SocketType]::Dgram
$ProtocolType = [System.Net.Sockets.ProtocolType]::Udp
$Socket = New-Object System.Net.Sockets.Socket $AddressFamily, $SocketType, $ProtocolType
$Socket.TTL = 20
$Socket.Connect($EndPoint)
$Encoding = [System.Text.Encoding]::ASCII
$Message = "BLAH `n"*45
$Buffer = $Encoding.GetBytes($Message)
$Socket.Send($Buffer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment