Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
larac2shell — Cross-platform interactive shell for Microsoft Defender for Endpoint Live Response | Kitploit
Tools/GitHubGitHub/akefallonitis/larac2shell
Lateral MovementScripting & AutomationPost-ExploitationPenetration TestingCommand and ControlUtilities & FrameworksAuthenticationIncident ResponseRemote Access Tool
GitHubakefallonitis/larac2shell

larac2shell

Cross-platform interactive shell for Microsoft Defender for Endpoint Live Response

1513 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share
View Repository

LaraC2 Shell -- MDE Live Response Interactive Shell

CI License: MIT PowerShell 7+ Platforms

Cross-platform interactive shell for Microsoft Defender for Endpoint Live Response.

FeatureDetail
PlatformPowerShell Core 7.0+ (Windows, Linux, macOS)
API modesInternal (portal, near-realtime) and Official (public, stateless)
ExecutionArbitrary commands + 25 native LR commands
Auth7 authentication methods, unified menu, auto-refresh
LicenseMIT

LaraC2 Shell connects to MDE Live Response through two independent API paths -- the internal portal API (persistent sessions, ~2-5s latency) and the official public API (per-command, ~20-60s latency). It auto-uploads executor stubs, handles rate limiting transparently, and provides a full REPL with machine management, library management, and a built-in help system.

Documentation


Features

  • Two API modes: Internal (portal, ~2-5s/cmd, near-real-time) + Official (public, ~20-60s/cmd, CI/CD ready)
  • 7 auth methods in a unified menu: client creds, device code, credentials+TOTP, passkey/HSM, ESTS cookie, TAP, direct sccauth -- mode is derived from the auth choice
  • 25 native LR commands + arbitrary command execution via auto-uploaded B64 executor stubs
  • Cross-OS targeting: Windows, Linux, macOS endpoints (auto-selects executor + encoding)
  • Transparent rate limiting: 429 backoff, ActiveRequest smart conflict resolution (12 retries, cancel external / wait own)
  • Session lifecycle: auto-connect, auto-reconnect on 30-min inactivity, stale session pruning, cross-machine switching
  • Auth lifecycle: OAuth2 auto-refresh, XSRF auto-refresh (4-min TTL), silent re-auth for TOTP/passkey; connect command re-authenticates when session expires
  • Session reuse: transparent auto-connect, auto-reconnect, and cross-machine switching with no user intervention
  • Multi-machine execution: multi command with name pattern filtering and top-N limiting
  • Multi-command batching: up to 5 commands per Official API call, auto-split for larger sets
  • Library management: list, upload, delete, download, auto-upload executor stubs, 409 conflict override
  • Action management: list, cancel (partial ID match), status detail
  • Interactive UX: tab completion, command aliases (ls/ps/netstat), working directory tracking, help system
  • Error guidance: context-aware messages (400->syntax, 401->reauth, 403->scopes, 429->rate limit)
  • No secrets on CLI: credentials from config file or interactive prompt, never in command history

Quick Start

Prerequisites

  • PowerShell Core 7.0+ (Windows, Linux, or macOS)
  • Either a portal account with Live Response access (internal mode) or an MDE app registration with Machine.LiveResponse + Library.Manage permissions (official mode)

Launch

root@kitploit:~
git clone https://github.com/akefallonitis/larac2shell.git
cd larac2shell
pwsh -File shell/Invoke-MDEShell.ps1

That's it. The shell presents a unified 7-method auth menu on first launch — pick one, authenticate, select a machine, and you're in a REPL. No config file, no flags, nothing to set up.

root@kitploit:~
  Select API mode:

    Internal API  (security.microsoft.com — near real-time, ~2-5s/cmd)
    1  Credentials + MFA        username + password, TOTP/push/SMS [auto-refresh]
    2  Software passkey          FIDO2/WebAuthn JSON key file [auto-refresh]
    3  ESTS cookie               ESTSAUTHPERSISTENT from browser (~24hr)
    4  Temporary Access Pass     one-time admin-issued code
    5  Direct sccauth + XSRF     cookies from browser DevTools (~1hr)

    Official API  (api.securitycenter.microsoft.com — CI/CD ready, ~20-60s/cmd)
    6  Device code               browser login (interactive)
    7  Client credentials        app registration with client secret

  Auth method (1-7):

