Skip to content

Commit a3fd986

Browse files
authored
Merge pull request #15 from T3pp31/codex/web-vulnerability-checks
[codex] add web vulnerability checks
2 parents d9798bd + 7a26232 commit a3fd986

29 files changed

Lines changed: 2508 additions & 148 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ node_modules/
55
dist/
66
coverage/
77
src-tauri/target/
8+
src-tauri/target-codex*/
89
tools/**/target/
910

1011
# Environment

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ Npcap SDK は以下のいずれかの方法で配置してください。
164164
| `[scan]` | `reset_packet_count` | ARP 停止時に送信する復旧パケット数 |
165165
| `[scan]` | `progress_report_interval` | 進捗イベント送信間隔 |
166166
| `[scan]` | `lan_scan_arp_retry_count` | LAN スキャン時の ARP リトライ回数 |
167+
| `[scan]` | `lan_scan_concurrency` | LAN スキャン同時実行数 |
167168
| `[vendor]` | `api_url` | MAC ベンダー API の URL |
168169
| `[vendor]` | `use_local_oui` | ローカル OUI データベースの使用 |
169170
| `[vendor]` | `api_timeout_ms` | MAC ベンダー API タイムアウト (ms) |

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8+
"tauri": "tauri",
9+
"tauri:dev": "tauri dev",
810
"build": "tsc -b && vite build",
911
"lint": "eslint .",
1012
"preview": "vite preview"

scripts/setup-npcap-sdk.ps1

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
11
#Requires -Version 5.1
22
<#
33
.SYNOPSIS
4-
Npcap SDK をダウンロード・展開し、環境変数 NPCAP_SDK_DIR をセットする。
4+
Download and install the Npcap SDK, then set NPCAP_SDK_DIR.
55
.DESCRIPTION
6-
build.rs NPCAP_SDK_DIR を読んで cargo:rustc-link-search を出力するため、
7-
このスクリプトでローカル開発環境を準備する。
6+
build.rs reads NPCAP_SDK_DIR and emits cargo:rustc-link-search.
7+
This script prepares a local Windows development environment.
88
#>
99

1010
Set-StrictMode -Version Latest
1111
$ErrorActionPreference = "Stop"
1212

13-
# ---------------------------------------------------------------------------
14-
# 設定値(変更が必要な場合はここを編集)
15-
# ---------------------------------------------------------------------------
16-
$SdkVersion = "1.13"
17-
$SdkUrl = "https://npcap.com/dist/npcap-sdk-$SdkVersion.zip"
18-
$InstallPath = "C:\npcap-sdk"
19-
$EnvVarName = "NPCAP_SDK_DIR"
20-
$ZipPath = Join-Path $env:TEMP "npcap-sdk-$SdkVersion.zip"
13+
$SdkVersion = "1.13"
14+
$SdkUrl = "https://npcap.com/dist/npcap-sdk-$SdkVersion.zip"
15+
$InstallPath = "C:\npcap-sdk"
16+
$EnvVarName = "NPCAP_SDK_DIR"
17+
$ZipPath = Join-Path $env:TEMP "npcap-sdk-$SdkVersion.zip"
18+
19+
function Set-NpcapSdkEnvVar {
20+
$currentValue = [System.Environment]::GetEnvironmentVariable($EnvVarName, "User")
21+
if ($currentValue -eq $InstallPath) {
22+
Write-Host "[INFO] User environment variable $EnvVarName is already set."
23+
return
24+
}
25+
26+
[System.Environment]::SetEnvironmentVariable($EnvVarName, $InstallPath, "User")
27+
$env:NPCAP_SDK_DIR = $InstallPath
28+
Write-Host "[INFO] Set user environment variable $EnvVarName to $InstallPath."
29+
}
30+
31+
function Test-NpcapSdkLayout {
32+
$libPath = Join-Path $InstallPath "Lib\x64"
33+
if (-not (Test-Path $libPath)) {
34+
Write-Error "[ERROR] Expected SDK library directory was not found: $libPath"
35+
exit 1
36+
}
37+
}
2138

