提交 fe0bd1b4 authored 作者: wangqiang's avatar wangqiang

controll

上级 0fa08e0e
......@@ -44,11 +44,6 @@
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
......@@ -70,6 +65,28 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.4.3.2</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>mybatis-spring</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
<exclusion>
<artifactId>mybatis</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
<exclusion>
<artifactId>mybatis-plus-annotation</artifactId>
<groupId>com.baomidou</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
......@@ -114,11 +131,6 @@
<version>${moquette.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3.2</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
......
......@@ -19,7 +19,6 @@ import com.priusis.util.SysConfigUtil;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......
apq:
iot-gateway: 192.168.124.19:7002
PC_HOST: 192.168.124.6
vnc-repeater: 120.24.236.245:5500
iot-gateway: 39.98.116.19:80/api
job:
type: all
PC_HOST: 39.98.116.19
PC_PORT: 1883
vnc-repeater: 39.98.116.19:5500
\ No newline at end of file
......@@ -69,9 +69,8 @@ public class ApqRegisterJob {
int type = registerParamDto.getType();
List<RegisterParamDto.RegisterDetailParamDto> programs = registerParamDto.getPrograms();
// 上报软件检测监控数据
Map mapRequest = new HashMap();
List<String> mapSoftRequest = null;
if (type == 1) {
mapRequest.put("type", type);
log.info("收到软件检测黑名单");
for (RegisterParamDto.RegisterDetailParamDto program : programs) {
String name = program.getName().trim();
......@@ -86,20 +85,18 @@ public class ApqRegisterJob {
} catch (Exception e) {
log.error("杀进程异常", e);
}
// 上报黑名单异常
mapRequest.put(name, "1");
mapSoftRequest.add(name);
}
}
} else {
mapRequest.put("type", type);
log.info("收到软件检测白名单");
try {
// 扫描进程列表
Set<String> processNames = new HashSet<>();
Set<String> killProcessNames = new HashSet<>();
///FI "USERNAME ne NT AUTHORITY\SYSTEM" /FI "USERNAME ne 暂缺"
Process process = Runtime.getRuntime().exec("cmd /c tasklist -fi " + '"' + "USERNAME ne NT AUTHORITY SYSTEM" + '"' + " -fi " + '"' + "USERNAME ne 暂缺" + '"' + " /fo csv");
Process process = Runtime.getRuntime().exec("cmd /c tasklist -fi " + '"' + "USERNAME ne NT AUTHORITY\\SYSTEM" + '"' + " -fi " + '"' + "USERNAME ne 暂缺" + '"' + " /fo csv");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) {
reader.readLine();
String line;
......@@ -123,6 +120,7 @@ public class ApqRegisterJob {
}
}
if (killProcessNames.size() > 0) {
mapSoftRequest = new ArrayList<>();
for (String name : killProcessNames) {
log.info("软件检测软件: {}", name);
boolean isE = WinExecuteUtils.findProcess(name);
......@@ -136,7 +134,7 @@ public class ApqRegisterJob {
}
// 上报白名单异常
mapRequest.put(name, "1");
mapSoftRequest.add(name);
}
}
}
......@@ -146,14 +144,20 @@ public class ApqRegisterJob {
}
// 上报黑白名单异常
if (mapRequest.size() > 0) {
if (mapSoftRequest.size() > 0) {
Map eventMapRequest = new HashMap();
Map mapRequest = new HashMap();
eventMapRequest.put("requestId", 2);
eventMapRequest.put("methodName", "BlackList");
eventMapRequest.put("methodName", type == 1 ? "BlackList" : "WhiteList"); // BlackList WriteList
eventMapRequest.put("params", mapRequest);
for (String mapSoftRequestData : mapSoftRequest) {
mapRequest.put("wbl", mapSoftRequestData);
Map map = restTemplate.postForObject("http://localhost:8765/uplink_event/oc-client", eventMapRequest, Map.class);
log.info("存在软件检测接口扫码告警,上报告警事件: mapData:{}, ret:{}", mapRequest, map);
}
}
} else {
log.info("未获取到获取软件检测监控配置");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论