Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

라베파 환경에 맞춰서 수정 #67

Merged
merged 6 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void checkNetworkInterfaces(List<NetworkInterface> system, List<NetworkI
System.out.println("\n설정된 네트워크 인터페이스:");
setting.forEach(System.out::println);
if (!system.containsAll(setting))
throw new IllegalStateException("로깅하려는 인터페이스가 시스템에 존재하지 않습니다.");
throw new IllegalStateException("로깅하려는 인터페이스가 시스템에 존재하지 않거나 상태가 올바르지 않습니다.");
}

private List<NetworkInterface> getNetworkInterfaces() {
Expand All @@ -68,14 +68,17 @@ private List<NetworkInterface> 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 추출
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import lombok.NoArgsConstructor;

//실행 후 종료되지 않는 프로세스
//꾸준히 출력을 읽을 수 있어야 한다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

//실행 후 종료되어 모든 출력을 얻는 프로세스
//출력 스트림을 통한 프로세스와의 상호작용은 없다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())));

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion modules/network-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ spring:
group:
local:
prod:
active: local
active: prod
include: log-writer