diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/SystemValidator.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/SystemValidator.java index e957fce8..4931ff38 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/SystemValidator.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/SystemValidator.java @@ -54,7 +54,7 @@ private void checkNetworkInterfaces(List system, List getNetworkInterfaces() { @@ -68,14 +68,17 @@ private List getNetworkInterfaces() { for (String line : iwconfigOutput) { line = line.trim(); // 인터페이스 이름 감지 (인터페이스 정보 나오기 시작) - if (!line.startsWith(" ") && line.contains("IEEE 802.11")) { + if (!line.startsWith(" ") && (line.contains("IEEE 802.11") || line.contains("unassociated"))) { if (currentName != null) { // 첫 인터페이스가 아니면 모아둔 이전 인터페이스의 정보 저장 interfaces.add(new NetworkInterface(currentName, currentEssid, currentMode)); } // 새 인터페이스 정보 모으기 & 초기화 currentName = line.split("\\s+")[0]; - currentEssid = line.split("ESSID:")[1].split("\\s+")[0].replace("\"", "").trim(); + if (line.contains("ESSID:")) + currentEssid = line.split("ESSID:")[1].split("\\s+")[0].replace("\"", "").trim(); + else + currentEssid = ""; currentMode = null; // 초기화 } // Mode 추출 diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/common/process/ContinuousProcess.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/common/process/ContinuousProcess.java index 3994ab9b..2b7e5347 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/common/process/ContinuousProcess.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/common/process/ContinuousProcess.java @@ -7,7 +7,6 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Writer; -import lombok.NoArgsConstructor; //실행 후 종료되지 않는 프로세스 //꾸준히 출력을 읽을 수 있어야 한다. diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/common/process/TransientProcess.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/common/process/TransientProcess.java index 8091d65a..21052682 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/common/process/TransientProcess.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/common/process/TransientProcess.java @@ -2,14 +2,12 @@ import jakarta.annotation.Nullable; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.ArrayList; import java.util.List; -import lombok.NoArgsConstructor; //실행 후 종료되어 모든 출력을 얻는 프로세스 //출력 스트림을 통한 프로세스와의 상호작용은 없다. diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/managed/arp/ArpLogProcess.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/managed/arp/ArpLogProcess.java index 9c9cd905..34e121ad 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/managed/arp/ArpLogProcess.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/managed/arp/ArpLogProcess.java @@ -4,20 +4,19 @@ import com.whoz_in.log_writer.managed.ManagedInfo; import java.io.BufferedReader; import java.io.BufferedWriter; -import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; -import java.util.ArrayList; -import java.util.List; +import java.lang.ProcessBuilder.Redirect; public class ArpLogProcess extends TransientProcess { public ArpLogProcess(ManagedInfo info, String password) { try { //TODO: error 처리 로직 수정 - new File("../error").mkdir(); //에러 처리 수정하면 이거 없앨게요.. super.process = new ProcessBuilder(info.command().split(" ")) - .redirectError(new File("../error", info.ssid()+".txt")) //이것도.. + //arp-scan 실행할 때마다 아래와 같은 오류가 떠서 일단 Error Stream 출력 안하도록 했음 + // WARNING: Cannot open MAC/Vendor file ieee-oui.txt: Permission denied +// .redirectError(Redirect.INHERIT) .start(); super.br = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(process.getOutputStream())); diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/managed/mdns/MdnsLogProcess.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/managed/mdns/MdnsLogProcess.java index 7162abcb..186ef787 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/managed/mdns/MdnsLogProcess.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/managed/mdns/MdnsLogProcess.java @@ -4,19 +4,18 @@ import com.whoz_in.log_writer.common.util.NonBlockingBufferedReader; import com.whoz_in.log_writer.managed.ManagedInfo; import java.io.BufferedReader; -import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Writer; +import java.lang.ProcessBuilder.Redirect; public class MdnsLogProcess extends ContinuousProcess { public MdnsLogProcess(ManagedInfo info, String sudoPassword) { try { - new File("../error").mkdir(); //에러 처리 수정하면 이거 없앨게요.. super.process = new ProcessBuilder(info.command().split(" ")) - .redirectError(new File("../error", info.ssid()+".txt")) + .redirectError(Redirect.INHERIT) .start(); super.br = new NonBlockingBufferedReader(new BufferedReader(new InputStreamReader(this.process.getInputStream()))); Writer writer = new OutputStreamWriter(this.process.getOutputStream()); diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/monitor/MonitorLogProcess.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/monitor/MonitorLogProcess.java index f6ab5c93..ab4793f5 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/monitor/MonitorLogProcess.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/monitor/MonitorLogProcess.java @@ -3,19 +3,18 @@ import com.whoz_in.log_writer.common.process.ContinuousProcess; import com.whoz_in.log_writer.common.util.NonBlockingBufferedReader; import java.io.BufferedReader; -import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Writer; +import java.lang.ProcessBuilder.Redirect; public final class MonitorLogProcess extends ContinuousProcess { public MonitorLogProcess(MonitorInfo info, String sudoPassword) { try { - new File("../error").mkdir(); //에러 처리 수정하면 이거 없앨게요.. super.process = new ProcessBuilder(info.command().split(" ")) - .redirectError(new File("../error", "monitor.txt")) + .redirectError(Redirect.INHERIT) .start(); super.br = new NonBlockingBufferedReader(new BufferedReader(new InputStreamReader(process.getInputStream()))); diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/monitor/MonitorLogWriter.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/monitor/MonitorLogWriter.java index 8c7c9fbb..292da1b1 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/monitor/MonitorLogWriter.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/monitor/MonitorLogWriter.java @@ -1,8 +1,6 @@ package com.whoz_in.log_writer.monitor; import com.whoz_in.log_writer.config.NetworkConfig; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.HashSet; import java.util.Set; import org.springframework.beans.factory.annotation.Value; diff --git a/modules/infrastructure/log-writer/src/main/resources/network-local.json b/modules/infrastructure/log-writer/src/main/resources/network-local.json index 4a5191a9..e21d33f0 100644 --- a/modules/infrastructure/log-writer/src/main/resources/network-local.json +++ b/modules/infrastructure/log-writer/src/main/resources/network-local.json @@ -8,7 +8,7 @@ ], "monitor": { - "command": "tshark -l -i {{interface}} -T fields -e wlan.sa -e eth.src", + "command": "sudo -S tshark -l -i {{interface}} -T fields -e wlan.sa -e eth.src", "interface": "en0" }, diff --git a/modules/infrastructure/log-writer/src/main/resources/network-prod.json b/modules/infrastructure/log-writer/src/main/resources/network-prod.json index 577e248d..4ff7a527 100644 --- a/modules/infrastructure/log-writer/src/main/resources/network-prod.json +++ b/modules/infrastructure/log-writer/src/main/resources/network-prod.json @@ -34,7 +34,7 @@ }, "monitor": { - "command": "tshark -l -i {{interface}} -T fields -e wlan.sa -e eth.src", + "command": "sudo -S tshark -l -i {{interface}} -T fields -e wlan.sa -e wlan.ra", "interface": "monitor_wlan" } } \ No newline at end of file diff --git a/modules/network-api/src/main/resources/application.yml b/modules/network-api/src/main/resources/application.yml index bacc4e9b..88a72c5a 100644 --- a/modules/network-api/src/main/resources/application.yml +++ b/modules/network-api/src/main/resources/application.yml @@ -6,5 +6,5 @@ spring: group: local: prod: - active: local + active: prod include: log-writer