66 < title > Malware download page</ title >
77 < script >
88 // eslint-disable-next-line no-unused-vars
9- function run ( ) {
10- const url = "/security/badware/phishing-redirect/download" ;
9+ function getUrl ( ) {
10+ const delayedCheckbox = document . getElementById ( 'delayedCheckbox' ) ;
11+ return delayedCheckbox . checked ? "/security/badware/phishing-redirect/download?delay=5000" : "/security/badware/phishing-redirect/download" ;
12+ }
13+
14+ function linkHrefDownload ( ) {
15+ const url = getUrl ( ) ;
1116 const link = document . createElement ( 'a' ) ;
1217 link . href = url ;
1318 document . body . appendChild ( link ) ;
1419 link . click ( ) ;
1520 document . body . removeChild ( link ) ;
1621 }
22+
23+ async function blobDownload ( ) {
24+ const url = getUrl ( ) ;
25+ const response = await fetch ( url ) ;
26+ const blob = await response . blob ( ) ;
27+ const link = document . createElement ( 'a' ) ;
28+ link . href = window . URL . createObjectURL ( blob ) ;
29+ link . download = 'example.exe' ;
30+ document . body . appendChild ( link ) ;
31+ link . click ( ) ;
32+ document . body . removeChild ( link ) ;
33+ window . URL . revokeObjectURL ( link . href ) ;
34+ }
35+
36+ function xhrDownload ( ) {
37+ const url = getUrl ( ) ;
38+ const xhr = new XMLHttpRequest ( ) ;
39+ xhr . open ( 'GET' , url , true ) ;
40+ xhr . responseType = 'blob' ;
41+ xhr . onload = function ( ) {
42+ const blob = new Blob ( [ xhr . response ] , { type : 'application/octet-stream' } ) ;
43+ const link = document . createElement ( 'a' ) ;
44+ link . href = window . URL . createObjectURL ( blob ) ;
45+ link . download = 'example.exe' ;
46+ document . body . appendChild ( link ) ;
47+ link . click ( ) ;
48+ document . body . removeChild ( link ) ;
49+ window . URL . revokeObjectURL ( link . href ) ;
50+ } ;
51+ xhr . send ( ) ;
52+ }
53+
54+ function iframeDownload ( ) {
55+ const url = getUrl ( ) ;
56+ const iframe = document . createElement ( 'iframe' ) ;
57+ iframe . style . display = 'none' ;
58+ iframe . src = url ;
59+ document . body . appendChild ( iframe ) ;
60+ setTimeout ( ( ) => {
61+ document . body . removeChild ( iframe ) ;
62+ } , 1000 ) ; // Clean up after a second
63+ }
64+
65+ function windowLocationDownload ( ) {
66+ const url = getUrl ( ) ;
67+ window . location . href = url ;
68+ }
69+
70+ async function fetchStreamDownload ( ) {
71+ const url = getUrl ( ) ;
72+ const response = await fetch ( url ) ;
73+ const reader = response . body . getReader ( ) ;
74+ const contentLength = + response . headers . get ( 'Content-Length' ) ;
75+ let receivedLength = 0 ; // Received bytes
76+ const chunks = [ ] ; // Array of received binary chunks (comprises the body)
77+
78+ while ( true ) {
79+ const { done, value } = await reader . read ( ) ;
80+ if ( done ) break ;
81+ chunks . push ( value ) ;
82+ receivedLength += value . length ;
83+ console . log ( `Received ${ receivedLength } of ${ contentLength } ` ) ;
84+ }
85+
86+ const blob = new Blob ( chunks ) ;
87+ const link = document . createElement ( 'a' ) ;
88+ link . href = window . URL . createObjectURL ( blob ) ;
89+ link . download = 'example.exe' ;
90+ document . body . appendChild ( link ) ;
91+ link . click ( ) ;
92+ document . body . removeChild ( link ) ;
93+ window . URL . revokeObjectURL ( link . href ) ;
94+ }
1795 </ script >
1896</ head >
1997
@@ -25,8 +103,29 @@ <h1>Malware download page</h1>
25103 < p > This is an example malware page that DuckDuckGo clients intend to block. If you arrive here by mistake; there's
26104 nothing to worry about, we just use this page to test if our client blocking is working.</ p >
27105
28- < button id ="run " onclick ="run() "> Download Button</ button >
29- < a href ="/security/badware/phishing-redirect/download "> Download Link</ a >
106+ < h2 > Blocked URL Targets</ h2 >
107+ < p > Click the buttons below to test various malware detection techniques based on JS file download techniques:</ p >
108+ < label >
109+ < input type ="checkbox " id ="delayedCheckbox "> Delay Download
110+ </ label >
111+ < ul >
112+ < li > < button id ="run " onclick ="linkHrefDownload() "> Href Download Button</ button > </ li >
113+ < li > < button id ="run " onclick ="blobDownload() "> Blob Download Button</ button > </ li >
114+ < li > < button id ="run " onclick ="xhrDownload() "> XHR Download Button</ button > </ li >
115+ < li > < button id ="run " onclick ="iframeDownload() "> Iframe Download Button</ button > </ li >
116+ < li > < button id ="run " onclick ="windowLocationDownload() "> Window Location Download Button</ button > </ li >
117+ < li > < button id ="run " onclick ="fetchStreamDownload() "> Fetch Stream Download Button</ button > </ li >
118+ < li > < a href ="/security/badware/phishing-redirect/download "> Download Link</ a > </ li >
119+ </ ul >
120+
121+ < h2 > Blocked File Content</ h2 >
122+ < p > These links are to files where the file content should be blocked, as opposed to the file URL or JS technique:</ p >
123+ < ul >
124+ < li > < a href ="/security/badware/phishing-redirect/files/bad_app_file_on_scan.exe "> Uncommon, then "malicious" warning after deep scanning</ a > </ li >
125+ < li > < a href ="/security/badware/phishing-redirect/files/unknown.apk "> File warning on Android</ a > </ li >
126+ < li > < a href ="/security/badware/phishing-redirect/files/content.exe "> File warning on Desktop</ a > </ li >
127+ < li > < a href ="/security/badware/phishing-redirect/files/zip_password_1234.zip "> Password Protected ZIP</ a > </ li >
128+ </ ul >
30129</ body >
31130
32131</ html >
0 commit comments