Download Source Code

All of the code used in this book is available for download. The download package generates an actual Web Forms website that you can run locally in Visual Studio to practice defense against common XSS attacks. The package includes:

  • Real-world examples. Everyday, working code to illustrate common XSS attacks and effective counter-measures.
  • XSS-Defender. A Javascript library of sanitization and encoding methods designed to resist DOM-Based XSS attacks.

For detailed guidance on working with source code, see Appendix A in the book.

How to Download Source Code

Follow these instructions to download source code from the book:

  • Click the "Download" button below.
  • From the the dialog box that appears, Choose "Save File". Then, click "OK".
  • Files will be saved to the "Downloads" directory on your computer.
  • The files will be in a zipped folder, named "xss-site".
  • Drag the zipped folder to a new location of your choice.
  • To unzip the folder, press and hold (or right-click) the folder, select "Extract All", and follow instructions.

When you unzip the folder, you will see another folder called "xss-site". All of the source code can be found in that folder.

How to Work with Source Code

The “xss-site” folder is actually a web site that you can access with Visual Studio Community 2017 (or any other current version of Visual Studio). To get a free copy of Visual Studio Community, go to https://visualstudio.microsoft.com/downloads/.

To run the web site and view web pages in a browser, open the “xss-site” folder as a web site in Visual Studio Community. Then, click F5 from the integrated development environment. The home page for the website shows links to each example from the book. To see any example, simply click its link from the home page.

To read or edit individual files, open Visual Basic's Solution Explorer by choosing View/Solution Explorer from the main menu (or by typing Ctrl+Alt+L). The Solution Explorer lists all of the source code files. From the Solution Explorer, you can select individual files to read or edit.

If you have any questions about working with source code, see Appendix A in the book.