Choices 1-5 set internal mode, 6-7 set official. You can switch modes later without restarting — see Switching modes inline below.

Switching modes inline

root@kitploit:~
[INT myhost C:\]> mode
  Current mode: Internal API
  Switch with: 'mode internal' or 'mode official'.

[INT myhost C:\]> mode official
  [Mode] Switching from Internal API to official...
  (auth menu for official mode opens)
  [Mode] Now in official mode.
  Run 'machines' to list targets or 'connect <name|id>' to select one.

mode <target> disconnects any current LR session, clears the old auth state, and re-runs the auth flow for the target mode. When it returns you're authenticated in the new mode with no machine selected — run machines to list, or connect <name|id> to jump straight to a target. No restart required.

CLI shortcuts (optional)

For scripting or when you want to skip the unified menu:

root@kitploit:~
# Pre-select the mode (narrows the auth menu to 1-5 or 6-7)
pwsh -File shell/Invoke-MDEShell.ps1 -Mode internal
pwsh -File shell/Invoke-MDEShell.ps1 -Mode official

# Pre-select a machine (skips the picker)
pwsh -File shell/Invoke-MDEShell.ps1 -Machine myhost

# Software passkey path (internal mode)
pwsh -File shell/Invoke-MDEShell.ps1 -PasskeyPath ./keys/passkey.json

# Non-interactive single command (exits with remote command's exit code)
pwsh -File shell/Invoke-MDEShell.ps1 -Machine myhost -Command 'whoami'

Config file (optional)

Only used for one scenario: official mode with a client secret, non-interactively. Every other auth method prompts you interactively and stores nothing on disk. If you don't need unattended client-credentials auth, you can skip this section entirely.

root@kitploit:~
Copy-Item shell/config/shell-config.example.json shell/config/shell-config.json
# Edit the file: set official.tenantId, official.clientId, official.clientSecret
pwsh -File shell/Invoke-MDEShell.ps1 -Config shell/config/shell-config.json

Config schema (all fields optional except official.tenantId + official.clientId when using client credentials):

Security: Restrict filesystem permissions on any config file containing clientSecret. The clientSecret is never accepted on the command line — config file only. All internal-mode credentials (username, password, TOTP secret, cookies) are prompted interactively and never persisted to disk.


Authentication Methods

The shell presents a unified 7-method auth menu on startup. Mode (internal/official) is derived from the choice.

The connect command re-authenticates when the session expires, using the same method that was originally selected. Methods without auto-refresh prompt interactively again.

In-memory credential handling: for method 1, the supplied password and TOTP secret are retained in-memory (as plain strings, inside $script:Int_ReauthParams) for the lifetime of the shell process so silent re-auth can run unattended. The string objects live in the PowerShell runspace; they are not serialized to disk or passed on the command line. If that exposure is not acceptable for your threat model, use method 2 (passkey/HSM) or method 7 (client credentials) instead.


Shell Commands

Shell Control

Machine Management

CommandDescription
machines [refresh]List machines and select one (refresh = force reload)
connect [name|id]Connect to a machine by name substring or ID prefix

Native Live Response Commands (25 total)

Command Aliases

Arbitrary Commands

Any input that does not match a built-in command is treated as an arbitrary command and executed on the remote machine via the B64 executor stub. Examples: whoami, ipconfig, cat /etc/hostname.

  • Windows targets: command is UTF-16-LE Base64-encoded and executed via executor_b64.ps1 (PowerShell ScriptBlock)
  • Linux/macOS targets: command is UTF-8 Base64-encoded and executed via executor_b64.sh (bash)

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.

Library Management

Action Management

CommandDescription
actionsList pending/in-progress actions for current machine
actions allList all recent actions across all machines
actions cancel <id>Cancel an action by ID (partial match supported)

Architecture

Internal vs Official API

LaraC2 Shell exposes two independent API paths to the same MDE Live Response backend. The Internal API mirrors the portal's WebSocket-like session model and delivers near-real-time responses. The Official API uses Microsoft's documented REST endpoints and is suited for automation.

What LaraC2 adds beyond the raw API

Key constraint

Official API and Internal API share a per-machine action queue. They cannot run simultaneously on the same machine.

