云服务器内容精选

  • 约束条件 Web基础防护、精准访问防护和黑白名单设置支持攻击惩罚功能,当攻击惩罚标准配置完成后,您还需要在Web基础防护、精准访问防护或黑白名单规则中选择攻击惩罚,该功能才能生效。 黑白名单规则中,不支持选择“长时间IP拦截”和“短时间IP拦截”的攻击惩罚。 添加或修改防护规则后,规则生效需要等待几分钟。规则生效后,您可以在“防护事件”页面查看防护效果。 在配置Cookie或Params恶意请求的攻击惩罚标准前,您需要在域名详情页面设置对应的流量标识。相关操作请参见配置攻击惩罚的流量标识。
  • 配置示例-Cookie拦截攻击惩罚 假如防护域名“www.example.com”已接入WAF,访问者IP XXX.XXX.248.195为恶意请求,而您需要对来自该IP地址Cookie标记为jsessionid的访问请求封禁10分钟。您可以参照以下操作步骤验证封禁效果。 在“网站设置”页面,单击“www.example.com”,进入域名基本信息页面。 配置防护域名的Cookie流量标识,即“Session标记”。 图2 流量标识 添加一条拦截时长为600秒的“长时间Cookie拦截”的攻击惩罚标准。 图3 添加Cookie拦截攻击惩罚 开启攻击惩罚。 图4 攻击惩罚配置框 添加一条黑白名单规则,拦截XXX.XXX.248.195,且“攻击惩罚”选择“长时间Cookie拦截”。 图5 选择攻击惩罚规则 清理浏览器缓存,在浏览器中访问“http://www.example.com”页面。 当XXX.XXX.248.195源IP访问页面时,会被WAF拦截。当WAF检测到来自该源IP的Cookie标记为jsessionid访问请求时,WAF将封禁该访问请求,时长为10分钟。 图6 WAF拦截攻击请求 返回Web应用防火墙管理控制台,在左侧导航树中,单击“防护事件”,进入“防护事件”页面,您可以查看该防护事件。
  • 使用建议 如果您对自己的业务流量特征还不完全清楚,建议先切换到“仅记录”模式进行观察。一般情况下,建议您观察一至两周,然后分析仅记录模式下的攻击日志。 如果没有发现任何正常业务流量被拦截的记录,则可以切换到“拦截”模式启用拦截防护。 如果发现攻击日志中存在正常业务流量,建议调整防护等级或者设置全局白名单来避免正常业务的误拦截。 业务操作方面应注意以下问题: 正常业务的HTTP请求中尽量不要直接传递原始的SQL语句、JavaScript代码。 正常业务的URL尽量不要使用一些特殊的关键字(UPDATE、SET等)作为路径,例如:“https://www.example.com/abc/update/mod.php?set=1”。 如果业务中需要上传文件,不建议直接通过Web方式上传超过50M的文件,建议使用对象存储服务或者其他方式上传。
  • 配置示例-敏感信息过滤 假如防护域名“www.example.com”已接入WAF,您可以参照以下操作步骤验证敏感信息过滤防护效果。 添加一条敏感信息过滤规则。 图3 敏感信息泄露 开启防敏感信息泄露。 图4 防敏感信息泄露配置框 清理浏览器缓存,在浏览器中访问“http://www.example.com/admin/”页面。 该页面的电子邮箱、电话号码和身份号码信息被屏蔽。 图5 敏感信息屏蔽示例
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type 缺省值:application/json;charset=utf8 最小长度:1 最大长度:128 表3 请求Body参数 参数 是否必选 参数类型 描述 instance_id 是 String 实例id type 是 String 规则类型。black - 黑名单, white - 白名单 ips 是 Array of strings ip列表
  • Go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" antiddos "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := antiddos.NewAntiDDoSClient( antiddos.AntiDDoSClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ShowDefaultConfigRequest{} response, err := client.ShowDefaultConfig(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkantiddos.v1.region.antiddos_region import AntiDDoSRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkantiddos.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.getenv("CLOUD_SDK_AK") sk = os.getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = AntiDDoSClient.new_builder() \ .with_credentials(credentials) \ .with_region(AntiDDoSRegion.value_of("cn-north-4")) \ .build() try: request = ShowDefaultConfigRequest() response = client.show_default_config(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type请求头 缺省值:application/json;charset=utf8 最小长度:1 最大长度:255
  • Java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.antiddos.v1.region.AntiDDoSRegion; import com.huaweicloud.sdk.antiddos.v1.*; import com.huaweicloud.sdk.antiddos.v1.model.*; public class ShowDefaultConfigSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); AntiDDoSClient client = AntiDDoSClient.newBuilder() .withCredential(auth) .withRegion(AntiDDoSRegion.valueOf("cn-north-4")) .build(); ShowDefaultConfigRequest request = new ShowDefaultConfigRequest(); try { ShowDefaultConfigResponse response = client.showDefaultConfig(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 enable_L7 Boolean 是否开启L7层防护,固定值为fasle traffic_pos_id Long 流量分段ID,取值范围:1~9、88、99 最小值:1 最大值:99 http_request_pos_id Long HTTP请求数分段ID,取值范围:1~15 最小值:1 最大值:15 cleaning_access_pos_id Long 清洗时访问限制分段ID,取值范围:1~8、88、99 最小值:1 最大值:99 app_type_id Integer 应用类型ID,可选取值: 0 1
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type 缺省值:application/json;charset=utf8 最小长度:1 最大长度:255 表3 请求Body参数 参数 是否必选 参数类型 描述 name 否 String 策略名 最小长度:1 最大长度:255 threshold 否 Integer 清洗阈值 最小值:100 最大值:1000 description 否 String 描述 最小长度:0 最大长度:255 udp 否 String udp协议封禁。block:封禁,unblock:不封禁
  • 背景信息 终端防护与响应服务会根据配置的异常登录策略判断终端上是否存在非法登录行为,对不在该策略内的登录行为进行告警,并提供处置方式。租户通过配置异常登录策略,管理相应终端的登录行为。 当终端安装EDR Agent后,用户首次成功登录终端,如果此时未配置异常登录策略,EDR Agent不会触发告警,并且首次成功登录的IP地址及该时间点往后顺延24小时内的所有公网登录地址都会被云端识别为合法登录地址;如果已配置异常登录策略,未配置在异常登录策略中的登录行为均被认为是非法登录行为。
  • 响应示例 状态码: 200 OK { "id" : "38ff0cb9a10e4d5293c642bc0350fa6d", "name" : "demo", "level" : 2, "action" : { "category" : "log" }, "options" : { "webattack" : true, "common" : true, "crawler" : true, "crawler_engine" : false, "crawler_scanner" : true, "crawler_script" : false, "crawler_other" : false, "webshell" : false, "cc" : true, "custom" : true, "whiteblackip" : false, "geoip" : true, "ignore" : true, "privacy" : true, "antitamper" : true, "antileakage" : false, "bot_enable" : true }, "hosts" : [ "c0268b883a854adc8a2cd352193b0e13" ], "timestamp" : 1650529538732, "full_detection" : false, "bind_host" : [ { "id" : "c0268b883a854adc8a2cd352193b0e13", "hostname" : "www.demo.com", "waf_type" : "cloud" } ] }
  • 请求示例 修改项目id为project_id和防护策略id为policy_id的防护策略中的基础防护开关配置等信息,打开深度检测、header全检测、Shiro解密检测的防护开关。 PATCH https://{Endpoint}/v1/{project_id}/waf/policy/{policy_id}?enterprise_project_id=0 { "extend" : { "extend" : "{\"deep_decode\":true,\"check_all_headers\":true,\"shiro_rememberMe_enable\":true}" } } 关闭项目id为project_id和防护策略id为policy_id的黑白名单防护 PATCH https://{Endpoint}/v1/{project_id}/waf/policy/{policy_id}?enterprise_project_id=0 { "options" : { "whiteblackip" : false } }
  • 防护效果 开启Web基础防护功能后,在浏览器中输入模拟SQL注入攻击的测试域名,WAF将拦截了此条攻击。您可以在“安全总览”页面,查看攻击的拦截日志,如图4所示。 图3 SQL攻击拦截 图4 安全统计 在“防护事件”页面,您可查看“昨天”、“今天”、“3天”、7天、“30天”或者自定义时间范围内的防护日志。同时,在攻击事件的“操作”列,单击“详情”,可以查看具体的攻击信息,如图5所示。 图5 防护事件列表