GVKun编程网logo

利用PHP远程唤醒计算机,发送唤醒魔术包(利用php远程唤醒计算机,发送唤醒魔术包)

12

在本文中,我们将详细介绍利用PHP远程唤醒计算机,发送唤醒魔术包的各个方面,并为您提供关于利用php远程唤醒计算机,发送唤醒魔术包的相关解答,同时,我们也将为您带来关于airdroid怎么远程唤醒ai

在本文中,我们将详细介绍利用PHP远程唤醒计算机,发送唤醒魔术包的各个方面,并为您提供关于利用php远程唤醒计算机,发送唤醒魔术包的相关解答,同时,我们也将为您带来关于airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程、android – 如何远程唤醒手机?、c# 远程网络唤醒电脑(电脑远程开机+内网MAC和IP扫描)(附带源码+主板和Windows开启详细说明+外网远程唤醒方案)、golang 远程唤醒开机实例的有用知识。

本文目录一览:

利用PHP远程唤醒计算机,发送唤醒魔术包(利用php远程唤醒计算机,发送唤醒魔术包)

利用PHP远程唤醒计算机,发送唤醒魔术包(利用php远程唤醒计算机,发送唤醒魔术包)

这个功能得计算机主板和网卡支持才可以,具体请百度。 private function wakeOnLan($ip,$mac,$port){$addr_byte = explode('':'', $mac);$hw_addr = '''';for ($i=0; $i wakeOnLan($ip,$mac,7);} 本文标题:利用PHP远程唤醒计算机,发送唤醒魔术包 本文链接: ht

这个功能得计算机主板和网卡支持才可以,具体请百度。

	private function wakeOnLan($ip,$mac,$port){
		$addr_byte = explode('':'', $mac);
		$hw_addr = '''';
		for ($i=0; $i wakeOnLan($ip,$mac,7);
	}
登录后复制

本文标题:利用PHP远程唤醒计算机,发送唤醒魔术包

本文链接:http://www.maben.com.cn/archives/581.html转载请注明出处

airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程

airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程

手机打开AirDroid,

airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程

点击首页下方“个人”按钮,

airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程

点击“设置”,打开APP设置页面,

airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程

找到“快速远程唤醒”选项,打开开关,完成设置。

airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程

以上就是airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程的详细内容,更多请关注php中文网其它相关文章!

android – 如何远程唤醒手机?

android – 如何远程唤醒手机?

我想构建一个需要通过3G远程启动的Android应用程序(在通过套接字获得推送通知之后).

我做了一些研究,一旦屏幕关闭,它似乎变得非常复杂,也因为Android杀死空闲套接字.

是否有一个示例项目演示如何可靠地实现它?我找到了WakefulIntentService库,但它没有考虑到套接字需要保持活动状态.

另一种方法是定期轮询某个URL以获取唤醒信号,但这会在设备检测到需要启动应用程序之前引入较大的延迟,具体取决于轮询间隔.

解决方法:

你有没有看过GCM或parse.com发送和接收推送?

我不认为那些容易被杀死的人.

话虽如此,如果你还没有,你应该让你的套接字在服务中运行.然后它可以在后台独立于活动的活动运行,并且可以在设备启动时启动.此外,这将降低Android关闭它的可能性.

c# 远程网络唤醒电脑(电脑远程开机+内网MAC和IP扫描)(附带源码+主板和Windows开启详细说明+外网远程唤醒方案)

c# 远程网络唤醒电脑(电脑远程开机+内网MAC和IP扫描)(附带源码+主板和Windows开启详细说明+外网远程唤醒方案)

一、需求

1、人在公司坐,昨晚写的文档放在家中电脑忘记copy了,想要访问家中电脑拿到文档。

2、家中或公司中局域网内有某台电脑(或服务器)要开机,或者批量一键打开局域网内某些电脑

二、必备条件

1、网线连接电脑网口(wifi无线网卡无法网络唤醒)

2、网卡支持网络唤醒功能

三、设置

1、主板BIOS设置

目前测试过的主板:微星PRO Z690-A WIFI DDR4(MS-7D25)、技嘉B75M-D3V、技嘉B85M-D2V

下面以微星PRO Z690-A为例。

主板:微星PRO Z690-A WIFI DDR4

系统:Windows10

路由器:中兴AX5400,TPLink5600和7660

发包程序:C#,下面有源码,或者伸手党可以直接从下载链接获取发布好的应用程序

 开机狂按Del键进入微星BIOS,其他品牌DEL,ESC,F1,F2,F8,F9,F10,F12

  1. 高级–整合周边设备–网卡ROM启动,设置为允许
  2. 高级–电源管理设置–Eup 2013,设置为禁止
  3. 高级–唤醒事件设置–PCIE设备唤醒,设置为允许

2、网卡(Windows)设置

  1. 控制面板–所有控制面板项–网络连接
  2. 在网卡适配器点击鼠标右键–属性,弹出的属性对话框中
  3. 选择网络选项卡–配置
  4. 选择高级选项卡,将关机 网络唤醒设置为开启,将魔术封包唤醒设置为开启
  5. 电源管理选项卡,勾选下面三个选项,允许此设备唤醒计算机。
  6. 切换为电源管理选项,勾选允许此设备唤醒计算机。
  7. 关闭快速启动,右击开始按钮,点击“电源选项”,点击“选择电源按钮的功能”;点击“更改当前不可用的设置”,把“启用快速启动”勾选。(这条必须做

 

 

 

 3、后记

  1. 电脑网线连接网口处,电脑关机状态下有的会有黄灯常量,有的电脑不亮,都能唤醒
  2. 在设置网卡的时候发现没有关机 网络唤醒的选项的时候,有可能是网卡驱动或者网卡版本不同,没有此选项也能唤醒。

三、C#源码 

伸手党可以直接从下载链接获取发布好的应用程序,下载地址:

https://download.csdn.net/download/hwt0101/86781647

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.networkinformation;
using System.Net.sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RemotePowerOn
{
    public partial class Form1 : Form
    {
        //通过正则表达式设定MAC地址筛选标准,关于正则表达式请自行百度
        const string macCheckRegexString = @"^([0-9a-fA-F]{2})(([/\s:-][0-9a-fA-F]{2}){5})$";

        private static readonly Regex MacCheckRegex = new Regex(macCheckRegexString);
        public Form1()
        {
            InitializeComponent();
        }
        public static bool WakeUp(string mac)
        {
            //查看该MAC地址是否匹配正则表达式定义,(mac,0)前一个参数是指mac地址,后一个是从指定位置开始查询,0即从头开始
            if (MacCheckRegex.IsMatch(mac,0))
            {
                byte[] macByte = FormatMac(mac);
                WakeUpCore(macByte);
                return true;
            }

            return false;

        }

        private static void WakeUpCore(byte[] mac)
        {
            //发送方法是通过UDP
            UdpClient client = new UdpClient();
            //broadcast内容为:255,255,255.广播形式,所以不需要IP
            client.Connect(System.Net.IPAddress.broadcast,40000);
            //下方为发送内容的编制,6遍“FF”+17遍mac的byte类型字节。
            byte[] packet = new byte[17 * 6];
            for (int i = 0; i < 6; i++)
                packet[i] = 0xFF;
            for (int i = 1; i <= 16; i++)
                for (int j = 0; j < 6; j++)
                    packet[i * 6 + j] = mac[j];
            //唤醒动作
            int result = client.Send(packet,packet.Length);
        }

        private static byte[] FormatMac(string macInput)
        {
            byte[] mac = new byte[6];

            string str = macInput;
            //消除MAC地址中的“-”符号
            string[] sArray = str.Split('-');


            //mac地址从string转换成byte
            for (var i = 0; i < 6; i++)
            {
                var byteValue = Convert.ToByte(sArray[i],16);
                mac[i] = byteValue;
            }

            return mac;
        }
        private void button1_Click(object sender,EventArgs e)
        {
            string mac = textBox1.Text;
            WakeUp(mac);
            //WakeUp("25-D5-47-12-97-E2"); 
        }


        private void button2_Click(object sender,EventArgs e)
        {
            #region 方法1

            // Todo: Implement Functionality Here
            // Get my PC IP address
            Msg(string.Format("My IP : {0}",GetIPAddress()));
            // Get My PC MAC address
            Msg(string.Format("My MAC: {0}",GetMacAddress()));
            // Get My PC HostName
            Msg(string.Format("My HostName: {0}",Dns.GetHostName()));
            // Get all devices on network
            Dictionary<IPAddress,PhysicalAddress> all = GetAllDevicesOnLAN();
            foreach (keyvaluePair<IPAddress,PhysicalAddress> kvp in all)
            {
                Msg(string.Format("IP : {0}\n MAC {1}",kvp.Key,kvp.Value));
            }

            #endregion

            #region 方法2
            //GetIPAddress2();
            //foreach (var ip in ips)
            //{
            //    //Console.WriteLine(ip);
            //    Msg(ip);
            //}
            #endregion
        }

        #region MAC扫描方法1
        //public static void Main(string[] args)
        //{
        //	Console.WriteLine("Hello World!");

        //	// Todo: Implement Functionality Here
        //	// Get my PC IP address
        //	Console.WriteLine("My IP : {0}",GetIPAddress());
        //	// Get My PC MAC address
        //	Console.WriteLine("My MAC: {0}",GetMacAddress());
        //	// Get My PC HostName
        //	Console.WriteLine("My HostName: {0}",Dns.GetHostName());
        //	// Get all devices on network
        //	Dictionary<IPAddress,PhysicalAddress> all = GetAllDevicesOnLAN();
        //	foreach (keyvaluePair<IPAddress,PhysicalAddress> kvp in all)
        //	{
        //		Console.WriteLine("IP : {0}\n MAC {1}",kvp.Value);
        //	}

        //	Console.Write("Press any key to continue . . . ");
        //	Console.ReadKey(true);
        //}

        /// <summary>
        /// MIB_IPNETROW structure returned by GetIpNetTable
        /// DO NOT MODIFY THIS STRUCTURE.
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        struct MIB_IPNETROW
        {
            [MarshalAs(UnmanagedType.U4)]
            public int dwIndex;
            [MarshalAs(UnmanagedType.U4)]
            public int dwPhysAddrLen;
            [MarshalAs(UnmanagedType.U1)]
            public byte mac0;
            [MarshalAs(UnmanagedType.U1)]
            public byte mac1;
            [MarshalAs(UnmanagedType.U1)]
            public byte mac2;
            [MarshalAs(UnmanagedType.U1)]
            public byte mac3;
            [MarshalAs(UnmanagedType.U1)]
            public byte mac4;
            [MarshalAs(UnmanagedType.U1)]
            public byte mac5;
            [MarshalAs(UnmanagedType.U1)]
            public byte mac6;
            [MarshalAs(UnmanagedType.U1)]
            public byte mac7;
            [MarshalAs(UnmanagedType.U4)]
            public int dwAddr;
            [MarshalAs(UnmanagedType.U4)]
            public int dwType;
        }

        /// <summary>
        /// GetIpNetTable external method
        /// </summary>
        /// <param name="pIpNetTable"></param>
        /// <param name="pdwSize"></param>
        /// <param name="bOrder"></param>
        /// <returns></returns>
        [DllImport("IpHlpApi.dll")]
        [return: MarshalAs(UnmanagedType.U4)]
        static extern int GetIpNetTable(IntPtr pIpNetTable,[MarshalAs(UnmanagedType.U4)] ref int pdwSize,bool bOrder);

        /// <summary>
        /// Error codes GetIpNetTable returns that we recognise
        /// </summary>
        const int ERROR_INSUFFICIENT_BUFFER = 122;
        /// <summary>
        /// Get the IP and MAC addresses of all kNown devices on the LAN
        /// </summary>
        /// <remarks>
        /// 1) This table is not updated often - it can take some human-scale time
        ///    to notice that a device has dropped off the network,or a new device
        ///    has connected.
        /// 2) This discards non-local devices if they are found - these are multicast
        ///    and can be discarded by IP address range.
        /// </remarks>
        /// <returns></returns>
        private static Dictionary<IPAddress,PhysicalAddress> GetAllDevicesOnLAN()
        {
            Dictionary<IPAddress,PhysicalAddress> all = new Dictionary<IPAddress,PhysicalAddress>();
            // Add this PC to the list...
            all.Add(GetIPAddress(),GetMacAddress());
            int spaceForNetTable = 0;
            // Get the space needed
            // We do that by requesting the table,but not giving any space at all.
            // The return value will tell us how much we actually need.
            GetIpNetTable(IntPtr.Zero,ref spaceForNetTable,false);
            // Allocate the space
            // We use a try-finally block to ensure release.
            IntPtr rawTable = IntPtr.Zero;
            try
            {
                rawTable = Marshal.AllocCoTaskMem(spaceForNetTable);
                // Get the actual data
                int errorCode = GetIpNetTable(rawTable,false);
                if (errorCode != 0)
                {
                    // Failed for some reason - can do no more here.
                    throw new Exception(string.Format(
                        "Unable to retrieve network table. Error code {0}",errorCode));
                }
                // Get the rows count
                int rowsCount = Marshal.ReadInt32(rawTable);
                IntPtr currentBuffer = new IntPtr(rawTable.ToInt64() + Marshal.SizeOf(typeof(Int32)));
                // Convert the raw table to individual entries
                MIB_IPNETROW[] rows = new MIB_IPNETROW[rowsCount];
                for (int index = 0; index < rowsCount; index++)
                {
                    rows[index] = (MIB_IPNETROW)Marshal.PtrToStructure(new IntPtr(currentBuffer.ToInt64() +
                                                                                  (index * Marshal.SizeOf(typeof(MIB_IPNETROW)))
                                                                                 ),typeof(MIB_IPNETROW));
                }
                // Define the dummy entries list (we can discard these)
                PhysicalAddress virtualMAC = new PhysicalAddress(new byte[] { 0,0 });
                PhysicalAddress broadcastMAC = new PhysicalAddress(new byte[] { 255,255 });
                foreach (MIB_IPNETROW row in rows)
                {
                    IPAddress ip = new IPAddress(BitConverter.GetBytes(row.dwAddr));
                    byte[] rawMAC = new byte[] { row.mac0,row.mac1,row.mac2,row.mac3,row.mac4,row.mac5 };
                    PhysicalAddress pa = new PhysicalAddress(rawMAC);
                    if (!pa.Equals(virtualMAC) && !pa.Equals(broadcastMAC) && !IsMulticast(ip))
                    {
                        //Console.WriteLine("IP: {0}\t\tMAC: {1}",ip.ToString(),pa.ToString());
                        if (!all.ContainsKey(ip))
                        {
                            all.Add(ip,pa);
                        }
                    }
                }
            }
            finally
            {
                // Release the memory.
                Marshal.FreeCoTaskMem(rawTable);
            }
            return all;
        }

        /// <summary>
        /// Gets the IP address of the current PC
        /// </summary>
        /// <returns></returns>
        private static IPAddress GetIPAddress()
        {
            String strHostName = Dns.GetHostName();
            IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
            IPAddress[] addr = ipEntry.AddressList;
            foreach (IPAddress ip in addr)
            {
                if (!ip.IsIPv6LinkLocal)
                {
                    return (ip);
                }
            }
            return addr.Length > 0 ? addr[0] : null;
        }

        /// <summary>
        /// Gets the MAC address of the current PC.
        /// </summary>
        /// <returns></returns>
        private static PhysicalAddress GetMacAddress()
        {
            foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                // Only consider Ethernet network interfaces
                if (nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet &&
                    nic.OperationalStatus == OperationalStatus.Up)
                {
                    return nic.GetPhysicalAddress();
                }
            }
            return null;
        }

        /// <summary>
        /// Returns true if the specified IP address is a multicast address
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        private static bool IsMulticast(IPAddress ip)
        {
            bool result = true;
            if (!ip.IsIPv6Multicast)
            {
                byte highIP = ip.GetAddressBytes()[0];
                if (highIP < 224 || highIP > 239)
                {
                    result = false;
                }
            }
            return result;
        }

        #endregion

        #region MAC扫描方法2



        static List<string> ips = new List<string>();
        static Dictionary<string,string> dic1 = new Dictionary<string,string>();

        static void GetIPAddress2()
        {
            string myHostName = Dns.GetHostName();//本机名
            string myHostIP = Dns.GetHostEntry(myHostName).AddressList[1].ToString();//本机IP地址
            string IpRange = myHostIP.Remove(myHostIP.LastIndexOf('.'));//IP网段
            for (int r = 1; r <= 255; r++)//枚举网段计算机
            {
                Ping ping = new Ping();
                ping.PingCompleted += new PingCompletedEventHandler(ping_Completed);//事件绑定方法
                string pingIP = IpRange + "." + r.ToString();
                ping.SendAsync(pingIP,1000,null);
            }
        }

        static void ping_Completed(object sender,PingCompletedEventArgs e)
        {
            if (e.Reply.Status == IPStatus.Success)
            {
                ips.Add(e.Reply.Address.ToString());
                if (!dic1.ContainsKey(e.Reply.Address.ToString()))
                {
                    dic1[e.Reply.Address.ToString()] = "";
                }
            }
        }

        #endregion



        private void Msg(string e)
        {
            try
            {
                string msg = "";
                //if (string.IsNullOrEmpty(richTextBox1.Text))
                //{
                //    msg = e;
                //}
                //else
                //{
                //    msg = richTextBox1.Text + "\r\n" + e;
                //}
                msg = e;
                if (base.Invokerequired)
                {
                    base.Invoke(new MethodInvoker(() =>
                    {
                        richTextBox1.Text = richTextBox1.Text + "\r\n" + e;
                    }));
                }
                else
                {
                    richTextBox1.Text = richTextBox1.Text + "\r\n" + e;
                }
            }
            catch
            {
            }
        }

    }
}

四、 外网远程唤醒方案

  1. 家中放一台微型迷你低功耗计算机或者网关(树莓派、网关、迷你服务器)功耗在10W左右,保持24小时常开,一年电费在一百左右。安装向日葵或者ToDesk设置无人值守,支持电脑和手机App连接。随时随地连接到桌面后,用远程发包软件(文中源码或直接下载打包程序)来远程网络唤醒局域网内其他电脑。
  2. 使用向日葵开机棒,参照官方设置即可,主要是开机棒开放了mac地址开机。可以使得开机棒不局限于一台计算机开机了。在向日葵的网站上找到开机棒,或者在手机就app中找到,然后输入mac地址,即可。
  3. 使用路由器(例如TP-Link)自带的域名解析功能,参考文章:【超详细】Windows设置远程唤醒WOL+远程连接(远程开机)_wyouzhi@yyds的博客-CSDN博客_远程开机与远程唤醒bios设置

golang 远程唤醒开机实例

golang 远程唤醒开机实例

package main

import (
   "fmt"
   "github.com/sabhiram/go-wol"
   "io"
   "log"
   "net"
   "net/http"
   "time"
)

func main() {
   http.HandleFunc("/makeUp", func(w http.ResponseWriter, r *http.Request) {
      macAddr := r.FormValue("mac")
      ip := r.FormValue("ip")
      secret := r.FormValue("secret")
      if secret != "407787759" {
         io.WriteString(w, "<h1color:red;''>非常操作!</h1>")
         return
      }

      if ip != "" {
         b := isping(ip)
         if b {
            io.WriteString(w, "<h1color:blue;''>已开机!</h1>")
            return
         }
      }
      log.Println(macAddr, ip, secret)
      wakeUp(macAddr)
      io.WriteString(w, "<h1color:red;''>开机指令发送成功!请稍候...</h1>")
   })

   http.ListenAndServe(":2019", nil)

}
func wakeUp(macAddr string) {
   var localAddr *net.UDPAddr

   localAddr, _ = ipFromInterface("eno5")

   udpAddr, err := net.ResolveUDPAddr("udp", "255.255.255.255:9")

   if err != nil {
      panic(err)
   }
   mp, err := wol.New(macAddr)
   if err != nil {
      panic(err)
   }

   bs, err := mp.Marshal()
   if err != nil {
      panic(err)
   }

   conn, err := net.DialUDP("udp", localAddr, udpAddr)
   if err != nil {
      panic(err)
   }
   defer conn.Close()

   n, err := conn.Write(bs)

   if err == nil && n != 102 {
      err = fmt.Errorf("magic packet sent was %d bytes (expected 102 bytes sent)", n)
   }
   fmt.Printf("Magic packet sent successfully to %s\n", macAddr)

}

// ipFromInterface returns a `*net.UDPAddr` from a network interface name.
func ipFromInterface(iface string) (*net.UDPAddr, error) {
   ief, err := net.InterfaceByName(iface)
   if err != nil {
      return nil, err
   }

   addrs, err := ief.Addrs()
   if err == nil && len(addrs) <= 0 {
      err = fmt.Errorf("no address associated with interface %s", iface)
   }
   if err != nil {
      return nil, err
   }

   // Validate that one of the addrs is a valid network IP address.
   for _, addr := range addrs {
      switch ip := addr.(type) {
      case *net.IPNet:
         // Verify that the DefaultMask for the address we want to use exists.
         if ip.IP.DefaultMask() != nil {
            return &net.UDPAddr{
               IP: ip.IP,
            }, nil
         }
      }
   }

   return nil, fmt.Errorf("no address associated with interface %s", iface)

}

func isping(ip string) bool {
   recvBuf1 := make([]byte, 2048)
   payload := []byte{0x08, 0x00, 0x4d, 0x4b, 0x00, 0x01, 0x00, 0x10, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69}
   Time, _ := time.ParseDuration("1s")
   conn, err := net.DialTimeout("ip4:icmp", ip, Time)
   if err != nil {
      fmt.Println("bibi")
      return false
   }
   _, err = conn.Write(payload)
   if err != nil {
      return false
   }
   conn.SetReadDeadline(time.Now().Add(time.Second * 2))
   num, err := conn.Read(recvBuf1[0:])
   conn.SetReadDeadline(time.Time{})
   if string(recvBuf1[0:num]) != "" {
      return true
   }

   return false
}

通过 web 访问程序,让它发出魔术包唤醒同网段的其它 PC

要远程开机的 PC 要设置网卡唤醒功能!

然后通过 http:// 您的程序运行的 IP:2019/makeUp?secret=407787759&mac=00:00:59:96:CC:0c (你要开机的 MAC 地址)

今天的关于利用PHP远程唤醒计算机,发送唤醒魔术包利用php远程唤醒计算机,发送唤醒魔术包的分享已经结束,谢谢您的关注,如果想了解更多关于airdroid怎么远程唤醒 airdroid开启快速远程唤醒教程、android – 如何远程唤醒手机?、c# 远程网络唤醒电脑(电脑远程开机+内网MAC和IP扫描)(附带源码+主板和Windows开启详细说明+外网远程唤醒方案)、golang 远程唤醒开机实例的相关知识,请在本站进行查询。

本文标签: