code-injection

Cleaning/sanitizing xpath attributes

旧城冷巷雨未停 提交于 2019-12-17 20:36:24
问题 I need to dynamically construct an XPath query for an element attribute, where the attribute value is provided by the user. I'm unsure how to go about cleaning or sanitizing this value to prevent the XPath equivalent of a SQL injection attack. For example (in PHP): <?php function xPathQuery($attr) { $xml = simplexml_load_file('example.xml'); return $xml->xpath("//myElement[@content='{$attr}']"); } xPathQuery('This should work fine'); # //myElement[@content='This should work fine'] xPathQuery(

PHP mysql injection protection

做~自己de王妃 提交于 2019-12-17 19:44:31
问题 I have written this short function to protect against my_sql injection, because of its importance I just want to double check with other's that this will function as I intend. foreach($_REQUEST as $key => $value) { $_REQUEST[$key] = stripslashes($value); $_REQUEST[$key] = mysql_real_escape_string($_REQUEST[$key]); } 回答1: Well, you use stripslashes() because the magic_quotes_gpc is set? So this code will only work when magic_quotes_gpc is set! I'd recommend you switch it off and dont use the

How can I print stack trace for caught exceptions in C++ & code injection in C++

荒凉一梦 提交于 2019-12-17 17:29:33
问题 I want to have stack trace not for my exceptions only but also for any descendants of std::exception As I understand, stack trace is completely lost when exception is caught because of stack unwinding (unrolling). So the only way I see to grab it is injection of code saving context info (stack trace) at the place of std::exception constructor call. Am I right? If it is the case, please tell me how code injection can be done (if it can) in C++. Your method may be not completely safe because I

Force x86 CLR on an 'Any CPU' .NET assembly

喜你入骨 提交于 2019-12-17 17:25:56
问题 In .NET, the 'Platform Target: Any CPU' compiler option allows a .NET assembly to run as 64 bit on a x64 machine, and 32 bit on an x86 machine. It is also possible to force an assembly to run as x86 on an x64 machine using the 'Platform Target: x86' compiler option. Is it possible to run an assembly with the 'Any CPU' flag, but determine whether it should be run in the x86 or x64 CLR? Normally this decision is made by the CLR/OS Loader (as is my understanding) based on the bitness of the

Php & Sql Injection - UTF8 POC

霸气de小男生 提交于 2019-12-17 10:34:39
问题 There is a lot of talk about how addslashes and mysql_real_escape function are not safe to prevent injections. The truth is even the big frameworks or CMSs like Wordpress are using this functions and they do a god job so far. I know there are some particular scenarios when using GBK charset, or utf8_decode can be used to inject some sql code, or some simple examples like 1' OR 1 -- that can be used when there is a simple where involved. However, after a bit of research it seems very hard to

Javascript Injected in browser

谁都会走 提交于 2019-12-14 03:42:02
问题 I am using 4g wifi internet whenever I visit any page it keeps loading and when I look at a source code of the page there is a script injected into code <script type = 'text/javascript' id ='1qa2ws' charset='utf-8' src='http://10.80.196.101:8080/www/default/base.js'></script> Please help its really annoying. 回答1: I just figured it out its my ISP injecting javascript in browsers. So I resolved it by using No Javascript addon in Firefox as well as in Chrome . This would help for those who are

NtReadFile doesn't read

夙愿已清 提交于 2019-12-14 03:25:19
问题 I try to write dll injector with nativeApi. My first question is this good way to do it? And second is: NtReadFile doesn't fail, but also doesn't read. I think it's buffer wrong but i'm not sure? How can i fix this issue? Now it's look like this: bool initiationDll(const std::string& dllPath){ if (!isDllExist(dllPath)) { printf("Dll doesn't exist!\n"); return false; } else { printf("LibraryPath :%s\n", dllPath.c_str()); NTSTATUS status; HANDLE lFile; OBJECT_ATTRIBUTES objAttribs = { 0 };

C++ Code Injection crashes injected application

佐手、 提交于 2019-12-14 01:28:45
问题 I'm trying to inject a simple executable into another executable that I made, unfortunately, whenever I inject the code into the executable, it says 'simpleinjected.exe has stopped working' then it closes. I'm using CreateRemoteThread to inject the code. This is what I have done so far. Injector.exe // the file that's injecting the code #include <stdio.h> #include <windows.h> #define procId 2844 #define executable "executable.exe" // located in same directory int main() { HANDLE hProc =

Will this be enough to prevent Mysql injection using MYSQL_QUERY

喜夏-厌秋 提交于 2019-12-14 00:05:14
问题 I know most of the answers will say use PDO/Mysqli but I'm trying to see if I can do it this way then move on to PDO/Mysqli still learning: Will this function be enough to prevent mysql injection? function anti_inject($sql) { $sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"), "", $sql); $sql = preg_replace("/[^a-zA-Z0-9]+/", " ", $sql); $sql = mysql_real_escape_string($sql); $sql = trim($sql); $sql = strip_tags($sql); $sql = addslashes(

Can parameterized statement stop all SQL injection?

六眼飞鱼酱① 提交于 2019-12-13 17:35:10
问题 If yes, why are there still so many successful SQL injections? Just because some developers are too dumb to use parameterized statements? 回答1: The links that I have posted in my comments to the question explain the problem very well. I've summarised my feelings on why the problem persists, below: Those just starting out may have no awareness of SQL injection. Some are aware of SQL injection, but think that escaping is the (only?) solution. If you do a quick Google search for php mysql query ,