Rate Limiting (Transparent)


Near-Real-Time Shell Feasibility

Measured latencies on a production MDE tenant, across Windows, Linux, and macOS targets:

Internal API: near-real-time capable. With session reuse, native commands respond in 2-5s. This is as close to real-time as MDE allows. The bottleneck is the SenseIR agent on the target, not the framework.

Official API: automation-grade. Minimum ~15s per command due to stateless architecture (submit, poll, fetch). Well-suited for scripted automation and CI/CD, not interactive use.


Cross-OS Support

Linux and macOS endpoints are fully supported via both API modes.

Target OSInternal API AvgOfficial API Avg
Windows~7s~30s
Linux~6s~26-33s
macOS~6s~26-33s

What to watch for:

  1. .sh stubs must have Unix line endings (LF, not CRLF) or bash fails with "ambiguous redirect".
  2. Official API library upload does not sync .sh files to Linux/macOS endpoints. Upload via Internal API (portal) or the Defender portal UI first. Once uploaded, Official API RunScript works fine.
  3. executor_b64.sh works on Linux and macOS once properly uploaded.

Testing

The test suite includes 712 offline unit tests, 301 Official-API integration tests, 251 Internal-API integration tests, plus a configurable stress-test driver.

Prerequisites

root@kitploit:~
Install-Module -Name Pester -MinimumVersion 5.0.0 -Force -Scope CurrentUser

Offline Tests (no tenant required)

Unit tests covering module loading, B64 encoding, command building, alias resolution, tokenizer, rate limiter, auth crypto, session management, error paths, and all auth flows via Pester Mock.

root@kitploit:~
Invoke-Pester ./tests/shell/LaraC2Shell.Offline.Tests.ps1 -Output Detailed

Internal API Tests (requires portal cookies)

Integration tests covering sccauth auth, session lifecycle, all native commands, B64 execution, cross-OS targeting.

root@kitploit:~
$env:LARAC2_SCCAUTH = 'your-sccauth-cookie'
$env:LARAC2_XSRF = 'your-xsrf-token'
Invoke-Pester ./tests/shell/LaraC2Shell.Internal.Tests.ps1 -Output Detailed

Stress Tests (throughput and reliability)

root@kitploit:~
# Single-mode stress
pwsh -File tests/shell/LaraC2Shell.Stress.Tests.ps1 -Config config.json -Mode official -Rounds 5

# Cross-OS stress (Windows + Linux + macOS)
pwsh -File tests/shell/LaraC2Shell.Stress.Tests.ps1 -Config config.json -Mode both -Scenario crossos

CI/CD (GitHub Actions)


Troubleshooting


Requirements

RequirementDetail
PowerShell Core7.0 or later (pwsh)
MDE App RegistrationRequired for official mode (Machine.LiveResponse + permissions)

All authentication is self-contained -- no external modules required. Internal mode auth flows are based on XDRInternals by Fabian Bader & Nathan McNulty.


File Layout

root@kitploit:~
shell/
  Invoke-MDEShell.ps1           Main shell entry point (REPL, dispatch, help)
  modules/
    Auth-Official.ps1           OAuth2 client credentials + device code
    Auth-Internal.ps1           Self-contained ESTS/passkey/TOTP/TAP authentication
    Auth-Crypto.ps1             Crypto helpers: TOTP, WebAuthn, passkey signing, Key Vault
    Rate-Limiter.ps1            429/backoff/ActiveRequest handling
    Invoke-LRCommand.ps1        Command execution (both modes, B64 stubs, multi-machine)
    Get-Machines.ps1            Machine list + picker
    Manage-Library.ps1          Library file management + auto-init stubs
    Manage-Actions.ps1          Action list/cancel
  config/
    shell-config.example.json   Config template (copy and fill in)

stubs/
  executor_b64.ps1              Windows PS B64 executor (auto-uploaded)
  executor_b64.sh               Linux/macOS bash B64 executor (auto-uploaded)

tests/
  shell/
    LaraC2Shell.Offline.Tests.ps1    Unit tests (no tenant needed)
    LaraC2Shell.Online.Tests.ps1     Integration tests (Official API)
    LaraC2Shell.Internal.Tests.ps1   Integration tests (Internal API)
    LaraC2Shell.Stress.Tests.ps1     Stress/throughput driver (configurable scenarios)

