如何设置UAC白名单

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何设置UAC白名单相关的知识,希望对你有一定的参考价值。

方法/步骤
点击桌面右下角的“通知”图标,如下图所示
在弹出来的界面,点击“所有设置”
再设置主页,点击右下角的“安全和更新”
接下来,在左侧的列表栏目,找到“Window Defender”,然后点击它
这时候,我们可以看到右侧有很多安全设置选项,找到“排除”选项,点击“排除”下方的“添加到排除项”,如图所示
接下来的页面,可以看到“文件与文件夹”、“文件类型”、“进程”等分类。
这里我们以文件夹为例子。我们单击“排除文件夹”前面的加号,如图所示
接下来,会弹出一个添加文件夹窗口。我们以添加整个F盘为示例,选中F盘后,单击下面的添加按钮。按照图中步骤进行操作。
这时,会返回到第6步中的界面,在“排除文件夹”的下放,会多出一个F盘的文件夹,这里就添加成功了!
参考技术A 是有非常简单的办法实现,对某特定程序实现UAC白名单。
假设系统以用户xyz登录,需要设定的程序在文件夹abc内,右键文件夹abc,属性,安全,点击“编辑”,然后选择登录的用户xyz,把“完全修改”选项勾选,点击确定,完成。

这样操作后,不用把UAC拉到最低,安全性依然保持原来的高度。因为以后新的程序安装,依然会有安装提示,防止其他静默软件安装,同时又能实现针对某程序不再提出UAC提示。

Asp.Net Core 中如何设置 IP 白名单

咨询区

  • MartinM

我想在一个web站点中实现ip白名单功能,在 MVC 时代我只需要在 web.config 中添加如下配置即可。


<security>
  <ipSecurity allowUnlisted="false" denyAction="NotFound">
    <add allowed="true" ipAddress="XX.XX.XX.XX" subnetMask="255.255.255.0"/>
  </ipSecurity>
</security>

但在 AspNetCore 中使用如上配置时,程序启动就会报错。


Unable to start process The web server request failed with status code 500, internal server error

很显然这个 config 配置是有问题的,请问是否有内置或者第三方的组件来实现这个功能?

回答区

  • Ergwun

Damian Bod 写了一篇文章:https://damienbod.com/2016/12/18/implementing-a-client-white-list-using-asp-net-core-middleware/ 来演示如果通过中间件的方式来实现 ip 白名单功能。

他分别给了一个 全局性中间件actionfilter 两种方式来实现,无论哪种方式都需要在 appsetttings.json 中配置可允许访问的 ip 列表,然后根据这个list来检查客户端的ip是否符合?client ip 可以通过 context.Connection.RemoteIpAddress 来获取。

如果你有更精细化的配置,比如说设置ip段,那你可以通过nuget上的 IPAddressRange 包来实现,它支持了多种格式,如:192.168.0.0/24192.168.0.0/255.255.255.0,包括 CIDR 表达式和 IPv6。

参考下面的例子。

  1. appsettings.json:


{
  "IPAddressWhitelistConfiguration": {
    "AuthorizedIPAddresses": [
      "::1", // IPv6 localhost
      "127.0.0.1", // IPv4 localhost
      "192.168.0.0/16", // Local network
      "10.0.0.0/16", // Local network
    ]
  }
}

  1. IPWhiteListConfiguration.cs:


namespace My.Web.Configuration
{
    using System.Collections.Generic;

    public class IPWhitelistConfiguration : IIPWhitelistConfiguration
    {
        public IEnumerable<string> AuthorizedIPAddresses { get; set; }
    }
}

  1. IIPWhiteListConfiguration.cs:


namespace My.Web.Configuration
{
    using System.Collections.Generic;

    public interface IIPWhitelistConfiguration
    {
        IEnumerable<string> AuthorizedIPAddresses { get; }
    }
}

  1. Startup.cs:


public class Startup
{
    // ...
    public void ConfigureServices(IServiceCollection services)
    {
        // ...
        services.Configure<IPWhitelistConfiguration>(
           this.Configuration.GetSection("IPAddressWhitelistConfiguration"));
        services.AddSingleton<IIPWhitelistConfiguration>(
            resolver => resolver.GetRequiredService<IOptions<IPWhitelistConfiguration>>().Value);
        // ...
    }
 }

  1. ClientIPAddressFilterAttribute.cs:


namespace My.Web.Filters
{
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.Filters;
    using NetTools;
    using My.Web.Configuration;

    public class ClientIPAddressFilterAttribute : ActionFilterAttribute
    {
        private readonly IEnumerable<IPAddressRange> authorizedRanges;

        public ClientIPAddressFilterAttribute(IIPWhitelistConfiguration configuration)
        {
            this.authorizedRanges = configuration.AuthorizedIPAddresses
                .Select(item => IPAddressRange.Parse(item));
        }

        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var clientIPAddress = context.HttpContext.Connection.RemoteIpAddress;
            if (!this.authorizedRanges.Any(range => range.Contains(clientIPAddress)))
            {
                context.Result = new UnauthorizedResult();
            }
        }
    }
}

点评区

在 website 中设置ip白名单的功能非常常见,nuget上也有很多的开源中间件帮助实现,比如:ClientIpAspNetCoreIIS,我在项目中也有用到白名单的功能,只不过是做到了 nginx 层。

以上是关于如何设置UAC白名单的主要内容,如果未能解决你的问题,请参考以下文章

UAC白名单有没有用?

UAC白名单设置工具怎么用

使用UAC白名单让指定的程序不受UAC限制,很实用的哦

如何设置urlfilter的白名单?

如何设置防火墙白名单

Mac 命令行 Command Line 配置代理, 配置白名单