{"id":482,"date":"2019-04-05T22:17:23","date_gmt":"2019-04-05T13:17:23","guid":{"rendered":"https:\/\/medicalfields.jp\/blog\/?p=482"},"modified":"2019-12-03T11:53:19","modified_gmt":"2019-12-03T02:53:19","slug":"%e3%83%aa%e3%83%a2%e3%83%bc%e3%83%88%e3%83%87%e3%82%b9%e3%82%af%e3%83%88%e3%83%83%e3%83%97%e3%82%92%e7%89%b9%e5%ae%9a%e3%81%aeip%e3%81%ae%e3%81%bf%e3%81%a7%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e3%82%88","status":"publish","type":"post","link":"https:\/\/medicalfields.jp\/blog\/%e3%83%91%e3%82%bd%e3%82%b3%e3%83%b3\/%e3%83%aa%e3%83%a2%e3%83%bc%e3%83%88%e3%83%87%e3%82%b9%e3%82%af%e3%83%88%e3%83%83%e3%83%97%e3%82%92%e7%89%b9%e5%ae%9a%e3%81%aeip%e3%81%ae%e3%81%bf%e3%81%a7%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e3%82%88\/","title":{"rendered":"\u30ea\u30e2\u30fc\u30c8\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u3092\u7279\u5b9a\u306eIP\u306e\u307f\u3067\u63a5\u7d9a\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3001\u3055\u3089\u306bPHP\u3092\u4f7f\u3063\u3066IP\u30a2\u30c9\u30ec\u30b9\u8ffd\u52a0\u8a31\u53ef\u3059\u308b"},"content":{"rendered":"\n<p>\u6587\u7ae0\u306b\u3059\u308b\u3068\u5206\u304b\u308a\u3065\u3089\u3044\u3051\u3069\u3001PHP\u304b\u3089\u6307\u5b9a\u3057\u305fURL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u5834\u5408\uff08\u305d\u306e\u3068\u304d\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u639b\u3051\u3066\u3082\u3044\u3044\uff09\u305d\u306e\u30a2\u30af\u30bb\u30b9\u3057\u305fIP\u30a2\u30c9\u30ec\u30b9\u3092\u30ea\u30e2\u30fc\u30c8\u30c7\u30a3\u30b9\u30af\u30c8\u30c3\u30d7\u306e\u53d7\u4fe1\u306e\u898f\u5247\u306b\u8ffd\u52a0\u3057\u3066\u30ea\u30e2\u30fc\u30c8\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\uff08RDP\uff09\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u9ad8\u3081\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u30dd\u30fc\u30c8\u304c\u5b8c\u5168\u306b\u53cd\u5fdc\u3057\u306a\u304f\u306a\u308b\u306e\u3067\u30dd\u30fc\u30c8\u30b9\u30ad\u30e3\u30f3\u306b\u3082\u6709\u52b9\u3067\u3059\u3057\u3001\u4e0d\u6b63\u30a2\u30af\u30bb\u30b9\u5bfe\u7b56\u3068\u3057\u3066\u306f\u304b\u306a\u308a\u5f37\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u7279\u5b9a\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3060\u3051\u3067\u3001\u5229\u7528\u3092\u8a31\u53ef\u3067\u304d\u3001\u5229\u4fbf\u6027\u3082\u9ad8\u3044\u3068\u601d\u3044\u307e\u3059<\/p>\n<p>\u30c7\u30e1\u30ea\u30c3\u30c8\u3068\u3057\u3066\u306f\u3001Windows\u306e\u30d5\u30a1\u30a4\u30e4\u30fc\u30a6\u30a9\u30fc\u30eb\u306e\u30eb\u30fc\u30eb\u306b\u30c9\u30f3\u30c9\u30f3\u6e9c\u307e\u3063\u3066\u3044\u304f\u306e\u3067\u3001\u305f\u307e\u306b\u6574\u7406\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3050\u3089\u3044\u3067\u3059\u306d<\/p>\n<p>\u3067\u3082\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u8003\u3048\u305f\u3089IP\u3092\u5236\u9650\u3059\u308b\u306e\u306f\u5927\u4e8b\u3060\u3068\u601d\u3044\u307e\u3059<\/p>\n<p>&nbsp;<\/p>\n<p>\u524d\u56de\u3084\u3063\u305fApache\u306ePHP\u306e\u30a2\u30af\u30bb\u30b9\u5236\u9650\u3068\u5c11\u3057\u3060\u3051\u4f3c\u3066\u307e\u3059\u3002\u3084\u3063\u3066\u308b\u3053\u3068\u306f\u7d50\u69cb\u9055\u3046\u3051\u3069\u3002<\/p>\n<p>\u3084\u308a\u65b9\u3068\u3057\u3066\u3001\u307e\u305aRDP\u306f\u30ed\u30fc\u30ab\u30eb\u3084\u7279\u5b9a\u306eIP\u3060\u3051\u3057\u304b\u8a31\u53ef\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u306f\u4ed6\u306e\u30b5\u30a4\u30c8\u3067\u3082\u66f8\u3044\u3066\u308b\u306e\u3067\u3042\u307e\u308a\u89e3\u8aac\u3057\u307e\u305b\u3093\u304c\u3001Windows Defender\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u3092\u958b\u3044\u3066\u3001\u30ea\u30e2\u30fc\u30c8\u30c7\u30b9\u30af\u30c8\u30c3\u30d7 &#8211; \u30e6\u30fc\u30b6\u30fc\u30e2\u30fc\u30c9(TCP \u53d7\u4fe1)\u3068\u30ea\u30e2\u30fc\u30c8\u30c7\u30b9\u30af\u30c8\u30c3\u30d7 &#8211; \u30e6\u30fc\u30b6\u30fc\u30e2\u30fc\u30c9(UDP \u53d7\u4fe1)\u306e\u30ea\u30e2\u30fc\u30c8\u30a2\u30c9\u30ec\u30b9\u306e\u30b9\u30b3\u30fc\u30d7\u3092\u4efb\u610f\u306eIP\u30a2\u30c9\u30ec\u30b9\u304b\u3089\u3053\u308c\u3089\u306eIP\u30a2\u30c9\u30ec\u30b9\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u79c1\u306f127.0.0.1\u3068192.168.1.0\/24\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/medicalfields.jp\/blog\/wp-content\/uploads\/2019\/04\/RDP_port.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-483\" src=\"https:\/\/medicalfields.jp\/blog\/wp-content\/uploads\/2019\/04\/RDP_port.png\" alt=\"\" width=\"1495\" height=\"854\"><\/a><\/p>\n<p>\u305d\u308c\u3067\u3001\u3053\u3053\u304b\u3089\u304c\u30aa\u30ea\u30b8\u30ca\u30eb\u3067\u3059<\/p>\n<p>C#\u3092\u4f7f\u3063\u305fWindows Firewall\u306bAllow IP\u8ffd\u52a0\u3059\u308b\u30aa\u30ea\u30b8\u30ca\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u306eEXE\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>Visual Studio 2019 community\u3067\u4f5c\u6210\u3057\u307e\u3057\u305f<\/p>\n<p>\u65b0\u898f\u4f5c\u6210\u2192\u65b0\u3057\u3044\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u2192\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\uff08.NET Framework\uff09C#\u3092\u9078\u3093\u3067\u3001\u540d\u524d\u306f\u300cadd_ip_to_windows_firewall\u300d\u3067\u5bfe\u8c61\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306f.NET Framework 4.5\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>&nbsp;<\/p>\n<pre><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Runtime.InteropServices;\nusing NetFwTypeLib;\n\nnamespace add_ip_to_windows_firewall\n{\n    class Program\n    {\n\n        public const int NET_FW_IP_PROTOCOL_TCP = 6;\n\n        public const int NET_FW_IP_PROTOCOL_UDP = 17;\n\n        public static void addRule(String ip, String port, int protocol)\n        {\n            INetFwRule firewallRule = (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID(&quot;HNetCfg.FWRule&quot;));\n            firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW;\n            firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN;\n            firewallRule.RemoteAddresses = ip;\n            firewallRule.Protocol = protocol;\n            firewallRule.LocalPorts = port;\/\/\u8907\u6570\u306e\u5834\u5408\u306f8051,8052,8053\u306a\u3069\n            firewallRule.Enabled = true;\n            firewallRule.InterfaceTypes = &quot;All&quot;;\n            firewallRule.Name = &quot;RDP IP permission : &quot; + ip;\n            INetFwPolicy2 firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID(&quot;HNetCfg.FwPolicy2&quot;));\n            firewallPolicy.Rules.Add(firewallRule);\n        }\n        static void Main(string[] args)\n        {\n\n            if (args.Length == 0)\n            {\n                Console.WriteLine(&quot;ERROR!!! Please set IP in args....&quot;);\n                System.Threading.Thread.Sleep(5000);\n            }\n            else\n            {\n                string ip = args[0];\n                Console.WriteLine(&quot;allow access to &quot; + ip);\n                addRule(ip, port: &quot;3389&quot;, protocol: NET_FW_IP_PROTOCOL_TCP);\n                addRule(ip, port: &quot;3389&quot;, protocol: NET_FW_IP_PROTOCOL_UDP);\n                Console.WriteLine(&quot;May Be Success!&quot; + ip);\n\n            }\n        }\n    }\n}\n<\/pre><\/pre>\n<p>\u4e0a\u304c\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p>\u8cbc\u308a\u4ed8\u3051\u3066\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002NetFwTypeLib\u304cmissing\u306e\u5834\u5408\u306f\u53c2\u7167\u304b\u3089<\/p>\n<p>\u53c2\u7167\u306e\u8ffd\u52a0\u3067System32\u306b\u3042\u308bFirewallAPI.dll\u3092\u9078\u629e\u3057\u3066OK\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3093\u3067\u51fa\u6765\u4e0a\u304c\u3063\u305fadd_ip_to_windows_firewall\u3092PHP\u304c\u5b9f\u884c\u51fa\u6765\u308bWEB\u30b5\u30fc\u30d0\u30fc\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u4ee5\u4e0b\u306ePHP\u30d5\u30a1\u30a4\u30eb\u3082\u4f5c\u6210\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>index.php<\/p>\n<pre>&nbsp;<\/pre>\n<pre><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&amp;amp;amp;amp;lt;?php\nerror_reporting(E_ALL);\ntry {\n    $myExeFile = dirname(__FILE__) . '\/add_ip_to_windows_firewall.exe';\n    if (! file_exists($myExeFile)) {\n        echo $myExeFile;\n        exit(&quot;exe\u30d5\u30a1\u30a4\u30eb\u304c\u7121\u3044\u3067\u3059&quot;);\n    }\n    $ip = $_SERVER[&quot;REMOTE_ADDR&quot;];\n    $exeCommand = $myExeFile . &quot; &quot; . $ip;\n    echo &quot;\u51e6\u7406\u3092\u5b9f\u884c\u3057\u307e\u3059&quot;;\n    echo &quot;\n&quot;;\n    echo exec($exeCommand);\n    echo &quot;\n&quot;;\n    echo &quot;allow access to xxx\u3000\u304c\u51fa\u305f\u3089\u6210\u529f\u3067\u3059\uff01&quot;;\n} catch (Exception $e) {\n    echo $e-&amp;amp;amp;amp;gt;getMessage();\n}\n?&amp;amp;amp;amp;gt;\n<\/pre><\/pre>\n<p>&nbsp;<\/p>\n<p>WEB\u30b5\u30fc\u30d0\u30fc\u3067\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b<\/p>\n<p>.htaccess\uff08\u5fc5\u8981\u306a\u3089\u3067allow from all\u3060\u3051\u3068\u304b\uff09<\/p>\n<p>index.php\uff08\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u4f55\u3067\u3082\u3044\u3044\u3002\u3080\u3057\u308d\u8907\u96d1\u306a\u307b\u3069\u3044\u3044\uff09<\/p>\n<p>add_ip_to_windows_firewall.exe<\/p>\n<p>\u306e\uff13\u3064\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>Apache\u306e\u6a29\u9650\u3092\u7ba1\u7406\u8005\u6a29\u9650\u3067\u5b9f\u884c\u3055\u305b\u308b\u3088\u3046\u306b\u3057\u3066\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bhttp:\/\/yousite\/addiprdp\/index.php\u306b\u30a2\u30af\u30bb\u30b9<\/p>\n<p>\u3059\u308b\u3068windows firewall\u306bRDP\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\u3059\u308bIP\u304c\u65b0\u3057\u304f\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u306f\u305a\u3067\u3059\uff01<\/p>\n<p>add_ip_to_windows_firewall.exe\u3092\u8a66\u3057\u305f\u3044\u5834\u5408\u306f\u5f15\u6570\u306bIP\u30a2\u30c9\u30ec\u30b9\u3092\u5165\u308c\u3066\u7ba1\u7406\u8005\u6a29\u9650\u3067CMD\u3092\u5b9f\u884c\u3055\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\u3068\u304b\u9762\u5012\u304f\u3055\u3044\u306a\u3089\u81ea\u5df1\u8cac\u4efb\u3067\u2193\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002Windows 10 pro \u3067\u52d5\u304b\u3057\u307e\u3057\u305f<\/p>\n<p><a href=\"https:\/\/medicalfields.jp\/blog\/wp-content\/uploads\/2019\/04\/add_ip_to_windows_firewall_php_ver.zip\">add_ip_to_windows_firewall_php_ver<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u306b\u3059\u308b\u3068\u5206\u304b\u308a\u3065\u3089\u3044\u3051\u3069\u3001PHP\u304b\u3089\u6307\u5b9a\u3057\u305fURL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u5834\u5408\uff08\u305d\u306e\u3068\u304d\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u639b\u3051\u3066\u3082\u3044\u3044\uff09\u305d\u306e\u30a2\u30af\u30bb\u30b9\u3057\u305fIP\u30a2\u30c9\u30ec\u30b9\u3092\u30ea\u30e2\u30fc\u30c8\u30c7\u30a3\u30b9\u30af\u30c8\u30c3\u30d7\u306e\u53d7\u4fe1\u306e\u898f\u5247\u306b\u8ffd\u52a0\u3057\u3066\u30ea\u30e2\u30fc\u30c8\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\uff08RDP\uff09\u306e\u30bb\u30ad\u30e5 &hellip; <a href=\"https:\/\/medicalfields.jp\/blog\/%e3%83%91%e3%82%bd%e3%82%b3%e3%83%b3\/%e3%83%aa%e3%83%a2%e3%83%bc%e3%83%88%e3%83%87%e3%82%b9%e3%82%af%e3%83%88%e3%83%83%e3%83%97%e3%82%92%e7%89%b9%e5%ae%9a%e3%81%aeip%e3%81%ae%e3%81%bf%e3%81%a7%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e3%82%88\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u30ea\u30e2\u30fc\u30c8\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u3092\u7279\u5b9a\u306eIP\u306e\u307f\u3067\u63a5\u7d9a\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3001\u3055\u3089\u306bPHP\u3092\u4f7f\u3063\u3066IP\u30a2\u30c9\u30ec\u30b9\u8ffd\u52a0\u8a31\u53ef\u3059\u308b<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[13],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6kJO0-7M","_links":{"self":[{"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/posts\/482"}],"collection":[{"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/comments?post=482"}],"version-history":[{"count":14,"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/posts\/482\/revisions"}],"predecessor-version":[{"id":583,"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/posts\/482\/revisions\/583"}],"wp:attachment":[{"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/media?parent=482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/categories?post=482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/medicalfields.jp\/blog\/wp-json\/wp\/v2\/tags?post=482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}