Sharing memory between two processes (C, Windows)

Although windows supports shared memory through its file mapping API, you can’t easily inject a shared memory mapping into another process directly, as MapViewOfFileEx does not take a process argument. However, you can inject some data by allocating memory in another process using VirtualAllocEx and WriteProcessMemory. If you were to copy in a handle using … Read more

How to inject jquery to any webpage [duplicate]

This is a bookmarklet code to inject jquery in any webpage: javascript: (function (){ function l(u, i) { var d = document; if (!d.getElementById(i)) { var s = d.createElement(‘script’); s.src = u; s.id = i; d.body.appendChild(s); } } l(“https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js”, ‘jquery’) })(); Update: I removed the http: part from the URL per @Monkpit comment, which is … Read more

How to prevent code injection attacks in PHP?

mysql_real_escape_string used when insert into database htmlentities() used when outputting data into webpage htmlspecialchars() used when? strip_tags() used when? addslashes() used when? htmlspecialchars() used when? htmlspecialchars is roughly the same as htmlentities. The difference: character encodings. Both encode control characters like <, >, & and so on used for opening tags etc. htmlentities also encode … Read more

How to prevent Javascript injection attacks within user-generated HTML

You think that’s it? Check this out. Whatever approach you take, you definitely need to use a whitelist. It’s the only way to even come close to being safe about what you’re allowing on your site. EDIT: I’m not familiar with .NET, unfortunately, but you can check out stackoverflow’s own battle with XSS (https://blog.stackoverflow.com/2008/06/safe-html-and-xss/) and … Read more

Can parameterized statement stop all SQL injection?

When articles talk about parameterized queries stopping SQL attacks they don’t really explain why, it’s often a case of “It does, so don’t ask why” — possibly because they don’t know themselves. A sure sign of a bad educator is one that can’t admit they don’t know something. But I digress. When I say I … Read more