docs/
  USER_GUIDE.md                 Step-by-step usage guide
  COMMAND_REFERENCE.md          All commands, routing, batching
  ERROR_REFERENCE.md            Error messages and fixes
  PERFORMANCE_COMPARISON.md     Stress test data and API comparison

Authorization

See LICENSE for terms.


References & Credits

Download Tool
DocPurpose
User GuideStep-by-step setup, auth, and operation
Command ReferenceAll commands, routing, batching, tab completion
Error ReferenceHTTP codes, shell errors, auth errors, fixes
PerformanceInternal vs Official latency, throughput, limits
ArchitectureInternals, auth chains, endpoints, file layout
ContributingHow to contribute, test, submit PRs
Security PolicyHow to report a vulnerability privately
ReferencesPrior art, related research, credits
DisclaimerAuthorization, credits
SectionFieldDescription
officialtenantIdAzure AD tenant ID
officialclientIdApp registration client ID
officialclientSecretClient secret (omit and set useDeviceCode: true for device code)
officialuseDeviceCodetrue to use device code flow instead of client credentials
defaultsdefaultMachinePre-select machine on startup (name substring or ID prefix)
defaultscommandTimeoutSecondsClient-side timeout ceiling. 0 = server decides (up to 1800s).
defaultspollIntervalOfficialOfficial API poll interval in seconds (default 2)
defaultspollIntervalInternalInternal API poll interval in seconds (default 1)
#ModeMethodHowAuto-Refresh
1InternalCredentials + TOTPInteractive promptYes (silent) -- only when a TOTP secret was supplied. With push/SMS MFA the session cannot auto-refresh.
2InternalSoftware passkey-PasskeyPath param or promptYes (silent)
3InternalESTS cookieInteractive promptNo (~24hr)
4InternalTemporary Access PassInteractive promptNo (one-time)
5InternalDirect sccauth + XSRFInteractive promptNo (~1hr) -- XSRF auto-refresh does not apply; the shell does not auto-refresh cookies supplied directly.
6OfficialDevice codeBrowser loginNo (~1hr)
7OfficialClient credentialsConfig fileYes (silent)
CommandDescription
help [command]Show help (optionally for a specific command)
help commandsList all native LR commands with descriptions
statusShow connection status, auth state, machine info
configShow Live Response configuration
connect [name|id]Re-authenticate (if expired) and select a machine
disconnectDisconnect current LR session and clear machine
multi [options] <cmd>Run command on multiple machines (-top N, -filter pattern)
session [list]Show current session info or all cached sessions
modeShow the current API mode
mode internal|officialSwitch API mode inline — disconnects the current session, tears down old auth state, and re-runs the auth menu for the target mode. Pick up with machines or connect afterwards
exit / quit / qExit the shell
CommandDescription
run <script> [args]Run a script from the MDE Library
getfile <path>Download a file from the remote machine
putfile <name>Upload a library file to the remote working directory
processesList running processes
connectionsList active network connections
cd <path>Change working directory (internal mode)
dir [path]List directory contents
findfile <name>Search for a file by name across all drives
traceShow diagnostic trace information
analyze <path>Submit a file for deep analysis
remediate <path>Quarantine/remediate a file
undo <actionId>Undo a previous remediation action
registry <key>Query registry keys/values (Windows only)
scheduledtasksList scheduled tasks
persistenceCheck common persistence locations
driversList loaded drivers (Windows only)
servicesList services
startupfoldersList startup folder contents (Windows only)
fileinfo <path>Get detailed file information
prefetchList prefetch data (Windows only)
logView diagnostic logs
jobsList background jobs (internal mode)
fg <jobId>Foreground a background job (internal mode)
libraryManage library files (list, upload, download, delete)
statusShow session status and diagnostics
AliasResolves To
lsdir
psprocesses
downloadgetfile
processprocesses
netstatconnections
CommandDescription
libraryList all files in the MDE Library
library refreshForce-refresh the library list from API
library upload <path>Upload a local file to the library
library delete <name>Delete a file from the library by name
library download <name>Download a file's content from the library (Internal API: direct; Official API: via getfile from the endpoint's library cache once a machine is selected -- sync may take up to 10 min)
Internal APIOfficial API
Base URLsecurity.microsoft.com/apiproxy/mtp/liveResponseApi/api.securitycenter.microsoft.com/api/
SessionPersistent (30-min keepalive, auto-reconnect)Per-command (stateless)
Poll interval~1s (near-realtime)2s
Multi-commandSequential within shared sessionBatched (up to 5 per API call)
AuthSelf-contained (ESTS/passkey/TOTP -> sccauth)OAuth2 client credentials or device code
Default timeout1800s (server decides, not client)1800s (server decides, not client)
StepRaw Official APILaraC2 Shell
Stub uploadManual: build multipart, POST, handle conflictsAuto on connect, 409 override
B64 encodeManual: choose UTF-16LE/UTF-8 per OSAuto-detect OS, auto-encode
Build RunScriptManual: JSON with ScriptName + Args paramsType command directly
Poll + fetchManual: loop + download link + parse JSONTransparent: returns clean output
Error handlingManual: check 400/401/403/409/429/503Automatic: retry, backoff, guidance
Multi-commandManual: build Commands[] arrayAutomatic batching up to 5
LimitValueHandling
LR commands per minute10429 response with Retry-After header
Library uploads per minute100Sliding window queue
Library uploads per hour1500Hourly counter
HTTP 429 Too Many Requests--Sleep for Retry-After header (default 35s)
ActiveRequestAlreadyExists--Cancel conflicting action + fixed backoff (10s, then 15s up to 12 retries)
Bearer token expiry (official)~1 hourAuto-refresh before expiry
sccauth expiry (internal)~1 hourSilent re-auth if credentials stored
LR session inactivity30 minutesAuto-reconnect
XSRF rotation4 minutesTransparent refresh
OperationInternal APIOfficial API
whoami (B64)4-9s20-46s
dir (native)2-4s14-25s
processes (native)3-15s20-175s
connections (native)2-4s~15s
services (native)2-5s~15s
hostname (B64)4-7s11-16s
Session connect (first cmd)9-15sN/A (stateless)
Cross-machine switch7-10s15-30s
JobTriggerPlatformsRequirements
PSScriptAnalyzer LintEvery push/PRUbuntuNone
Offline TestsEvery push/PRUbuntu + Windows + macOSNone
Online Tests (Official)ConditionalUbuntuLARAC2_ONLINE_TESTS variable + LARAC2_CONFIG secret
Stress TestsManual dispatchUbuntuLARAC2_CONFIG secret
ErrorCauseResolution
ActiveRequestAlreadyExistsAnother LR command is running on the targetAuto-handled (official mode): cancel conflicting action + fixed 10s/15s backoff up to 12 retries. Internal mode: wait-only. No user action needed.
HTTP 429Rate limit exceeded (10 cmds/min)Auto-handled: sleeps for Retry-After period and retries.
"script not found" on Linux/macOS.sh stub not synced to endpointUpload via Internal API or Defender portal UI. Official API uploads do not sync .sh files.
"ambiguous redirect" on Linux/macOS.sh stub has CRLF line endingsRe-save with LF line endings and re-upload.
HTTP 400 on large commandB64 payload exceeds ~30 KBUse library upload + run <script> instead.
HTTP 401Token/session expiredShell auto-refreshes for client credentials, TOTP, and passkey. For other methods, type connect.
HTTP 403Insufficient permissionsOfficial: check Machine.LiveResponse + Library.Manage scopes. Internal: check Security Operator role.
HTTP 404Machine not foundRun machines refresh to reload.
Library.Manage
Operating SystemWindows, Linux, or macOS (shell runs on any; targets can be any MDE-enrolled OS)
ResourceAuthorDescription
XDRInternalsFabian Bader, Nathan McNultyInternal portal authentication flows (ESTS, passkey, TOTP, TAP)
Running Arbitrary CommandsJon GlassLive Response command execution techniques
Troubleshoot Live ResponseJeffrey AppelLR architecture, WpnService, session diagnostics
MDE Internals 0x05Olaf Hartong (FalconForce)MDE telemetry for sensitive actions, detection engineering
DefenderHarvesterOlaf HartongMDE telemetry export concepts
Run Live Response APIMicrosoftOfficial API documentation
Library Methods APIMicrosoftLibrary management API documentation