anymous 1.2.1 → 1.2.2
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/package.json +1 -1
- package/src/cli/cmd/run/splash.ts +1 -1
- package/src/cli/ui.ts +1 -1
- package/src/tool/computer.ts +59 -24
- package/src/tool/computer.txt +10 -10
package/package.json
CHANGED
|
@@ -171,7 +171,7 @@ function draw(
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
const VERSION = "1.2.
|
|
174
|
+
const VERSION = "1.2.2"
|
|
175
175
|
|
|
176
176
|
function build(input: SplashWriterInput, kind: "entry" | "exit", ctx: ScrollbackRenderContext): ScrollbackSnapshot {
|
|
177
177
|
const width = Math.max(1, ctx.width)
|
package/src/cli/ui.ts
CHANGED
|
@@ -54,7 +54,7 @@ export function logo(pad?: string) {
|
|
|
54
54
|
result.push(row)
|
|
55
55
|
result.push(EOL)
|
|
56
56
|
}
|
|
57
|
-
result.push("AI-Powered Reverse Engineering & Pentest Platform v1.2.
|
|
57
|
+
result.push("AI-Powered Reverse Engineering & Pentest Platform v1.2.2")
|
|
58
58
|
return result.join("")
|
|
59
59
|
}
|
|
60
60
|
|
package/src/tool/computer.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Effect, Schema, pipe } from "effect"
|
|
2
2
|
import * as Tool from "./tool"
|
|
3
|
-
import { spawn
|
|
3
|
+
import { spawn } from "child_process"
|
|
4
4
|
import DESCRIPTION from "./computer.txt"
|
|
5
5
|
|
|
6
6
|
const platform = process.platform
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const powershellScript = (script: string) =>
|
|
9
9
|
Effect.promise<string>(
|
|
10
10
|
() =>
|
|
11
11
|
new Promise((resolve, reject) => {
|
|
12
|
+
const enc = Buffer.from(script, "utf16le").toString("base64")
|
|
12
13
|
const proc = spawn("powershell", [
|
|
13
14
|
"-NoProfile",
|
|
14
15
|
"-NonInteractive",
|
|
15
|
-
"-
|
|
16
|
-
|
|
16
|
+
"-EncodedCommand",
|
|
17
|
+
enc,
|
|
17
18
|
])
|
|
18
19
|
let stdout = ""
|
|
19
20
|
let stderr = ""
|
|
@@ -23,13 +24,13 @@ const poweshellScript = (script: string) =>
|
|
|
23
24
|
if (code === 0) resolve(stdout.trim())
|
|
24
25
|
else reject(new Error(stderr.trim() || `exit code ${code}`))
|
|
25
26
|
})
|
|
26
|
-
proc.on("error", reject)
|
|
27
|
+
proc.on("error", (e) => reject(e))
|
|
27
28
|
}),
|
|
28
29
|
)
|
|
29
30
|
|
|
30
31
|
const captureScreenshot = Effect.fn("Computer.screenshot")(function* () {
|
|
31
32
|
if (platform === "win32") {
|
|
32
|
-
const base64 = yield*
|
|
33
|
+
const base64 = yield* powershellScript(`
|
|
33
34
|
Add-Type -AssemblyName System.Drawing
|
|
34
35
|
Add-Type -AssemblyName System.Windows.Forms
|
|
35
36
|
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
|
|
@@ -83,7 +84,7 @@ $ms.Dispose()
|
|
|
83
84
|
|
|
84
85
|
const moveMouse = Effect.fn("Computer.moveMouse")(function* (x: number, y: number) {
|
|
85
86
|
if (platform === "win32") {
|
|
86
|
-
yield*
|
|
87
|
+
yield* powershellScript(`
|
|
87
88
|
Add-Type -AssemblyName System.Windows.Forms
|
|
88
89
|
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(${Math.round(x)}, ${Math.round(y)})
|
|
89
90
|
`)
|
|
@@ -111,30 +112,38 @@ Add-Type -AssemblyName System.Windows.Forms
|
|
|
111
112
|
|
|
112
113
|
const clickMouse = Effect.fn("Computer.clickMouse")(function* (button: "left" | "right" | "middle") {
|
|
113
114
|
if (platform === "win32") {
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
yield* poweshellScript(`
|
|
115
|
+
const down = button === "left" ? "LEFTDOWN" : button === "right" ? "RIGHTDOWN" : "MIDDLEDOWN"
|
|
116
|
+
const up = button === "left" ? "LEFTUP" : button === "right" ? "RIGHTUP" : "MIDDLEUP"
|
|
117
|
+
yield* powershellScript(`
|
|
118
118
|
Add-Type -AssemblyName System.Windows.Forms
|
|
119
|
-
|
|
119
|
+
$c = Add-Type -TypeDefinition @'
|
|
120
|
+
using System;
|
|
121
|
+
using System.Runtime.InteropServices;
|
|
122
|
+
public class W32 {
|
|
123
|
+
[DllImport("user32.dll")] public static extern void mouse_event(uint f, uint x, uint y, uint d, int i);
|
|
124
|
+
public const uint L=0x02,R=0x08,M=0x20,LU=0x04,RU=0x10,MU=0x40;
|
|
125
|
+
}
|
|
126
|
+
'@
|
|
127
|
+
[W32]::mouse_event([W32]::${down}, 0, 0, 0, 0); Start-Sleep -Milliseconds 50
|
|
128
|
+
[W32]::mouse_event([W32]::${up}, 0, 0, 0, 0); Write-Output OK
|
|
120
129
|
`)
|
|
121
130
|
} else if (platform === "darwin") {
|
|
122
|
-
const
|
|
131
|
+
const action = button === "left" ? "click" : button === "right" ? "click at (get position of mouse) using {button 2}" : "click at (get position of mouse) using {button 3}"
|
|
123
132
|
yield* Effect.promise(() =>
|
|
124
133
|
new Promise<void>((resolve, reject) => {
|
|
125
134
|
const proc = spawn("osascript", [
|
|
126
135
|
"-e",
|
|
127
|
-
`tell application "System Events" to ${
|
|
136
|
+
`tell application "System Events" to ${action}`,
|
|
128
137
|
])
|
|
129
138
|
proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
|
|
130
139
|
proc.on("error", reject)
|
|
131
140
|
}),
|
|
132
141
|
)
|
|
133
142
|
} else if (platform === "linux") {
|
|
134
|
-
const
|
|
143
|
+
const b = button === "left" ? "1" : button === "right" ? "3" : "2"
|
|
135
144
|
yield* Effect.promise(() =>
|
|
136
145
|
new Promise<void>((resolve, reject) => {
|
|
137
|
-
const proc = spawn("xdotool", ["click",
|
|
146
|
+
const proc = spawn("xdotool", ["click", b])
|
|
138
147
|
proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
|
|
139
148
|
proc.on("error", reject)
|
|
140
149
|
}),
|
|
@@ -142,11 +151,29 @@ Add-Type -AssemblyName System.Windows.Forms
|
|
|
142
151
|
}
|
|
143
152
|
})
|
|
144
153
|
|
|
154
|
+
const escapeSendKeys = (s: string) =>
|
|
155
|
+
s
|
|
156
|
+
.replace(/{/g, "{{}")
|
|
157
|
+
.replace(/}/g, "{}}")
|
|
158
|
+
.replace(/\+/g, "{+}")
|
|
159
|
+
.replace(/\^/g, "{^}")
|
|
160
|
+
.replace(/%/g, "{%}")
|
|
161
|
+
.replace(/~/g, "{~}")
|
|
162
|
+
.replace(/\(/g, "{(}")
|
|
163
|
+
.replace(/\)/g, "{)}")
|
|
164
|
+
.replace(/\[/g, "{[}")
|
|
165
|
+
.replace(/\]/g, "{]}")
|
|
166
|
+
.replace(/"/g, '`"')
|
|
167
|
+
.replace(/\$/g, "`$")
|
|
168
|
+
.replace(/\n/g, "`n")
|
|
169
|
+
.replace(/\r/g, "`r")
|
|
170
|
+
.replace(/\t/g, "`t")
|
|
171
|
+
|
|
145
172
|
const typeText = Effect.fn("Computer.typeText")(function* (text: string, delayMs: number = 0) {
|
|
146
173
|
const typeChar = (char: string) => {
|
|
147
174
|
if (platform === "win32") {
|
|
148
|
-
const esc = char
|
|
149
|
-
return
|
|
175
|
+
const esc = escapeSendKeys(char)
|
|
176
|
+
return powershellScript(`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait("${esc}")`)
|
|
150
177
|
} else if (platform === "darwin") {
|
|
151
178
|
return Effect.promise<void>(() =>
|
|
152
179
|
new Promise((resolve, reject) => {
|
|
@@ -167,8 +194,8 @@ const typeText = Effect.fn("Computer.typeText")(function* (text: string, delayMs
|
|
|
167
194
|
}
|
|
168
195
|
if (delayMs <= 0) {
|
|
169
196
|
if (platform === "win32") {
|
|
170
|
-
const escaped = text
|
|
171
|
-
yield*
|
|
197
|
+
const escaped = escapeSendKeys(text)
|
|
198
|
+
yield* powershellScript(`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait("${escaped}")`)
|
|
172
199
|
} else if (platform === "darwin") {
|
|
173
200
|
yield* Effect.promise<void>(() =>
|
|
174
201
|
new Promise((resolve, reject) => {
|
|
@@ -204,7 +231,7 @@ const keyPress = Effect.fn("Computer.keyPress")(function* (keys: string[]) {
|
|
|
204
231
|
home: "{HOME}", end: "{END}", pageup: "{PGUP}", pagedown: "{PGDN}",
|
|
205
232
|
}
|
|
206
233
|
const translated = keys.map((k) => mapping[k.toLowerCase()] ?? k.toUpperCase())
|
|
207
|
-
yield*
|
|
234
|
+
yield* powershellScript(`
|
|
208
235
|
Add-Type -AssemblyName System.Windows.Forms
|
|
209
236
|
[System.Windows.Forms.SendKeys]::SendWait("${translated.join("")}")
|
|
210
237
|
`)
|
|
@@ -237,9 +264,17 @@ Add-Type -AssemblyName System.Windows.Forms
|
|
|
237
264
|
|
|
238
265
|
const scrollMouse = Effect.fn("Computer.scrollMouse")(function* (clicks: number) {
|
|
239
266
|
if (platform === "win32") {
|
|
240
|
-
yield*
|
|
267
|
+
yield* powershellScript(`
|
|
241
268
|
Add-Type -AssemblyName System.Windows.Forms
|
|
242
|
-
|
|
269
|
+
Add-Type -TypeDefinition @'
|
|
270
|
+
using System;
|
|
271
|
+
using System.Runtime.InteropServices;
|
|
272
|
+
public class W32 {
|
|
273
|
+
[DllImport("user32.dll")] public static extern void mouse_event(uint f, uint x, uint y, uint d, int i);
|
|
274
|
+
public const uint W=0x0800;
|
|
275
|
+
}
|
|
276
|
+
'@
|
|
277
|
+
[W32]::mouse_event([W32]::W, 0, 0, ${Math.round(clicks) * 120}, 0); Write-Output OK
|
|
243
278
|
`)
|
|
244
279
|
} else if (platform === "darwin") {
|
|
245
280
|
yield* Effect.promise(() =>
|
|
@@ -267,7 +302,7 @@ Add-Type -AssemblyName System.Windows.Forms
|
|
|
267
302
|
|
|
268
303
|
const getScreenSize = Effect.fn("Computer.screenSize")(function* () {
|
|
269
304
|
if (platform === "win32") {
|
|
270
|
-
const raw = yield*
|
|
305
|
+
const raw = yield* powershellScript(`
|
|
271
306
|
Add-Type -AssemblyName System.Windows.Forms
|
|
272
307
|
$s = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
|
|
273
308
|
Write-Output "$($s.Width) $($s.Height)"
|
package/src/tool/computer.txt
CHANGED
|
@@ -2,17 +2,17 @@ Control the computer screen — capture screenshots, move mouse, click, type tex
|
|
|
2
2
|
|
|
3
3
|
Available actions:
|
|
4
4
|
- screenshot: Capture current screen (returns image, no side effects)
|
|
5
|
-
- move (x, y): Move mouse to coordinates
|
|
6
|
-
- click (x?, y?, button?): Click at position (default: left button)
|
|
7
|
-
- doubleclick (x?, y?): Double-click at position
|
|
8
|
-
- rightclick (x?, y?): Right-click at position
|
|
9
|
-
- type (text, delayMs?): Type text at current cursor position. Use delayMs (ms) to add a pause between each keystroke — useful for visible/animating typing
|
|
10
|
-
- keypress (keys): Press key combination
|
|
11
|
-
- scroll (clicks): Scroll up (positive) or down (negative)
|
|
5
|
+
- move (x, y): Move mouse to absolute pixel coordinates
|
|
6
|
+
- click (x?, y?, button?): Click at position (default: left button). Move first if x/y provided
|
|
7
|
+
- doubleclick (x?, y?): Double-click at position (moves first if x/y provided)
|
|
8
|
+
- rightclick (x?, y?): Right-click at position (moves first if x/y provided)
|
|
9
|
+
- type (text, delayMs?): Type text at current cursor position. Use delayMs (ms) to add a pause between each keystroke — useful for visible/animating typing or to let UI elements load
|
|
10
|
+
- keypress (keys): Press key combination, e.g. ["ctrl","l"] for address bar, ["ctrl","c"] copy, ["ctrl","v"] paste, ["enter"], ["tab"], ["alt","tab"] switch window, ["escape"], ["backspace"]
|
|
11
|
+
- scroll (clicks): Scroll up (positive number) or down (negative number)
|
|
12
12
|
- screensize: Get screen dimensions
|
|
13
13
|
|
|
14
|
-
Tip: To open a URL
|
|
14
|
+
Tip: To open a URL: keypress ["ctrl","l"] → type the URL (use delayMs if page is slow) → keypress ["enter"].
|
|
15
15
|
|
|
16
|
-
Coordinate system: (0,0) is top-left corner of primary screen.
|
|
16
|
+
Coordinate system: (0,0) is top-left corner of primary screen. Always get screen dimensions via screensize action first to know the available area.
|
|
17
17
|
|
|
18
|
-
Platform support: Windows (native), macOS (via screencapture + osascript), Linux (via ImageMagick + xdotool).
|
|
18
|
+
Platform support: Windows (native PowerShell + user32), macOS (via screencapture + osascript), Linux (via ImageMagick + xdotool).
|