From c4d2bfb5860bee12da4b884d1c09cc0ba5374121 Mon Sep 17 00:00:00 2001 From: coco3x Date: Sun, 1 Dec 2024 18:53:06 +0900 Subject: [PATCH 1/6] =?UTF-8?q?update:=20system=20validator=20-=20iwconfig?= =?UTF-8?q?=20=ED=8C=8C=EC=8B=B1=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/whoz_in/log_writer/SystemValidator.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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..f08270b0 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 @@ -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 추출 From 6e41d114e70f744fb85d44f338fe42aec2148882 Mon Sep 17 00:00:00 2001 From: coco3x Date: Sun, 1 Dec 2024 18:56:49 +0900 Subject: [PATCH 2/6] =?UTF-8?q?update:=20=EC=98=88=EC=99=B8=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/whoz_in/log_writer/SystemValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f08270b0..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() { From 59db972bb95d7e94a90477dcd3c0f77ef60d5900 Mon Sep 17 00:00:00 2001 From: coco3x Date: Sun, 1 Dec 2024 19:18:13 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20File=EC=9D=B4=20=EC=95=84=EB=8B=8C?= =?UTF-8?q?=20Sys.err=EB=A1=9C=20=EC=B6=9C=EB=A0=A5=EB=90=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit jar은 File 경로를 인식 불가 --- .../log_writer/common/process/ContinuousProcess.java | 1 - .../log_writer/common/process/TransientProcess.java | 2 -- .../com/whoz_in/log_writer/managed/arp/ArpLogProcess.java | 7 ++----- .../whoz_in/log_writer/managed/mdns/MdnsLogProcess.java | 5 ++--- .../com/whoz_in/log_writer/monitor/MonitorLogProcess.java | 5 ++--- .../com/whoz_in/log_writer/monitor/MonitorLogWriter.java | 2 -- modules/network-api/src/main/resources/application.yml | 2 +- 7 files changed, 7 insertions(+), 17 deletions(-) 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..b2c62bb4 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,17 @@ 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")) //이것도.. + .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/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 From c5d9eaccc4647f277462129ee6b3d955b597c069 Mon Sep 17 00:00:00 2001 From: coco3x Date: Sun, 1 Dec 2024 19:26:26 +0900 Subject: [PATCH 4/6] =?UTF-8?q?fix:=20monitor=20=EB=AA=85=EB=A0=B9?= =?UTF-8?q?=EC=96=B4=EC=97=90=20sudo=20=EB=B6=99=EC=9D=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../log-writer/src/main/resources/network-local.json | 2 +- .../log-writer/src/main/resources/network-prod.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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..f2531465 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 eth.src", "interface": "monitor_wlan" } } \ No newline at end of file From 2de6075699a8d00be7efad74c8e6856aedf0322c Mon Sep 17 00:00:00 2001 From: coco3x Date: Sun, 1 Dec 2024 19:39:49 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20prod=EC=97=90=EC=84=9C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8A=94=20monitor=20=EB=AA=85=EB=A0=B9?= =?UTF-8?q?=EC=96=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit local은 monitor모드가 불가능하기 때문에 eth.src를 사용해야 하며, prod는 monitor모드를 사용하여 eth.src를 알 수 없다. --- .../log-writer/src/main/resources/network-prod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f2531465..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": "sudo -S 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 From 05fec9c3fe95f40ac4277270c3f5984f609fef28 Mon Sep 17 00:00:00 2001 From: coco3x Date: Sun, 1 Dec 2024 19:45:42 +0900 Subject: [PATCH 6/6] =?UTF-8?q?temp:=20arp=EB=8A=94=20error=20stream?= =?UTF-8?q?=EC=9D=84=20=EC=B6=9C=EB=A0=A5=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/whoz_in/log_writer/managed/arp/ArpLogProcess.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 b2c62bb4..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 @@ -14,7 +14,9 @@ public ArpLogProcess(ManagedInfo info, String password) { try { //TODO: error 처리 로직 수정 super.process = new ProcessBuilder(info.command().split(" ")) - .redirectError(Redirect.INHERIT) + //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()));