diff --git a/implants/lib/eldritch/eldritch-wasm/src/headless.rs b/implants/lib/eldritch/eldritch-wasm/src/headless.rs index 87792a4b0..29d5c4a38 100644 --- a/implants/lib/eldritch/eldritch-wasm/src/headless.rs +++ b/implants/lib/eldritch/eldritch-wasm/src/headless.rs @@ -282,8 +282,8 @@ mod tests { #[test] fn test_headless_repl_macro() { let mut repl = HeadlessRepl::new(); - let res = repl.input("!ls"); - assert!(res.contains("\"status\": \"complete\"")); + repl.input("!ls"); + let res = repl.input(""); assert!(res.contains("sys.shell")); assert!(res.contains("ls")); } @@ -303,7 +303,6 @@ mod tests { let res = repl.input(""); assert!(res.contains("\"status\": \"complete\"")); // Payload should contain sys.shell with indentation - assert!(res.contains(" import sys")); assert!(res.contains("sys.shell(\\\"ls\\\")")); } } diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index c365ef3f7..000000000 --- a/package-lock.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "app", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "dependencies": { - "playwright": "^1.58.2" - } - }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/playwright": { - "version": "1.58.2", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.58.2.tgz", - "integrity": "sha512-vA30H8Nvkq/cPBnNw4Q8TWz1EJyqgpuinBcHET0YVJVFldr8JDNiU9LaWAE1KqSkRYazuaBhTpB5ZzShOezQ6A==", - "license": "Apache-2.0", - "dependencies": { - "playwright-core": "1.58.2" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "fsevents": "2.3.2" - } - }, - "node_modules/playwright-core": { - "version": "1.58.2", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.58.2.tgz", - "integrity": "sha512-yZkEtftgwS8CsfYo7nm0KE8jsvm6i/PTgVtB8DL726wNf6H2IMsDuxCpJj59KDaxCtSnrWan2AeDqM7JBaultg==", - "license": "Apache-2.0", - "bin": { - "playwright-core": "cli.js" - }, - "engines": { - "node": ">=18" - } - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 41c60dc4b..000000000 --- a/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "playwright": "^1.58.2" - } -} diff --git a/verification.png b/verification.png deleted file mode 100644 index a43f4bfd7..000000000 Binary files a/verification.png and /dev/null differ diff --git a/verification_wrap.png b/verification_wrap.png deleted file mode 100644 index 2b9337cbf..000000000 Binary files a/verification_wrap.png and /dev/null differ diff --git a/verification_wrap_2.png b/verification_wrap_2.png deleted file mode 100644 index 2b9337cbf..000000000 Binary files a/verification_wrap_2.png and /dev/null differ diff --git a/verify_shell.py b/verify_shell.py deleted file mode 100644 index ff6864c2f..000000000 --- a/verify_shell.py +++ /dev/null @@ -1,94 +0,0 @@ -import time -import json -from playwright.sync_api import sync_playwright - -def verify_shell(page): - # Intercept GraphQL queries to mock data - def handle_graphql(route): - try: - # Handle potential JSON parse errors or empty body - post_data = route.request.post_data_json - except: - route.continue_() - return - - operation_name = post_data.get('operationName') - - if operation_name == 'GetMe': - print("Intercepted GetMe") - route.fulfill(json={ - "data": { - "me": { - "id": "1", - "username": "admin", - "isActivated": True # Add isActivated based on memory - } - } - }) - elif operation_name == 'GetShell': - print("Intercepted GetShell") - variables = post_data.get('variables', {}) - shell_id = variables.get('id', '1') - route.fulfill(json={ - "data": { - "node": { - "__typename": "Shell", - "id": shell_id, - "host": {"id": "1", "hostname": "test-host"}, - "closedAt": None, - } - } - }) - elif operation_name == 'GetBeaconStatus': # Mock Beacon Status if needed - print("Intercepted GetBeaconStatus") - route.fulfill(json={ - "data": { - "node": { - "lastSeenAt": "2024-01-01T00:00:00Z" # Old enough/recent enough? Logic might depend. - } - } - }) - else: - route.continue_() - - # Enable request interception - page.route("**/graphql", handle_graphql) - - # Go to the shell page - # Using a high ID to avoid conflicts if needed, but 1 is fine with mocks - page.goto("http://localhost:3000/shellv2/1") - - # Wait for the terminal to appear. - # If the access gate is passed, we should see the shell UI. - try: - page.wait_for_selector(".xterm-rows", state="visible", timeout=10000) - except Exception as e: - print("Timeout waiting for .xterm-rows. Dumping page content...") - # print(page.content()) - raise e - - # Simulate typing 'echo hello' quickly - # This will trigger the fast-path logic - page.keyboard.type("echo hello") - - # Wait a bit for the debounced redraw to potentially happen - time.sleep(1) - - # Take a screenshot to verify the terminal content - page.screenshot(path="verification.png") - print("Screenshot saved to verification.png") - -with sync_playwright() as p: - browser = p.chromium.launch() - page = browser.new_page() - try: - verify_shell(page) - except Exception as e: - print(f"Error: {e}") - # Take a screenshot even on error if possible - try: - page.screenshot(path="error_retry.png") - except: - pass - finally: - browser.close() diff --git a/verify_shell_wrap.py b/verify_shell_wrap.py deleted file mode 100644 index e33bba94d..000000000 --- a/verify_shell_wrap.py +++ /dev/null @@ -1,88 +0,0 @@ -import time -import json -from playwright.sync_api import sync_playwright - -def verify_shell_wrapping(page): - # Intercept GraphQL queries to mock data - def handle_graphql(route): - try: - # Handle potential JSON parse errors or empty body - post_data = route.request.post_data_json - except: - route.continue_() - return - - operation_name = post_data.get('operationName') - - if operation_name == 'GetMe': - route.fulfill(json={ - "data": { - "me": { - "id": "1", - "username": "admin", - "isActivated": True - } - } - }) - elif operation_name == 'GetShell': - variables = post_data.get('variables', {}) - shell_id = variables.get('id', '1') - route.fulfill(json={ - "data": { - "node": { - "__typename": "Shell", - "id": shell_id, - "host": {"id": "1", "hostname": "test-host"}, - "closedAt": None, - } - } - }) - else: - route.continue_() - - # Enable request interception - page.route("**/graphql", handle_graphql) - - # Go to the shell page - page.goto("http://localhost:3000/shellv2/1") - - # Wait for the terminal to appear. - page.wait_for_selector(".xterm-rows", state="visible", timeout=10000) - - # Generate a long string that will wrap - # Assuming standard terminal width is around 80-100 chars, - # but browser window size matters. - # We'll type enough characters to definitely wrap 2-3 times. - long_string = "a" * 300 - - # Type the long string - # We type it in chunks to allow redraws to happen - for i in range(0, len(long_string), 10): - chunk = long_string[i:i+10] - page.keyboard.type(chunk) - # Small delay to mimic fast typing but allow some processing - time.sleep(0.05) - - # Wait a bit for the final redraw - time.sleep(2) - - # Take a screenshot to verify the terminal content - page.screenshot(path="verification_wrap.png") - print("Screenshot saved to verification_wrap.png") - -with sync_playwright() as p: - browser = p.chromium.launch() - page = browser.new_page() - # Set a specific viewport size to control terminal width somewhat - page.set_viewport_size({"width": 1024, "height": 768}) - - try: - verify_shell_wrapping(page) - except Exception as e: - print(f"Error: {e}") - try: - page.screenshot(path="error_wrap.png") - except: - pass - finally: - browser.close() diff --git a/verify_shell_wrap_2.py b/verify_shell_wrap_2.py deleted file mode 100644 index cbf241887..000000000 --- a/verify_shell_wrap_2.py +++ /dev/null @@ -1,88 +0,0 @@ -import time -import json -from playwright.sync_api import sync_playwright - -def verify_shell_wrapping(page): - # Intercept GraphQL queries to mock data - def handle_graphql(route): - try: - # Handle potential JSON parse errors or empty body - post_data = route.request.post_data_json - except: - route.continue_() - return - - operation_name = post_data.get('operationName') - - if operation_name == 'GetMe': - route.fulfill(json={ - "data": { - "me": { - "id": "1", - "username": "admin", - "isActivated": True - } - } - }) - elif operation_name == 'GetShell': - variables = post_data.get('variables', {}) - shell_id = variables.get('id', '1') - route.fulfill(json={ - "data": { - "node": { - "__typename": "Shell", - "id": shell_id, - "host": {"id": "1", "hostname": "test-host"}, - "closedAt": None, - } - } - }) - else: - route.continue_() - - # Enable request interception - page.route("**/graphql", handle_graphql) - - # Go to the shell page - page.goto("http://localhost:3000/shellv2/1") - - # Wait for the terminal to appear. - page.wait_for_selector(".xterm-rows", state="visible", timeout=10000) - - # Generate a long string that will wrap - # Assuming standard terminal width is around 80-100 chars, - # but browser window size matters. - # We'll type enough characters to definitely wrap 2-3 times. - long_string = "a" * 300 - - # Type the long string - # We type it in chunks to allow redraws to happen - for i in range(0, len(long_string), 10): - chunk = long_string[i:i+10] - page.keyboard.type(chunk) - # Small delay to mimic fast typing but allow some processing - time.sleep(0.05) - - # Wait a bit for the final redraw - time.sleep(2) - - # Take a screenshot to verify the terminal content - page.screenshot(path="verification_wrap_2.png") - print("Screenshot saved to verification_wrap_2.png") - -with sync_playwright() as p: - browser = p.chromium.launch() - page = browser.new_page() - # Set a specific viewport size to control terminal width somewhat - page.set_viewport_size({"width": 1024, "height": 768}) - - try: - verify_shell_wrapping(page) - except Exception as e: - print(f"Error: {e}") - try: - page.screenshot(path="error_wrap.png") - except: - pass - finally: - browser.close()