
# 分析溯源
事后对攻防过程中重要攻击或防守成果进行溯源分析，针对过程中暴露的安全能力风险、应急处理流程缺失、安全意识薄弱等问题进行梳理，输出复盘报告。
**安全分析能力提供原始日志数据查询统计能力，可以针对原始数据进行溯源分析。**
#### 分析溯源
1. [登录安全云脑 SecMaster控制台](https://console.huaweicloud.com/secmaster/#/secmaster/ssa/overview)。
2. 并进入目标工作空间管理页面。
3. 在左侧导航栏选择"日志审计 \> 安全数据"，进入安全分析页面。 
   图1进入安全分析页面   
   ![](https://support.huaweicloud.com/bestpractice-secmaster/zh-cn_image_0000002322259121.png "点击放大")
   
   
4. 在左侧数据空间导航栏中，单击数据空间名称，展开数据管道列后，再单击管道名称，右侧将显示管道数据的检索页面。 
   图2管道数据页面   
   ![](https://support.huaweicloud.com/bestpractice-secmaster/zh-cn_image_0000001940880697.png "点击放大")
   
   
5. 在管道数据检索页面，选择查询分析时间，设置查询条件或直接输入查询语句进行溯源分析。 
   设置查询条件或直接输入查询语句操作参考[查询语法](https://support.huaweicloud.com/usermanual-secmaster/secmaster_01_0041.html)。
   查询之后通过原始日志看到详细日志数据，如[图3]所示。
   图3原始日志   
   ![](https://support.huaweicloud.com/bestpractice-secmaster/zh-cn_image_0000001940965165.png "点击放大")
   同时，也可以通过显示字段，进行字段筛选显示查看分析，如[图4]所示。
   图4选中显示字段   
   ![](https://support.huaweicloud.com/bestpractice-secmaster/zh-cn_image_0000001940952745.png "点击放大")
   
   
 
#### 常用查询语句
表1常用查询语句 
| 需求         | 管道             | 查询语句                                                                                                                                                                                                                                                                   |
|:---|:---|:---|
| 某IP访问查询    | sec-waf-access | **x_forwarded_for='** *x.x.x.x* **' or remote_ip='** *x.x.x.x* **' and response_code='200' \| select x_forwarded_for,remote_ip,http_host,url,response_code**                                                                                                           |
| url关键词访问查询 | sec-waf-access | **url like '** *\*actuator\** **' and response_code='200' \| select \*,count(x_forwarded_for) as num group by x_forwarded_for,remote_ip,http_host,url**                                                                                                                |
| 某域名访问iptop | sec-waf-attack | **http_host=MATCH_QUERY('** *www.xx.com* **') \| select \*,count(remote_ip) as num group by http_host,remote_ip**                                                                                                                                                      |
| 某IP攻击查询    | sec-waf-attack | **sip='** *x.x.x.x* **' and not attack='custom_whiteblackip' and not attack='custom_custom' \| select attack,sip,http_host,uri,hit_data,status**                                                                                                                       |
| 某域名被攻击查询   | sec-waf-attack | **http_host='** *www.aa.com* **' and not attack='custom_whiteblackip' and not attack='custom_custom' and not attack='robot' \| select attack,sip,http_host,uri,hit_data,status**                                                                                       |
| 某主机执行命令查询  | sec-hss-log    | **(dest_asset.name='** *aa* **' or ipList='** *x.x.x.x* **') and alarmKey='proc_report_2' \| select dest_asset.name,ipList,appendInfo.cmdline,appendInfo.path**                                                                                                        |
| 某主机登录查询    | sec-hss-log    | **alarmKey like 'login_check_\*' and ipList='** *x.x.x.x* **' \| select ipList,appendInfo.service_type,appendInfo.service_port,appendInfo.login_ip ,hostIp**                                                                                                           |
| 某主机告警查询    | sec-hss-alarm  | **(dest_asset.name='** *hostname* **' or ipList='** *x.x.x.x* **' ) \| select dest_asset.name,ipList,appendInfo.event_name,appendInfo.file_info,appendInfo.process_info**                                                                                              |
| 某主机登录查询    | sec-hss-alarm  | **appendInfo.event_type=4007 and (ipList='** *x.x.x.x* **' or appendInfo.forensic_info.login_ip='** *x.x.x.x* **') \| select appendInfo.forensic_info.login_ip,appendInfo.forensic_info.service_type,appendInfo.forensic_info.user_name,appendInfo.event_name,ipList** |
   