22-
# ---------------------------------------------------------------------------
23-
# メイン処理
24-
# ---------------------------------------------------------------------------
2539
function Main {
26-
# 既にインストール済みか確認
2740
if (Test-Path $InstallPath) {
28-
Write-Host "[INFO] $InstallPath は既に存在します。"
29-
$answer = Read-Host "上書きしますか? (y/N)"
41+
Write-Host "[INFO] $InstallPath already exists."
42+
$answer = Read-Host "Overwrite it? (y/N)"
3043
if ($answer -ne "y") {
31-
Write-Host "[INFO] スキップしました。"
32-
Set-EnvVar
44+
Write-Host "[INFO] Skipped download and extraction."
45+
Test-NpcapSdkLayout
46+
Set-NpcapSdkEnvVar
3347
return
3448
}
49+
3550
Remove-Item -Recurse -Force $InstallPath
36-
Write-Host "[INFO] 既存ディレクトリを削除しました。"
51+
Write-Host "[INFO] Removed existing directory."
3752
}
3853

39-
# ダウンロード
40-
Write-Host "[INFO] Npcap SDK $SdkVersion をダウンロード中..."
54+
Write-Host "[INFO] Downloading Npcap SDK $SdkVersion..."
4155
try {
4256
Invoke-WebRequest -Uri $SdkUrl -OutFile $ZipPath -UseBasicParsing
4357
}
4458
catch {
45-
Write-Error "[ERROR] ダウンロードに失敗しました: $_"
59+
Write-Error "[ERROR] Failed to download Npcap SDK: $_"
4660
exit 1
4761
}
4862

4963
if (-not (Test-Path $ZipPath)) {
50-
Write-Error "[ERROR] ZIPファイルが見つかりません: $ZipPath"
64+
Write-Error "[ERROR] ZIP file was not found: $ZipPath"
5165
exit 1
5266
}
5367

54-
# 展開
55-
Write-Host "[INFO] $InstallPath に展開中..."
68+
Write-Host "[INFO] Extracting to $InstallPath..."
5669
try {
5770
Expand-Archive -Path $ZipPath -DestinationPath $InstallPath -Force
5871
}
5972
catch {
60-
Write-Error "[ERROR] 展開に失敗しました: $_"
73+
Write-Error "[ERROR] Failed to extract Npcap SDK: $_"
6174
exit 1
6275
}
6376

64-
# ZIPファイルを削除
6577
Remove-Item -Force $ZipPath -ErrorAction SilentlyContinue
6678

67-
# 環境変数をセット
68-
Set-EnvVar
79+
Test-NpcapSdkLayout
80+
Set-NpcapSdkEnvVar
6981

7082
Write-Host ""
71-
Write-Host "[SUCCESS] Npcap SDK $SdkVersion のセットアップが完了しました。"
72-
Write-Host " インストール先 : $InstallPath"
73-
Write-Host " 環境変数 : $EnvVarName = $InstallPath"
83+
Write-Host "[SUCCESS] Npcap SDK $SdkVersion setup completed."
84+
Write-Host " Install path : $InstallPath"
85+
Write-Host " Env var : $EnvVarName = $InstallPath"
7486
Write-Host ""
75-
Write-Host "※ 新しいターミナルを開くと環境変数が反映されます。"
76-
}
77-
78-
function Set-EnvVar {
79-
$currentValue = [System.Environment]::GetEnvironmentVariable($EnvVarName, "User")
80-
if ($currentValue -eq $InstallPath) {
81-
Write-Host "[INFO] 環境変数 $EnvVarName は既に設定済みです。"
82-
return
83-
}
84-
[System.Environment]::SetEnvironmentVariable($EnvVarName, $InstallPath, "User")
85-
# 現在のセッションにも反映
86-
$env:NPCAP_SDK_DIR = $InstallPath
87-
Write-Host "[INFO] ユーザー環境変数 $EnvVarName$InstallPath に設定しました。"
87+
Write-Host "Open a new terminal if another process needs the updated user environment."
8888
}
8989

9090
Main

