Block Remote IP address (hacker attack) on Windows 2008 Server

 

Block IP address with Windows Firewall 2008

This procedure helped us when someone wanted to hack our server,If you ever feel that someone may be trying to break into your server or know an IP address that you want to block from accessing your server there is a built in firewall on all of our 2008 DDS servers. You can use this firewall to block either a range of IP addresses or a single address.

  1. Log into your server via RDP.
  2. Click on start > administrative tools > windows firewall with advanced security
  3. On the left side of the firewall window click on the inbound rules option.
  4. On the right side of the screen click on New Rule.
  5. Click on the custom radio button and then click next.
  6. Make sure the All programs radio is selected then click next.
  7. On the protocol and ports options leave everything at its defaults and clicknext.
  8. On the scope screen you will see two boxes the top one is for local IP addresses and the bottom is forremote IP addresses. In this scenario we are trying to block an outside (remote) IP from accessing anything on the server so we will need to add the IP address to this section only as it will not be a local IP address.
  9. Click on the radio that says these IP addresses in the remote section as shown below:

      

     

      10 、Click on the Add button.

      11、In the next window we will be adding a single IP address to the rule, you can also add an entire range at this point if you wish.

                

 

              

            12、Click ok, click next.

            13、Make sure you select the Block the connection radio on the next screen and then clicknext.

            14、Leave all of the options on the next screen checked this will be sure to block the IP no matter the connection they are trying to use. Clicknext.

             15、Name the rule on the next screen something you can remember in case you wish to remove or edit it in the future. Clickfinish and thats it

 

//*************************************************************************************************************************************************************************************

 

class Program
    {
        static void Main(string[] args)
        {
            //HttpGet("http://localhost:52373/Index.aspx");

            HttpPost("http://localhost:52373/Index.aspx", "username=zhangsan&pwd=123");
        }
        /// <summary>
        /// GET请求
        /// </summary>
        /// <param name="URI"></param>
        /// <returns></returns>
        public static string HttpGet(string URI)
        {
            System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
            //req.Proxy = new System.Net.WebProxy(ProxyString, true); //true代表没代理
            System.Net.WebResponse resp = req.GetResponse();
            System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
            string responseStr = sr.ReadToEnd().Trim();
            return responseStr;
        }
        /// <summary>
        /// 发送POST请求
        /// </summary>
        /// <param name="URI"></param>
        /// <param name="Parameters"></param>
        /// <returns></returns>
        public static string HttpPost(string URI, string Parameters)
        {
            System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
            //req.Proxy = new System.Net.WebProxy(ProxyString, true);
            //POST请求参数
            req.ContentType = "application/x-www-form-urlencoded";
            req.Method = "POST";
            //We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
            req.ContentLength = bytes.Length;
            System.IO.Stream os = req.GetRequestStream();
            os.Write(bytes, 0, bytes.Length); //Push it out there
            os.Close();
            System.Net.WebResponse resp = req.GetResponse();
            if (resp == null) return null;
            System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
            return sr.ReadToEnd().Trim();
        }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值