In this dissertation we examine web exploitation from a number of different perspectives.First, we introduce return-to-JavaScript attacks; a new flavor of Cross-Site Scripting (XSS), which is able to escape script whitelisting. Second, we design xJS, a system that can prevent code injections of JavaScript in web applications. xJS is based on the concept of Instruction Set Randomization (ISR) for isolating legitimate JavaScript from malicious injections. We evaluate xJS and show that the overhead it imposes in the server's and the client's side is negligible, since xJS is based on the fast XOR operation. Third, we deliver a more fine-grained randomization framework for web applications, RaJa, which can efficiently cope with language mixing. RaJa can successfully extract and randomize the JavaScript source code of real-world applications, which experience heavy code-mixing (i.e. JavaScript is mixed with a server-side programming language, such as PHP). Forth, we present xHunter, a network-level detector, which is able to locate JavaScript fragments in the body of URLs. With the assistance of xHunter we deliver an extensive analysis of the largest to date web-attack repository, XSSed.com. This particular repository hosts about 12,000 incidents of web exploitation. Our analysis identifies that 7% of all examined web attacks do not use any markup elements, such as