src-tauri/build.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,9 @@ fn configure_npcap_link_search() {
3636

3737
// 1. 環境変数 NPCAP_SDK_DIR が指定されている場合
3838
if let Ok(sdk_dir) = std::env::var(NPCAP_SDK_ENV) {
39-
let lib_path = std::path::PathBuf::from(&sdk_dir)
40-
.join("Lib")
41-
.join("x64");
39+
let lib_path = std::path::PathBuf::from(&sdk_dir).join("Lib").join("x64");
4240
if lib_path.is_dir() {
43-
println!(
44-
"cargo:rustc-link-search=native={}",
45-
lib_path.display()
46-
);
41+
println!("cargo:rustc-link-search=native={}", lib_path.display());
4742
return;
4843
}
4944
panic!(
@@ -66,10 +61,7 @@ fn configure_npcap_link_search() {
6661
// 3. %USERPROFILE%\.npcap-sdk\Lib\x64
6762
if let Some(path) = userprofile_npcap_path() {
6863
if path.is_dir() {
69-
println!(
70-
"cargo:rustc-link-search=native={}",
71-
path.display()
72-
);
64+
println!("cargo:rustc-link-search=native={}", path.display());
7365
return;
7466
}
7567
}
@@ -87,9 +79,7 @@ fn configure_npcap_link_search() {
8779
if let Some(path) = userprofile_npcap_path() {
8880
msg.push_str(&format!(" - {}\n", path.display()));
8981
}
90-
msg.push_str(
91-
"\nNpcap SDK は https://npcap.com/#download からダウンロードできます。",
92-
);
82+
msg.push_str("\nNpcap SDK は https://npcap.com/#download からダウンロードできます。");
9383
panic!("{msg}");
9484
}
9585

src-tauri/config/default.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ poison_interval_sec = 2
88
reset_packet_count = 5
99
progress_report_interval = 100
1010
lan_scan_arp_retry_count = 1
11+
lan_scan_concurrency = 32
1112

1213
[vendor]
1314
api_url = "http://macvendors.co/api/"

src-tauri/src/commands/arp_spoof.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,11 @@ pub async fn start_arp_spoof(
2222
if !crate::network::npcap::is_npcap_available() {
2323
return Err(AppError::NpcapNotFound(NPCAP_DOWNLOAD_URL.to_string()));
2424
}
25-
crate::network::arp_spoof::start(
26-
&target_ip,
27-
&gateway_ip,
28-
packet_count,
29-
&state,
30-
)
31-
.await
25+
crate::network::arp_spoof::start(&target_ip, &gateway_ip, packet_count, &state).await
3226
}
3327

3428
#[tauri::command]
35-
pub async fn stop_arp_spoof(
36-
state: tauri::State<'_, AppState>,
37-
) -> Result<ArpSpoofStatus, AppError> {
29+
pub async fn stop_arp_spoof(state: tauri::State<'_, AppState>) -> Result<ArpSpoofStatus, AppError> {
3830
crate::network::arp_spoof::stop(&state).await
3931
}
4032

src-tauri/src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ pub mod lan_scan;
44
pub mod network_info;
55
pub mod npcap;
66
pub mod port_scan;
7+
pub mod web_check;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::error::AppError;
2+
use crate::network::web_check::{
3+
AuthHeaderInput, InputCheckRequest, WebCheckOptions, WebCheckResult,
4+
};
5+
use crate::AppState;
6+
7+
#[tauri::command]
8+
pub async fn web_check(
9+
target_url: String,
10+
mode: Option<String>,
11+
auth_headers: Option<Vec<AuthHeaderInput>>,
12+
extra_paths: Option<Vec<String>>,
13+
input_checks: Option<Vec<InputCheckRequest>>,
14+
state: tauri::State<'_, AppState>,
15+
) -> Result<WebCheckResult, AppError> {
16+
let options = WebCheckOptions {
17+
mode,
18+
auth_headers: auth_headers.unwrap_or_default(),
19+
extra_paths: extra_paths.unwrap_or_default(),
20+
input_checks: input_checks.unwrap_or_default(),
21+
};
22+
23+
crate::network::web_check::check_with_options(&target_url, &state.http_client, options).await
24+
}

src-tauri/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub struct ScanConfig {
2424
pub reset_packet_count: u32,
2525
pub progress_report_interval: u32,
2626
pub lan_scan_arp_retry_count: u32,
27+
pub lan_scan_concurrency: usize,
2728
}
2829

2930
#[derive(Debug, Deserialize, Clone)]
@@ -87,6 +88,7 @@ impl Default for AppConfig {
8788
reset_packet_count: 5,
8889
progress_report_interval: 100,
8990
lan_scan_arp_retry_count: 1,
91+
lan_scan_concurrency: 32,
9092
},
9193
vendor: VendorConfig {
9294
api_url: "http://macvendors.co/api/".to_string(),

0 commit comments

Comments
 (0)