@jshookmcp/jshook 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -661
- package/README.md +4 -4
- package/README.zh.md +3 -3
- package/dist/native/scripts/linux/enum-windows.sh +12 -12
- package/dist/native/scripts/macos/enum-windows.applescript +22 -22
- package/dist/native/scripts/windows/enum-windows-by-class.ps1 +51 -51
- package/dist/native/scripts/windows/enum-windows.ps1 +44 -44
- package/dist/native/scripts/windows/inject-dll.ps1 +21 -21
- package/dist/src/modules/analyzer/CodeAnalyzer.d.ts +1 -1
- package/dist/src/modules/analyzer/CodeAnalyzer.js +1 -1
- package/dist/src/modules/browser/BrowserDiscovery.d.ts +6 -5
- package/dist/src/modules/browser/BrowserDiscovery.js +1 -1
- package/dist/src/modules/browser/BrowserModeManager.d.ts +1 -1
- package/dist/src/modules/browser/BrowserModeManager.js +1 -1
- package/dist/src/modules/browser/UnifiedBrowserManager.js +1 -1
- package/dist/src/modules/captcha/AICaptchaDetector.d.ts +22 -22
- package/dist/src/modules/captcha/AICaptchaDetector.js +75 -75
- package/dist/src/modules/captcha/CaptchaDetector.d.ts +31 -17
- package/dist/src/modules/captcha/CaptchaDetector.js +1 -1
- package/dist/src/modules/collector/CodeCache.d.ts +2 -2
- package/dist/src/modules/collector/CodeCollector.d.ts +12 -9
- package/dist/src/modules/collector/CodeCollector.js +1 -1
- package/dist/src/modules/collector/DOMInspector.d.ts +3 -2
- package/dist/src/modules/collector/DOMInspector.js +1 -1
- package/dist/src/modules/crypto/CryptoDetector.d.ts +1 -1
- package/dist/src/modules/crypto/CryptoDetector.js +1 -1
- package/dist/src/modules/debugger/ScriptManager.impl.extract-function-tree.js +1 -1
- package/dist/src/modules/deobfuscator/Deobfuscator.d.ts +1 -1
- package/dist/src/modules/deobfuscator/Deobfuscator.js +1 -1
- package/dist/src/modules/deobfuscator/JSVMPDeobfuscator.restore.d.ts +1 -1
- package/dist/src/modules/deobfuscator/JSVMPDeobfuscator.restore.js +2 -2
- package/dist/src/modules/deobfuscator/PackerDeobfuscator.js +1 -1
- package/dist/src/modules/deobfuscator/VMDeobfuscator.d.ts +1 -1
- package/dist/src/modules/deobfuscator/VMDeobfuscator.js +82 -82
- package/dist/src/modules/emulator/AIEnvironmentAnalyzer.js +1 -1
- package/dist/src/modules/external/ExternalToolRunner.d.ts +1 -1
- package/dist/src/modules/external/ExternalToolRunner.js +1 -1
- package/dist/src/modules/hook/HookGeneratorBuilders.core.generators.compose.js +5 -5
- package/dist/src/modules/hook/HookGeneratorBuilders.core.generators.network.js +311 -311
- package/dist/src/modules/hook/HookGeneratorBuilders.core.generators.runtime.js +410 -410
- package/dist/src/modules/hook/HookGeneratorBuilders.core.generators.storage.js +122 -122
- package/dist/src/modules/monitor/ConsoleMonitor.impl.core.dynamic.js +194 -194
- package/dist/src/modules/monitor/PlaywrightNetworkMonitor.js +62 -62
- package/dist/src/modules/process/LinuxProcessManager.js +2 -2
- package/dist/src/modules/process/MacProcessManager.js +26 -26
- package/dist/src/modules/process/ProcessManager.impl.js +1 -1
- package/dist/src/modules/process/memory/availability.js +49 -49
- package/dist/src/modules/process/memory/injector.js +185 -185
- package/dist/src/modules/process/memory/reader.js +50 -50
- package/dist/src/modules/process/memory/regions.dump.js +51 -51
- package/dist/src/modules/process/memory/regions.enumerate.js +107 -107
- package/dist/src/modules/process/memory/regions.modules.js +80 -80
- package/dist/src/modules/process/memory/regions.protection.js +106 -106
- package/dist/src/modules/process/memory/scanner.darwin.js +41 -41
- package/dist/src/modules/process/memory/scanner.windows.js +124 -124
- package/dist/src/modules/process/memory/writer.js +54 -54
- package/dist/src/modules/security/ExecutionSandbox.js +44 -44
- package/dist/src/modules/stealth/StealthScripts.d.ts +3 -2
- package/dist/src/modules/stealth/StealthScripts.js +35 -1
- package/dist/src/modules/stealth/StealthVerifier.d.ts +1 -1
- package/dist/src/modules/stealth/StealthVerifier.js +1 -1
- package/dist/src/modules/trace/TraceDB.js +63 -63
- package/dist/src/native/CodeInjector.js +1 -1
- package/dist/src/native/HardwareBreakpoint.js +1 -1
- package/dist/src/server/MCPServer.js +1 -0
- package/dist/src/server/MCPServer.search.helpers.js +1 -1
- package/dist/src/server/MCPServer.tools.js +1 -1
- package/dist/src/server/ToolCallContextGuard.d.ts +5 -0
- package/dist/src/server/ToolCallContextGuard.js +77 -0
- package/dist/src/server/ToolRouter.d.ts +1 -1
- package/dist/src/server/ToolRouter.js +2 -2
- package/dist/src/server/domains/analysis/handlers.impl.d.ts +8 -8
- package/dist/src/server/domains/analysis/handlers.impl.js +8 -8
- package/dist/src/server/domains/analysis/handlers.web-tools.js +2 -2
- package/dist/src/server/domains/browser/definitions.tools.page-core.js +59 -59
- package/dist/src/server/domains/browser/definitions.tools.runtime.js +41 -41
- package/dist/src/server/domains/browser/definitions.tools.security.js +114 -114
- package/dist/src/server/domains/browser/handlers/facade-initializer.d.ts +3 -3
- package/dist/src/server/domains/browser/handlers/facade-initializer.js +3 -3
- package/dist/src/server/domains/browser/handlers/framework-state.js +210 -0
- package/dist/src/server/domains/browser/handlers/stealth-injection.js +8 -2
- package/dist/src/server/domains/browser/handlers.impl.d.ts +15 -11
- package/dist/src/server/domains/browser/handlers.impl.js +4 -4
- package/dist/src/server/domains/coordination/definitions.js +67 -0
- package/dist/src/server/domains/coordination/index.d.ts +18 -0
- package/dist/src/server/domains/coordination/index.js +132 -0
- package/dist/src/server/domains/coordination/manifest.js +15 -0
- package/dist/src/server/domains/graphql/handlers.impl.core.runtime.replay.js +2 -2
- package/dist/src/server/domains/graphql/handlers.impl.core.runtime.shared.js +77 -77
- package/dist/src/server/domains/hooks/ai-handlers.js +3 -3
- package/dist/src/server/domains/maintenance/handlers.d.ts +2 -2
- package/dist/src/server/domains/maintenance/handlers.js +2 -2
- package/dist/src/server/domains/platform/handlers/bridge-handlers.d.ts +1 -1
- package/dist/src/server/domains/platform/handlers/bridge-handlers.js +1 -1
- package/dist/src/server/domains/platform/handlers/miniapp-handlers.d.ts +1 -1
- package/dist/src/server/domains/platform/handlers/miniapp-handlers.js +1 -1
- package/dist/src/server/domains/process/handlers.impl.core.runtime.inject.js +1 -1
- package/dist/src/server/domains/trace/TraceSummarizer.d.ts +60 -0
- package/dist/src/server/domains/trace/TraceSummarizer.js +109 -0
- package/dist/src/server/domains/trace/definitions.tools.js +101 -71
- package/dist/src/server/domains/trace/handlers.d.ts +2 -1
- package/dist/src/server/domains/trace/handlers.js +59 -4
- package/dist/src/server/domains/trace/manifest.js +3 -1
- package/dist/src/server/domains/transform/handlers.impl.transform-base.js +103 -103
- package/dist/src/server/domains/wasm/handlers.js +2 -2
- package/dist/src/server/domains/workflow/handlers.impl.workflow-account-bundle.js +1 -1
- package/dist/src/server/domains/workflow/handlers.impl.workflow-api.js +51 -51
- package/dist/src/server/domains/workflow/handlers.impl.workflow-base.js +51 -51
- package/dist/src/server/extensions/ExtensionManager.roots.js +15 -5
- package/dist/src/server/http/HttpMiddleware.js +1 -1
- package/dist/src/server/registry/contracts.d.ts +6 -0
- package/dist/src/server/sandbox/MCPBridge.d.ts +9 -0
- package/dist/src/server/sandbox/MCPBridge.js +22 -0
- package/dist/src/server/sandbox/QuickJSSandbox.d.ts +4 -1
- package/dist/src/server/sandbox/QuickJSSandbox.js +149 -0
- package/dist/src/server/sandbox/SandboxHelpers.js +250 -250
- package/dist/src/server/sandbox/types.d.ts +13 -0
- package/dist/src/server/search/AffinityGraph.d.ts +7 -1
- package/dist/src/server/search/AffinityGraph.js +24 -3
- package/dist/src/services/LLMService.js +1 -1
- package/dist/src/utils/UnifiedCacheManager.d.ts +1 -1
- package/dist/src/utils/UnifiedCacheManager.js +2 -2
- package/dist/src/utils/cliFastPath.js +18 -4
- package/package.json +5 -3
- package/scripts/postinstall.cjs +37 -37
- package/src/native/scripts/linux/enum-windows.sh +12 -12
- package/src/native/scripts/macos/enum-windows.applescript +22 -22
- package/src/native/scripts/windows/enum-windows-by-class.ps1 +51 -51
- package/src/native/scripts/windows/enum-windows.ps1 +44 -44
- package/src/native/scripts/windows/inject-dll.ps1 +21 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jshookmcp/jshook",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "MCP server with 249 built-in tools (242 domain tools across 17 domains plus 7 built-in meta-tools) for AI-assisted JavaScript analysis and security analysis — browser automation, CDP debugging, network monitoring, JS hooks, code analysis, and workflow orchestration",
|
|
5
5
|
"mcpName": "io.github.vmoranv/jshookmcp",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"lefthook": "^2.1.3",
|
|
106
106
|
"medium-zoom": "^1.1.0",
|
|
107
107
|
"nodemon": "^3.1.14",
|
|
108
|
+
"oxlint": "^1.56.0",
|
|
108
109
|
"prettier": "^3.8.1",
|
|
109
110
|
"quickjs-emscripten": "^0.32.0",
|
|
110
111
|
"tsc-alias": "^1.8.16",
|
|
@@ -120,7 +121,7 @@
|
|
|
120
121
|
},
|
|
121
122
|
"scripts": {
|
|
122
123
|
"build": "node scripts/clean-dist.mjs && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && pnpm -C packages/extension-sdk build && node scripts/copy-native-scripts.mjs && node scripts/generate-entry-reexport.mjs && node scripts/fix-bin-permissions.mjs",
|
|
123
|
-
"typecheck": "tsc --noEmit -p tsconfig.json && pnpm -C packages/extension-sdk typecheck",
|
|
124
|
+
"typecheck": "tsc --noEmit -p tsconfig.build.json && pnpm -C packages/extension-sdk typecheck",
|
|
124
125
|
"dev": "tsx --conditions=development watch src/index.ts",
|
|
125
126
|
"start": "node dist/src/index.js",
|
|
126
127
|
"doctor": "tsx src/cli/doctor.ts",
|
|
@@ -131,6 +132,7 @@
|
|
|
131
132
|
"lint:md": "pnpm dlx markdownlint-cli2",
|
|
132
133
|
"format:docs": "pnpm run docs:generate && prettier docs .github README.md README.zh.md CONTRIBUTING.md --write",
|
|
133
134
|
"check:docs-format": "prettier docs .github README.md README.zh.md CONTRIBUTING.md --check",
|
|
135
|
+
"lint:ox": "oxlint src/ tests/",
|
|
134
136
|
"lint": "eslint src --ext .ts",
|
|
135
137
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
136
138
|
"test": "vitest run",
|
|
@@ -140,7 +142,7 @@
|
|
|
140
142
|
"package:verify-install": "node scripts/verify-packed-install.mjs",
|
|
141
143
|
"package:verify-release": "node scripts/verify-release-artifact.mjs",
|
|
142
144
|
"audit:tools": "node scripts/audit-tools.mjs",
|
|
143
|
-
"check": "pnpm run lint && pnpm run typecheck && pnpm run test",
|
|
145
|
+
"check": "pnpm run lint:ox && pnpm run lint && pnpm run typecheck && pnpm run test",
|
|
144
146
|
"package": "pnpm pack",
|
|
145
147
|
"postinstall": "node scripts/postinstall.cjs",
|
|
146
148
|
"install:full": "pnpm install && pnpm exec camoufox-js fetch"
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
const fs = require('node:fs');
|
|
2
|
-
const path = require('node:path');
|
|
3
|
-
const { spawnSync } = require('node:child_process');
|
|
4
|
-
|
|
5
|
-
const repoGitDir = path.join(process.cwd(), '.git');
|
|
6
|
-
const localBin = path.join(
|
|
7
|
-
process.cwd(),
|
|
8
|
-
'node_modules',
|
|
9
|
-
'.bin',
|
|
10
|
-
process.platform === 'win32' ? 'lefthook.cmd' : 'lefthook'
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
if (!fs.existsSync(repoGitDir)) {
|
|
14
|
-
process.exit(0);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (!fs.existsSync(localBin)) {
|
|
18
|
-
console.warn('[postinstall] lefthook not found locally; skipping git hook installation.');
|
|
19
|
-
process.exit(0);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const result = spawnSync(localBin, ['install'], {
|
|
23
|
-
stdio: 'inherit',
|
|
24
|
-
shell: process.platform === 'win32',
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (result.error) {
|
|
28
|
-
console.warn(
|
|
29
|
-
`[postinstall] lefthook install failed to spawn: ${result.error.message}; skipping git hook installation.`
|
|
30
|
-
);
|
|
31
|
-
} else if (result.status !== 0) {
|
|
32
|
-
console.warn(
|
|
33
|
-
`[postinstall] lefthook install exited with status ${result.status}; skipping git hook installation.`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
process.exit(0);
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { spawnSync } = require('node:child_process');
|
|
4
|
+
|
|
5
|
+
const repoGitDir = path.join(process.cwd(), '.git');
|
|
6
|
+
const localBin = path.join(
|
|
7
|
+
process.cwd(),
|
|
8
|
+
'node_modules',
|
|
9
|
+
'.bin',
|
|
10
|
+
process.platform === 'win32' ? 'lefthook.cmd' : 'lefthook'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
if (!fs.existsSync(repoGitDir)) {
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!fs.existsSync(localBin)) {
|
|
18
|
+
console.warn('[postinstall] lefthook not found locally; skipping git hook installation.');
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const result = spawnSync(localBin, ['install'], {
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
shell: process.platform === 'win32',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (result.error) {
|
|
28
|
+
console.warn(
|
|
29
|
+
`[postinstall] lefthook install failed to spawn: ${result.error.message}; skipping git hook installation.`
|
|
30
|
+
);
|
|
31
|
+
} else if (result.status !== 0) {
|
|
32
|
+
console.warn(
|
|
33
|
+
`[postinstall] lefthook install exited with status ${result.status}; skipping git hook installation.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
process.exit(0);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# enum-windows.sh
|
|
3
|
-
# Linux window enumeration script (placeholder)
|
|
4
|
-
|
|
5
|
-
TARGET_PID=$1
|
|
6
|
-
|
|
7
|
-
# Use xdotool or wmctrl for window enumeration
|
|
8
|
-
# This is a placeholder for future implementation
|
|
9
|
-
|
|
10
|
-
if command -v xdotool &> /dev/null; then
|
|
11
|
-
xdotool search --pid "$TARGET_PID" --name "" get-window-name
|
|
12
|
-
fi
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# enum-windows.sh
|
|
3
|
+
# Linux window enumeration script (placeholder)
|
|
4
|
+
|
|
5
|
+
TARGET_PID=$1
|
|
6
|
+
|
|
7
|
+
# Use xdotool or wmctrl for window enumeration
|
|
8
|
+
# This is a placeholder for future implementation
|
|
9
|
+
|
|
10
|
+
if command -v xdotool &> /dev/null; then
|
|
11
|
+
xdotool search --pid "$TARGET_PID" --name "" get-window-name
|
|
12
|
+
fi
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
-- enum-windows.applescript
|
|
2
|
-
-- macOS window enumeration script (placeholder)
|
|
3
|
-
|
|
4
|
-
param TargetPid
|
|
5
|
-
|
|
6
|
-
-- AppleScript implementation for window enumeration
|
|
7
|
-
-- This is a placeholder for future implementation
|
|
8
|
-
|
|
9
|
-
tell application "System Events"
|
|
10
|
-
set windowList to {}
|
|
11
|
-
repeat with proc in (every process whose unix id is TargetPid)
|
|
12
|
-
repeat with win in windows of proc
|
|
13
|
-
set end of windowList to {¬
|
|
14
|
-
title: name of win, ¬
|
|
15
|
-
position: position of win, ¬
|
|
16
|
-
size: size of win ¬
|
|
17
|
-
}
|
|
18
|
-
end repeat
|
|
19
|
-
end repeat
|
|
20
|
-
end tell
|
|
21
|
-
|
|
22
|
-
return windowList
|
|
1
|
+
-- enum-windows.applescript
|
|
2
|
+
-- macOS window enumeration script (placeholder)
|
|
3
|
+
|
|
4
|
+
param TargetPid
|
|
5
|
+
|
|
6
|
+
-- AppleScript implementation for window enumeration
|
|
7
|
+
-- This is a placeholder for future implementation
|
|
8
|
+
|
|
9
|
+
tell application "System Events"
|
|
10
|
+
set windowList to {}
|
|
11
|
+
repeat with proc in (every process whose unix id is TargetPid)
|
|
12
|
+
repeat with win in windows of proc
|
|
13
|
+
set end of windowList to {¬
|
|
14
|
+
title: name of win, ¬
|
|
15
|
+
position: position of win, ¬
|
|
16
|
+
size: size of win ¬
|
|
17
|
+
}
|
|
18
|
+
end repeat
|
|
19
|
+
end repeat
|
|
20
|
+
end tell
|
|
21
|
+
|
|
22
|
+
return windowList
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[string]$ClassPattern
|
|
3
|
-
)
|
|
4
|
-
|
|
5
|
-
Add-Type @"
|
|
6
|
-
using System;
|
|
7
|
-
using System.Runtime.InteropServices;
|
|
8
|
-
public class Win32 {
|
|
9
|
-
[DllImport("user32.dll")] public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childAfter, string className, string title);
|
|
10
|
-
[DllImport("user32.dll")] public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int pid);
|
|
11
|
-
[DllImport("user32.dll")] public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count);
|
|
12
|
-
[DllImport("user32.dll")] public static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder className, int maxCount);
|
|
13
|
-
}
|
|
14
|
-
"@
|
|
15
|
-
|
|
16
|
-
$windows = @()
|
|
17
|
-
$hwnd = [IntPtr]::Zero
|
|
18
|
-
while ($true) {
|
|
19
|
-
$hwnd = [Win32]::FindWindowEx([IntPtr]::Zero, $hwnd, $null, $null)
|
|
20
|
-
if ($hwnd -eq [IntPtr]::Zero) { break }
|
|
21
|
-
|
|
22
|
-
$className = New-Object System.Text.StringBuilder 256
|
|
23
|
-
[Win32]::GetClassName($hwnd, $className, 256) | Out-Null
|
|
24
|
-
$classNameStr = $className.ToString()
|
|
25
|
-
|
|
26
|
-
# Support wildcard pattern matching
|
|
27
|
-
$isMatch = $false
|
|
28
|
-
if ($ClassPattern -eq $classNameStr) {
|
|
29
|
-
$isMatch = $true
|
|
30
|
-
} elseif ($ClassPattern.Contains('*')) {
|
|
31
|
-
# Convert wildcard pattern to regex
|
|
32
|
-
$regexPattern = [regex]::Escape($ClassPattern).Replace('\*', '.*')
|
|
33
|
-
if ($classNameStr -match $regexPattern) {
|
|
34
|
-
$isMatch = $true
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if ($isMatch) {
|
|
39
|
-
$windowPid = 0
|
|
40
|
-
[Win32]::GetWindowThreadProcessId($hwnd, [ref]$windowPid) | Out-Null
|
|
41
|
-
$title = New-Object System.Text.StringBuilder 256
|
|
42
|
-
[Win32]::GetWindowText($hwnd, $title, 256) | Out-Null
|
|
43
|
-
$windows += @{
|
|
44
|
-
Handle = $hwnd.ToString()
|
|
45
|
-
Title = $title.ToString()
|
|
46
|
-
ClassName = $classNameStr
|
|
47
|
-
ProcessId = $windowPid
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
$windows | ConvertTo-Json -Compress
|
|
1
|
+
param(
|
|
2
|
+
[string]$ClassPattern
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
Add-Type @"
|
|
6
|
+
using System;
|
|
7
|
+
using System.Runtime.InteropServices;
|
|
8
|
+
public class Win32 {
|
|
9
|
+
[DllImport("user32.dll")] public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childAfter, string className, string title);
|
|
10
|
+
[DllImport("user32.dll")] public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int pid);
|
|
11
|
+
[DllImport("user32.dll")] public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count);
|
|
12
|
+
[DllImport("user32.dll")] public static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder className, int maxCount);
|
|
13
|
+
}
|
|
14
|
+
"@
|
|
15
|
+
|
|
16
|
+
$windows = @()
|
|
17
|
+
$hwnd = [IntPtr]::Zero
|
|
18
|
+
while ($true) {
|
|
19
|
+
$hwnd = [Win32]::FindWindowEx([IntPtr]::Zero, $hwnd, $null, $null)
|
|
20
|
+
if ($hwnd -eq [IntPtr]::Zero) { break }
|
|
21
|
+
|
|
22
|
+
$className = New-Object System.Text.StringBuilder 256
|
|
23
|
+
[Win32]::GetClassName($hwnd, $className, 256) | Out-Null
|
|
24
|
+
$classNameStr = $className.ToString()
|
|
25
|
+
|
|
26
|
+
# Support wildcard pattern matching
|
|
27
|
+
$isMatch = $false
|
|
28
|
+
if ($ClassPattern -eq $classNameStr) {
|
|
29
|
+
$isMatch = $true
|
|
30
|
+
} elseif ($ClassPattern.Contains('*')) {
|
|
31
|
+
# Convert wildcard pattern to regex
|
|
32
|
+
$regexPattern = [regex]::Escape($ClassPattern).Replace('\*', '.*')
|
|
33
|
+
if ($classNameStr -match $regexPattern) {
|
|
34
|
+
$isMatch = $true
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if ($isMatch) {
|
|
39
|
+
$windowPid = 0
|
|
40
|
+
[Win32]::GetWindowThreadProcessId($hwnd, [ref]$windowPid) | Out-Null
|
|
41
|
+
$title = New-Object System.Text.StringBuilder 256
|
|
42
|
+
[Win32]::GetWindowText($hwnd, $title, 256) | Out-Null
|
|
43
|
+
$windows += @{
|
|
44
|
+
Handle = $hwnd.ToString()
|
|
45
|
+
Title = $title.ToString()
|
|
46
|
+
ClassName = $classNameStr
|
|
47
|
+
ProcessId = $windowPid
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
$windows | ConvertTo-Json -Compress
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[int]$TargetPid
|
|
3
|
-
)
|
|
4
|
-
|
|
5
|
-
Add-Type @"
|
|
6
|
-
using System;
|
|
7
|
-
using System.Runtime.InteropServices;
|
|
8
|
-
public class Win32 {
|
|
9
|
-
[DllImport("user32.dll")] public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childAfter, string className, string title);
|
|
10
|
-
[DllImport("user32.dll")] public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int pid);
|
|
11
|
-
[DllImport("user32.dll")] public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count);
|
|
12
|
-
[DllImport("user32.dll")] public static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder className, int maxCount);
|
|
13
|
-
[DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hWnd, out RECT rect);
|
|
14
|
-
[StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left, Top, Right, Bottom; }
|
|
15
|
-
}
|
|
16
|
-
"@
|
|
17
|
-
|
|
18
|
-
$windows = @()
|
|
19
|
-
$hwnd = [IntPtr]::Zero
|
|
20
|
-
while ($true) {
|
|
21
|
-
$hwnd = [Win32]::FindWindowEx([IntPtr]::Zero, $hwnd, $null, $null)
|
|
22
|
-
if ($hwnd -eq [IntPtr]::Zero) { break }
|
|
23
|
-
$windowPid = 0
|
|
24
|
-
[Win32]::GetWindowThreadProcessId($hwnd, [ref]$windowPid) | Out-Null
|
|
25
|
-
if ($windowPid -eq $TargetPid) {
|
|
26
|
-
$title = New-Object System.Text.StringBuilder 256
|
|
27
|
-
$className = New-Object System.Text.StringBuilder 256
|
|
28
|
-
[Win32]::GetWindowText($hwnd, $title, 256) | Out-Null
|
|
29
|
-
[Win32]::GetClassName($hwnd, $className, 256) | Out-Null
|
|
30
|
-
$rect = New-Object Win32+RECT
|
|
31
|
-
[Win32]::GetWindowRect($hwnd, [ref]$rect) | Out-Null
|
|
32
|
-
$windows += @{
|
|
33
|
-
Handle = $hwnd.ToString()
|
|
34
|
-
Title = $title.ToString()
|
|
35
|
-
ClassName = $className.ToString()
|
|
36
|
-
ProcessId = $windowPid
|
|
37
|
-
Left = $rect.Left
|
|
38
|
-
Top = $rect.Top
|
|
39
|
-
Right = $rect.Right
|
|
40
|
-
Bottom = $rect.Bottom
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
$windows | ConvertTo-Json -Compress
|
|
1
|
+
param(
|
|
2
|
+
[int]$TargetPid
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
Add-Type @"
|
|
6
|
+
using System;
|
|
7
|
+
using System.Runtime.InteropServices;
|
|
8
|
+
public class Win32 {
|
|
9
|
+
[DllImport("user32.dll")] public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childAfter, string className, string title);
|
|
10
|
+
[DllImport("user32.dll")] public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int pid);
|
|
11
|
+
[DllImport("user32.dll")] public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count);
|
|
12
|
+
[DllImport("user32.dll")] public static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder className, int maxCount);
|
|
13
|
+
[DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hWnd, out RECT rect);
|
|
14
|
+
[StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left, Top, Right, Bottom; }
|
|
15
|
+
}
|
|
16
|
+
"@
|
|
17
|
+
|
|
18
|
+
$windows = @()
|
|
19
|
+
$hwnd = [IntPtr]::Zero
|
|
20
|
+
while ($true) {
|
|
21
|
+
$hwnd = [Win32]::FindWindowEx([IntPtr]::Zero, $hwnd, $null, $null)
|
|
22
|
+
if ($hwnd -eq [IntPtr]::Zero) { break }
|
|
23
|
+
$windowPid = 0
|
|
24
|
+
[Win32]::GetWindowThreadProcessId($hwnd, [ref]$windowPid) | Out-Null
|
|
25
|
+
if ($windowPid -eq $TargetPid) {
|
|
26
|
+
$title = New-Object System.Text.StringBuilder 256
|
|
27
|
+
$className = New-Object System.Text.StringBuilder 256
|
|
28
|
+
[Win32]::GetWindowText($hwnd, $title, 256) | Out-Null
|
|
29
|
+
[Win32]::GetClassName($hwnd, $className, 256) | Out-Null
|
|
30
|
+
$rect = New-Object Win32+RECT
|
|
31
|
+
[Win32]::GetWindowRect($hwnd, [ref]$rect) | Out-Null
|
|
32
|
+
$windows += @{
|
|
33
|
+
Handle = $hwnd.ToString()
|
|
34
|
+
Title = $title.ToString()
|
|
35
|
+
ClassName = $className.ToString()
|
|
36
|
+
ProcessId = $windowPid
|
|
37
|
+
Left = $rect.Left
|
|
38
|
+
Top = $rect.Top
|
|
39
|
+
Right = $rect.Right
|
|
40
|
+
Bottom = $rect.Bottom
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
$windows | ConvertTo-Json -Compress
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[int]$TargetPid,
|
|
3
|
-
[string]$DllPath
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
Add-Type @"
|
|
7
|
-
using System;
|
|
8
|
-
using System.Runtime.InteropServices;
|
|
9
|
-
public class Injector {
|
|
10
|
-
[DllImport("kernel32.dll")] public static extern IntPtr OpenProcess(int access, bool inherit, int pid);
|
|
11
|
-
[DllImport("kernel32.dll")] public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr addr, int size, int alloc, int protect);
|
|
12
|
-
[DllImport("kernel32.dll")] public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr addr, byte[] buffer, int size, out int written);
|
|
13
|
-
[DllImport("kernel32.dll")] public static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr attr, int stack, IntPtr start, IntPtr param, int flags, out int threadId);
|
|
14
|
-
[DllImport("kernel32.dll")] public static extern IntPtr GetModuleHandle(string name);
|
|
15
|
-
[DllImport("kernel32.dll")] public static extern IntPtr GetProcAddress(IntPtr hModule, string name);
|
|
16
|
-
[DllImport("kernel32.dll")] public static extern bool CloseHandle(IntPtr handle);
|
|
17
|
-
}
|
|
18
|
-
"@
|
|
19
|
-
|
|
20
|
-
# Injection requires elevated privileges and is disabled for safety
|
|
21
|
-
Write-Output "DLL injection is disabled for safety in this implementation. PID: $TargetPid, DLL: $DllPath"
|
|
1
|
+
param(
|
|
2
|
+
[int]$TargetPid,
|
|
3
|
+
[string]$DllPath
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
Add-Type @"
|
|
7
|
+
using System;
|
|
8
|
+
using System.Runtime.InteropServices;
|
|
9
|
+
public class Injector {
|
|
10
|
+
[DllImport("kernel32.dll")] public static extern IntPtr OpenProcess(int access, bool inherit, int pid);
|
|
11
|
+
[DllImport("kernel32.dll")] public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr addr, int size, int alloc, int protect);
|
|
12
|
+
[DllImport("kernel32.dll")] public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr addr, byte[] buffer, int size, out int written);
|
|
13
|
+
[DllImport("kernel32.dll")] public static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr attr, int stack, IntPtr start, IntPtr param, int flags, out int threadId);
|
|
14
|
+
[DllImport("kernel32.dll")] public static extern IntPtr GetModuleHandle(string name);
|
|
15
|
+
[DllImport("kernel32.dll")] public static extern IntPtr GetProcAddress(IntPtr hModule, string name);
|
|
16
|
+
[DllImport("kernel32.dll")] public static extern bool CloseHandle(IntPtr handle);
|
|
17
|
+
}
|
|
18
|
+
"@
|
|
19
|
+
|
|
20
|
+
# Injection requires elevated privileges and is disabled for safety
|
|
21
|
+
Write-Output "DLL injection is disabled for safety in this implementation. PID: $TargetPid, DLL: $DllPath"
|