Questions about this topic? Sign up to ask in the talk tab.

SQL backdoor

From NetSec
Revision as of 09:43, 24 January 2012 by LashawnSeccombe (Talk | contribs) (Created page with "{{info|'''SQL Malware''' affects a variety of database-driven applications, including but not limited to web applications, services, and desktop ...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
c3el4.png SQL Malware affects a variety of database-driven applications, including but not limited to web applications, services, and desktop applications. This breed of malware is made possible by the SQL functionality for triggers and stored sub-procedures.

Concept

Notice: SQL malware persists beyond deletion of rows containing it from a table.
SQL malware can exist in subprocedures and triggers, resulting in its activation at the execution of every (or a specific) query. It can do anything from resetting a password hash to replacing user-contributed content with redirects browser exploits and other malware distribution tactics.

Subprocedures

Sub-procedures are similar to functions or methods in other programming languages. They can be passed arguments, perform operations on the arguments passed, and return computed data.

Event Procedures

Triggers, otherwise referred to as event procedures in other programming languages, may be attached to any table for update,delete, or insert queries. It is important to note that while triggers cannot be bound to select queries, many applications store user activity history in SQL (search history, for example). In stead of hooking the SELECT ... LIKE statement against the table being searched to determine if a search query contained a particular keyword, a developer can hook the INSERT query against the history table where the search is logged.

Implementation

RPU0j.png These notes are for educational purposes only. Use of these code snippets on systems or databases that you do not own is a criminal act.
Protip: Depending on the databasing engine's version and configuration, it may be possible to inject SQL malware using SQL injection.

MySQL

Notice: CREATE TRIGGER requires the SUPER privilege on the selected database in order to execute successfully.

Syntax

Example: phpBB backdoor

PostgreSQL

Syntax

Example: Wordpress backdoor

MS SQL

Syntax

Example: DotNetNuke backdoor