You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Production readiness: complete docs rewrite, cross-OS fix, UX consolidation
Framework fixes:
- CRLF→LF fix for .sh stubs (was breaking bash on Linux/macOS with "ambiguous redirect")
- .gitattributes: enforce LF for .sh files
- Pipeline detection: commands with pipes/semicolons now B64-wrap even if first word is native LR verb
- Rate-Limiter: ActiveRequest retry message shows correct limit (12, not 5)
- Auth-Internal: session expiry message simplified to "Type 'connect' to re-authenticate"
- Invoke-LRCommand: default timeout 1800s (server decides, not client)
- Manage-Library: warns when .sh uploaded via Official API (doesn't sync to Linux/macOS)
- Removed lara_loader.sh (executor_b64.sh works on all platforms once properly uploaded)
UX consolidation:
- Unified auth menu (7 methods in one screen, mode derived from choice)
- connect command re-authenticates when session expired
- mode command informational only (no manual switching)
- session/session list for awareness
- Dynamic error handling with server response parsing
- Typo detection for shell commands
- 403 DisallowedOperation: specific device group guidance
Cross-OS findings:
- Linux/macOS PROVEN WORKING via both APIs (Internal: 6.2s avg, Official: 26-33s avg)
- .sh stubs MUST have Unix line endings (LF)
- Official API library upload doesn't sync .sh to Linux/macOS — upload via Internal API/portal first
- Once stubs are properly uploaded, Official API RunScript works fine on all 3 platforms
Documentation: complete rewrite of all 7 doc files from scratch:
- README.md, ARCHITECTURE.md, USER_GUIDE.md, COMMAND_REFERENCE.md
- ERROR_REFERENCE.md, PERFORMANCE_COMPARISON.md, tests/README.md
Test results (2026-04-03):
- Offline: 736/736 PASS (100%)
- Internal Pester: 251/251 PASS (100%)
- Stress Internal (blackhat): 23/26 PASS (88%)
- Stress Official (larabond): 25/26 PASS (96%)
- Stress CrossOS Internal (Win+Lin+Mac): 36/36 PASS (100%)
- Stress CrossOS Official (Win+Lin+Mac): 30/36 PASS (83%)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/COMMAND_REFERENCE.md
+44-56Lines changed: 44 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
# LaraC2 Shell -- Command Reference
2
2
3
-
Complete reference for all commands, native LR operations, aliases, and command
4
-
routing logic in the MDE Live Response Interactive Shell.
3
+
Complete reference for all commands, native LR operations, aliases, and command routing logic.
5
4
6
5
---
7
6
@@ -15,14 +14,12 @@ These commands are handled by the REPL dispatcher and do not execute on the remo
15
14
|`help commands`| List all 25 native LR commands with descriptions. |`help commands`|
16
15
|`help aliases`| Show all command aliases. |`help aliases`|
17
16
|`mode`| Display the current API mode (official or internal). |`mode`|
18
-
|`mode official`| Switch to Official API mode and re-authenticate. |`mode official`|
19
-
|`mode internal`| Switch to Internal API mode and re-authenticate. |`mode internal`|
20
17
|`status`| Show connection status: API mode, auth method/state, token expiry, session info, selected machine, OS, working directory. |`status`|
21
-
|`config`| Show Live Response configuration (unsigned scripts allowed, LR enabled). Works in both modes. |`config`|
22
-
|`disconnect`| Disconnect the current LR session (internal mode) and clear machine selection. |`disconnect`|
18
+
|`config`| Show Live Response configuration (unsigned scripts allowed, LR enabled). |`config`|
19
+
|`disconnect`| Disconnect the current LR session and clear machine selection. |`disconnect`|
23
20
|`machines`| List enrolled machines (cached 5 min) and prompt for selection. |`machines`|
24
21
|`machines refresh`| Force-reload the machine list from the API, then prompt for selection. |`machines refresh`|
25
-
|`connect [name\|id]`|Switch the active target machine. By name substring, ID prefix, or interactive picker if omitted. Auto-disconnects old session in internal mode. |`connect`, `connect blackhat`, `connect abc123`|
22
+
|`connect [name\|id]`|Re-authenticate if expired, then select a machine. By name substring, ID prefix, or interactive picker if omitted. Auto-disconnects old session in internal mode. |`connect`, `connect blackhat`, `connect abc123`|
26
23
|`library`| List all files in the MDE Library. |`library`|
27
24
|`library refresh`| Force-refresh the library file list from API. |`library refresh`|
28
25
|`library upload <path>`| Upload a local file to the MDE Library. |`library upload ./myscript.ps1`|
@@ -31,49 +28,46 @@ These commands are handled by the REPL dispatcher and do not execute on the remo
31
28
|`actions`| List InProgress/Pending actions for the current machine. |`actions`|
32
29
|`actions all`| List all recent actions across all statuses. |`actions all`|
33
30
|`actions cancel <id>`| Cancel an action by full or partial GUID (prefix match). |`actions cancel abc123`|
34
-
|`multi <command>`| Run a command on multiple machines simultaneously. Supports `-top N` and `-filter <pattern>` options. |`multi whoami`, `multi -top 3 hostname`|
31
+
|`multi <command>`| Run a command on multiple machines. Supports `-top N` and `-filter <pattern>`. |`multi whoami`, `multi -top 3 hostname`|
32
+
|`session`| Show current session info (machine, age, CWD). |`session`|
33
+
|`session list`| Show all cached sessions with age and idle time. |`session list`|
35
34
|`exit` / `quit` / `q`| Exit the shell. Disconnects the internal session first. |`exit`|
36
35
37
36
---
38
37
39
38
## Native LR Commands (25)
40
39
41
-
These commands are recognized by the shell as native Live Response operations. In official
42
-
mode, `getfile`, `putfile`, and `run` are sent as their native API types (`GetFile`,
43
-
`PutFile`, `RunScript`). All other native commands are executed via the B64 executor stub
44
-
in official mode. In internal mode, all native commands are sent using the session's cached
45
-
command definitions with proper `param_id`/`value` pairs.
40
+
These commands are recognized as native Live Response operations. In internal mode, all native commands are sent using the session's cached command definitions with proper `param_id`/`value` pairs. In official mode, `getfile`, `putfile`, and `run` use their native API types (`GetFile`, `PutFile`, `RunScript`); all other native commands go through the B64 executor.
46
41
47
-
| Command | Description | OS |API Mode | Example |
|`processes`| List running processes (PID, name, memory, CPU). | All | Both |`processes`|
50
-
|`connections`| List active network connections (local/remote address, port, protocol). | All | Both |`connections`|
45
+
|`connections`| List active network connections. | All | Both |`connections`|
51
46
|`getfile <path>`| Download a file from the remote machine. | All | Both |`getfile C:\Windows\System32\drivers\etc\hosts`|
52
-
|`putfile <name> [dest]`| Upload a file from the library to the remote working directory. Optional destination path. | All | Both |`putfile myscript.ps1`|
47
+
|`putfile <name>`| Upload a file from the library to the remote working directory. | All | Both |`putfile myscript.ps1`|
53
48
|`run <script> [args]`| Run a script from the MDE Library on the machine. | All | Both |`run myscript.ps1 -Param1 value1`|
54
49
|`cd <path>`| Change the working directory on the target. Internal mode updates the session directory. | All | Both |`cd C:\Windows\Temp`|
55
50
|`dir [path]`| List directory contents. | All | Both |`dir`, `dir C:\Windows\Temp`|
56
-
|`findfile <name>`| Search for a file by name across all drives/volumes. Timeout: 1800s (30 min). | All | Both |`findfile suspicious.exe`|
57
-
|`trace`| Capture a diagnostic ETW trace. Timeout: 600s (10 min). | All | Both |`trace -etl`|
58
-
|`analyze <path>`| Submit a file for deep analysis by MDE. Timeout: 600s (10 min). | All | Both |`analyze C:\Users\Public\suspicious.exe`|
51
+
|`findfile <name>`| Search for a file by name across all drives/volumes. Timeout: 1800s. | All | Both |`findfile suspicious.exe`|
52
+
|`trace`| Capture a diagnostic ETW trace. Timeout: 600s. | All | Both |`trace -etl`|
53
+
|`analyze <path>`| Submit a file for deep analysis by MDE. Timeout: 600s. | All | Both |`analyze C:\Users\Public\suspicious.exe`|
59
54
|`remediate <path>`| Quarantine/remediate a file on the remote machine. | All | Both |`remediate file C:\malware\suspicious.exe`|
60
55
|`undo <actionId>`| Undo a previous remediation action. | All | Both |`undo file C:\restored\file.exe`|
61
56
|`registry <key>`| Query registry keys and values (read-only). | Windows | Both |`registry HKLM\Software\Microsoft`|
62
-
|`scheduledtasks`| List scheduled tasks (Windows: task names/status; Linux: cron/systemd). | Windows | Both |`scheduledtasks`|
63
-
|`persistence`| Check common persistence mechanisms (autoruns, services, startup, cron). | All | Both |`persistence`|
57
+
|`scheduledtasks`| List scheduled tasks. | Windows | Both |`scheduledtasks`|
58
+
|`persistence`| Check common persistence mechanisms. | All | Both |`persistence`|
64
59
|`drivers`| List loaded drivers. | Windows | Both |`drivers`|
65
-
|`services`| List services (Windows: name, display name, status; Linux: running daemons). | All | Both |`services`|
60
+
|`services`| List services. | All | Both |`services`|
66
61
|`startupfolders`| List startup folder contents. | Windows | Both |`startupfolders`|
67
-
|`fileinfo <path>`| Get detailed file information (size, timestamps, attributes, hash, signature). 30 GB limit. | All | Both |`fileinfo C:\Windows\System32\cmd.exe`|
62
+
|`fileinfo <path>`| Get detailed file information (size, timestamps, hash, signature). 30 GB limit. | All | Both |`fileinfo C:\Windows\System32\cmd.exe`|
68
63
|`prefetch`| List prefetch data (recently executed programs). | Windows | Both |`prefetch`|
69
-
|`log`| View diagnostic logs on the target machine. | All | Both |`log`|
64
+
|`log`| View diagnostic logs. | All | Both |`log`|
70
65
|`jobs`| List background jobs in the current LR session. | All | Internal |`jobs`|
71
66
|`fg <jobId>`| Bring a background job to the foreground. | All | Internal |`fg 1`|
72
67
73
68
### Windows-Only Commands
74
69
75
-
The following commands are designed for Windows targets and will produce a warning
76
-
if sent to a Linux or macOS target:
70
+
The following commands produce a warning if sent to a Linux or macOS target:
77
71
78
72
-`registry`
79
73
-`scheduledtasks`
@@ -83,16 +77,14 @@ if sent to a Linux or macOS target:
83
77
84
78
### Per-Command Timeouts
85
79
86
-
Some commands have extended timeouts to account for their expected execution time:
87
-
88
80
| Command | Timeout | Reason |
89
81
|---------|---------|--------|
90
-
|`analyze`| 600s (10 min) | Deep analysis can be slow.|
91
-
|`findfile`| 1800s (30 min) | Full-disk search. MS API limit.|
92
-
|`trace`| 600s (10 min) | ETW trace collection.|
93
-
|`getfile`| 1800s (30 min) | Large file downloads. MS API limit.|
82
+
|`analyze`| 600s (10 min) | Deep analysis can be slow |
83
+
|`findfile`| 1800s (30 min) | Full-disk search (MS API limit)|
84
+
|`trace`| 600s (10 min) | ETW trace collection |
85
+
|`getfile`| 1800s (30 min) | Large file downloads (MS API limit)|
94
86
95
-
All other commands default to 300s (5 min), configurable via`commandTimeoutSeconds`in config.
87
+
All other commands use the default timeout: 1800s (server decides). The client-side`commandTimeoutSeconds` config value provides an additional ceiling.
96
88
97
89
---
98
90
@@ -106,25 +98,25 @@ All other commands default to 300s (5 min), configurable via `commandTimeoutSeco
106
98
|`process`|`processes`| List running processes |
107
99
|`netstat`|`connections`| List network connections |
108
100
109
-
Aliases are resolved before command execution. Both the alias and the full command
110
-
name work identically.
101
+
Aliases are resolved before command execution. Both the alias and the full command name work identically.
111
102
112
103
---
113
104
114
105
## Arbitrary Commands
115
106
116
-
Any input that is not a shell command, native LR command, or alias is treated as an
117
-
arbitrary command and executed on the remote machine via the B64 executor stub.
107
+
Any input that is not a shell command, native LR command, or alias is treated as an arbitrary command and executed on the remote machine via the B64 executor stub.
118
108
119
109
**How it works:**
120
110
121
111
1. The command string is Base64-encoded:
122
112
-**Windows targets**: UTF-16-LE encoding, then Base64
123
113
-**Linux/macOS targets**: UTF-8 encoding, then Base64
124
-
2. The encoded payload is passed as the`-B64` argument to the executor stub
114
+
2. The encoded payload is sent as the argument to the executor stub
125
115
3. The executor decodes and executes the command:
126
-
-**Windows**: `executor_b64.ps1` decodes and runs via PowerShell `Invoke-Expression`
127
-
-**Linux/macOS**: `executor_b64.sh` decodes and runs via `bash`
116
+
-**Windows**: `executor_b64.ps1` decodes and runs via PowerShell `[ScriptBlock]::Create()`
117
+
-**Linux/macOS**: `executor_b64.sh` decodes and pipes through `bash`
118
+
119
+
**Pipeline detection**: Commands containing pipes (`|`), semicolons (`;`), redirects (`>>`), or subexpressions (`$(`) are always B64-wrapped, even if the first word is a native LR verb. For example, `dir C:\ | Select-Object` goes through B64, not native `dir`.
128
120
129
121
**Examples:**
130
122
@@ -136,9 +128,7 @@ cat /etc/passwd
136
128
uname -a
137
129
```
138
130
139
-
**Size limits:** Commands are reliable up to ~30KB after encoding. Payloads over 35KB
140
-
may timeout, and 40KB+ are typically rejected by the API. For large scripts, use
141
-
`library upload` + `run <script>` instead.
131
+
**Size limits:** Commands are reliable up to ~30KB after encoding. Payloads over 35KB may timeout, and 40KB+ are typically rejected. For large scripts, use `library upload` + `run <script>` instead.
--> YES: Handled by the REPL dispatcher. No remote execution.
156
146
--> NO: Continue...
157
147
|
@@ -163,11 +153,13 @@ User Input
163
153
v
164
154
3. Native LR command or alias?
165
155
--> YES (alias): Resolve alias to canonical name, then...
166
-
--> YES (native): Route based on API mode:
167
-
- Official: getfile/putfile/run use native API types (GetFile/PutFile/RunScript).
168
-
All other native commands go through B64 executor.
169
-
- Internal: All native commands sent using session command definitions
170
-
with proper param_id/value pairs.
156
+
--> Has pipes/semicolons/redirects/subexpressions?
157
+
--> YES: Skip native routing, go to step 5 (B64 wrap)
158
+
--> NO: Route as native command:
159
+
- Official: getfile/putfile/run use native API types.
160
+
All others go through B64 executor.
161
+
- Internal: All native commands sent using session command
162
+
definitions with proper param_id/value pairs.
171
163
--> NO: Continue...
172
164
|
173
165
v
@@ -187,8 +179,7 @@ User Input
187
179
188
180
## Multi-Command Batching (Official Mode)
189
181
190
-
Official mode supports sending up to 5 `RunScript` commands in a single API call.
191
-
This is handled internally by `Invoke-LRCommandOfficial`:
182
+
Official mode supports sending up to 5 `RunScript` commands in a single API call. This is handled internally by `Invoke-LRCommandOfficial`:
192
183
193
184
- Commands are batched in groups of 5
194
185
- Each batch is sent as one `POST /machines/{id}/runliveresponse` with a `Commands` array
@@ -208,9 +199,7 @@ Run a single command across multiple machines simultaneously.
208
199
|`multi -top N <command>`| Run on first N active |`multi -top 3 hostname`|
209
200
|`multi -filter <pattern> <command>`| Run on matching machines |`multi -filter ws* processes`|
210
201
211
-
The `multi` command filters enrolled machines by `healthStatus -eq 'Active'`, then pipes
212
-
them to `Invoke-LRCommandMultiMachine`. Results are displayed as a table with MachineName,
213
-
Status, TimeMs, and a truncated Output preview.
202
+
The `multi` command filters enrolled machines by `healthStatus -eq 'Active'`, then runs the command on each. Results are displayed as a table with MachineName, Status, TimeMs, and a truncated Output preview.
214
203
215
204
**Internal API**: Uses persistent sessions per machine (2-5s per machine).
216
205
**Official API**: Creates separate runliveresponse actions (15-30s per machine).
0 commit comments