private static void WakeFunction(string MAC_ADDRESS) { WOLClass client = new WOLClass(); client.Connect(new IPAddress(0xffffffff), 0x2fff); client.SetClientToBrodcastMode(); //set sending bites int counter = 0; //buffer to be send byte[] bytes = new byte[1024]; // more than enough :-) //first 6 bytes should be 0xFF for (int y = 0; y < 6; y++) { bytes[counter++] = 0xFF; } //now repeate MAC 16 times for (int y = 0; y < 16; y++) { int i = 0; for (int z = 0; z < 6; z++) { bytes[counter++] = byte.Parse(MAC_ADDRESS.Substring(i, 2), NumberStyles.HexNumber); i += 2; } } //now send wake up packet int reterned_value = client.Send(bytes, 1024); }
public override AttackerResult stab() { //Send network adapter MAC address over UDP 16 times // Prep input parameters if (MACaddress.Contains(':')) { MACaddress = MACaddress.Replace(":", ""); } /////////////////////////////////////////////////////////////////////// // Segments of code were copied from: // // http://www.codeproject.com/Articles/5315/Wake-On-Lan-sample-for-C // /////////////////////////////////////////////////////////////////////// WOLClass client = new WOLClass(); client.Connect(new IPAddress(0xffffffff), //255.255.255.255 i.e broadcast 0x2fff); // port=12287 let's use this one client.SetClientToBrodcastMode(); //set sending bites int counter = 0; //buffer to be send byte[] bytes = new byte[1024]; // more than enough :-) //first 6 bytes should be 0xFF for (int y = 0; y < 6; y++) { bytes[counter++] = 0xFF; } //now repeate MAC 16 times for (int y = 0; y < 16; y++) { int i = 0; for (int z = 0; z < 6; z++) { bytes[counter++] = byte.Parse(MACaddress.Substring(i, 2), NumberStyles.HexNumber); i += 2; } } //now send wake up packet int reterned_value = client.Send(bytes, 1024); return(attackerStatus); }
/// <summary> /// Send a WakeOnLan command /// </summary> /// <param name="IPAddr">Destination IP Address (e.g. 255.255.255.255 = broadcast)</param> /// <param name="Port">UDP Port</param> /// <param name="MAC_ADDRESS">MAC Address to wakeup</param> static public void WakeUp(IPAddress IPAddr, int Port, string MAC_ADDRESS) { try { WOLClass client = new WOLClass(); Regex oRegex = new Regex("[^a-fA-F0-9]"); MAC_ADDRESS = oRegex.Replace(MAC_ADDRESS, ""); client.Connect(IPAddr, //255.255.255.255 i.e broadcast Port); // port=12287 let's use this one client.SetClientToBrodcastMode(); //set sending bites int counter = 0; //buffer to be send byte[] bytes = new byte[1024]; // more than enough :-) //first 6 bytes should be 0xFF for (int y = 0; y < 6; y++) { bytes[counter++] = 0xFF; } //now repeate MAC 16 times for (int y = 0; y < 16; y++) { int i = 0; for (int z = 0; z < 6; z++) { bytes[counter++] = byte.Parse(MAC_ADDRESS.Substring(i, 2), NumberStyles.HexNumber); i += 2; } } //now send wake up packet int reterned_value = client.Send(bytes, 1024); } catch { } }
//MAC_ADDRESS should look like '013FA049' public void WakeFunction(string MAC_ADDRESS) { WOLClass client=new WOLClass(); client.Connect(new IPAddress(0xffffffff), //255.255.255.255 i.e broadcast 0x2fff); // port=12287 let's use this one client.SetClientToBrodcastMode(); //set sending bites int counter=0; //buffer to be send byte[] bytes=new byte[1024]; // more than enough :-) //first 6 bytes should be 0xFF for(int y=0;y<6;y++) bytes[counter++]=0xFF; //now repeate MAC 16 times for(int y=0;y<16;y++) { int i=0; for(int z=0;z<6;z++) { bytes[counter++]= byte.Parse(MAC_ADDRESS.Substring(i,2),System.Globalization.NumberStyles.HexNumber); i+=2; } } //now send wake up packet int reterned_value=client.Send(bytes,1024); }