This attack exploits target software that constructs SQL statements based on user input. An attacker crafts input strings so that when the target software constructs SQL statements based on the input, the resulting SQL statement performs actions other than those the application intended. SQL Injection results from failure of the application to appropriately validate input.
Description
Attack Execution Flow
Step 1
Explore[Survey application] The attacker first takes an inventory of the functionality exposed by the application.
Spider web sites for all available links
Sniff network communications with application using a utility such as WireShark.
[Applicazione di rilevamento] L'attaccante inizia con un inventario delle funzionalità esposte dall'applicazione.
Crea una mappa dei siti web per tutti i link disponibili
Sniffa le comunicazioni di rete con l'applicazione utilizzando un'utilità come WireShark.
Attack Techniques
-
Sniff network communications with application using a utility such as WireShark.
-
Spider web sites for all available linksIT: Sniffare le comunicazioni di rete con un'applicazione utilizzando un'utilità come WireShark.
Step 2
Experiment[Determine user-controllable input susceptible to injection] Determine the user-controllable input susceptible to injection. For each user-controllable input that the attacker suspects is vulnerable to SQL injection, attempt to inject characters that have special meaning in SQL (such as a single quote character, a double quote character, two hyphens, a parenthesis, etc.). The goal is to create a SQL query with an invalid syntax.
Use web browser to inject input through text fields or through HTTP GET parameters.
Use a web application debugging tool such as Tamper Data, TamperIE, WebScarab,etc. to modify HTTP POST parameters, hidden fields, non-freeform fields, etc.
Use network-level packet injection tools such as netcat to inject input
Use modified client (modified by reverse engineering) to inject input.
Sperimentazione
[Determinare l'input controllabile dall'utente suscettibile di injection] Determinare l'input controllabile dall'utente che l'attaccante sospetta sia vulnerabile a SQL injection. Per ogni input controllabile dall'utente, tentare di iniettare caratteri con significato speciale in SQL (come un apice singolo, un apice doppio, due trattini, una parentesi, ecc.). L'obiettivo è creare una query SQL con una sintassi non valida.
Utilizzare il browser web per iniettare input tramite campi di testo o tramite parametri HTTP GET.
Utilizzare uno strumento di debugging delle applicazioni web come Tamper Data, TamperIE, WebScarab, ecc. per modificare i parametri HTTP POST, campi nascosti, campi non liberi, ecc.
Utilizzare strumenti di injection di pacchetti a livello di rete come netcat per iniettare input.
Utilizzare un client modificato (modificato tramite reverse engineering) per iniettare input.
Attack Techniques
-
Use network-level packet injection tools such as netcat to inject input
-
Use a web application debugging tool such as Tamper Data, TamperIE, WebScarab,etc. to modify HTTP POST parameters, hidden fields, non-freeform fields, etc.IT: Utilizza strumenti di iniezione di pacchetti a livello di rete come netcat per iniettare input
-
Use modified client (modified by reverse engineering) to inject input.IT: Utilizza strumenti di iniezione di pacchetti a livello di rete come netcat per iniettare input
-
Use web browser to inject input through text fields or through HTTP GET parameters.IT: Utilizza strumenti di iniezione di pacchetti a livello di rete come netcat per iniettare input
Step 3
Experiment[Experiment with SQL Injection vulnerabilities] After determining that a given input is vulnerable to SQL Injection, hypothesize what the underlying query looks like. Iteratively try to add logic to the query to extract information from the database, or to modify or delete information in the database.
Use public resources such as 'SQL Injection Cheat Sheet' at http://ferruh.mavituna.com/makale/sql-injection-cheatsheet/, and try different approaches for adding logic to SQL queries.
Add logic to query, and use detailed error messages from the server to debug the query. For example, if adding a single quote to a query causes an error message, try : '' OR 1=1; --', or something else that would syntactically complete a hypothesized query. Iteratively refine the query.
Use 'Blind SQL Injection' techniques to extract information about the database schema.
If a denial of service attack is the goal, try stacking queries. This does not work on all platforms (most notably, it does not work on Oracle or MySQL). Examples of inputs to try include: ''; DROP TABLE SYSOBJECTS; --' and ''); DROP TABLE SYSOBJECTS; --'. These particular queries will likely not work because the SYSOBJECTS table is generally protected.
Sperimentazione
[Esperimento con vulnerabilità di SQL Injection] Dopo aver determinato che un determinato input è vulnerabile a SQL Injection, ipotizza come potrebbe apparire la query sottostante. Cerca iterativamente di aggiungere logica alla query per estrarre informazioni dal database, o per modificare o eliminare dati nel database.
Utilizza risorse pubbliche come "SQL Injection Cheat Sheet" all'indirizzo http://ferruh.mavituna.com/makale/sql-injection-cheatsheet/, e prova approcci diversi per aggiungere logica alle query SQL.
Aggiungi logica alla query e utilizza messaggi di errore dettagliati dal server per il debug della query. Ad esempio, se aggiungere un apostrofo a una query provoca un messaggio di errore, prova con: "' OR 1=1; --", o qualcos'altro che completi sintatticamente una query ipotizzata. Raffina iterativamente la query.
Utilizza tecniche di "Blind SQL Injection" per estrarre informazioni sullo schema del database.
Se l'obiettivo è un attacco di tipo denial of service, prova a concatenare più query. Questo metodo non funziona su tutte le piattaforme (soprattutto, non funziona su Oracle o MySQL). Esempi di input da provare includono: "'; DROP TABLE SYSOBJECTS; --" e "'); DROP TABLE SYSOBJECTS; --". Queste query particolari probabilmente non funzioneranno perché la tabella SYSOBJECTS è generalmente protetta.
Attack Techniques
-
Use public resources such as "SQL Injection Cheat Sheet" at http://ferruh.mavituna.com/makale/sql-injection-cheatsheet/, and try different approaches for adding logic to SQL queries.
-
Add logic to query, and use detailed error messages from the server to debug the query. For example, if adding a single quote to a query causes an error message, try : "' OR 1=1; --", or something else that would syntactically complete a hypothesized query. Iteratively refine the query.IT: Utilizza risorse pubbliche come "SQL Injection Cheat Sheet" all'indirizzo http://ferruh.mavituna.com/makale/sql-injection-cheatsheet/ e sperimenta diversi approcci per aggiungere logica alle query SQL.
-
If a denial of service attack is the goal, try stacking queries. This does not work on all platforms (most notably, it does not work on Oracle or MySQL). Examples of inputs to try include: "'; DROP TABLE SYSOBJECTS; --" and "'); DROP TABLE SYSOBJECTS; --". These particular queries will likely not work because the SYSOBJECTS table is generally protected.IT: Utilizza risorse pubbliche come "SQL Injection Cheat Sheet" all'indirizzo http://ferruh.mavituna.com/makale/sql-injection-cheatsheet/ e sperimenta diversi approcci per aggiungere logica alle query SQL.
-
Use "Blind SQL Injection" techniques to extract information about the database schema.IT: Utilizza risorse pubbliche come "SQL Injection Cheat Sheet" all'indirizzo http://ferruh.mavituna.com/makale/sql-injection-cheatsheet/ e sperimenta diversi approcci per aggiungere logica alle query SQL.
Step 4
Exploit[Exploit SQL Injection vulnerability] After refining and adding various logic to SQL queries, craft and execute the underlying SQL query that will be used to attack the target system. The goal is to reveal, modify, and/or delete database data, using the knowledge obtained in the previous step. This could entail crafting and executing multiple SQL queries if a denial of service attack is the intent.
Craft and Execute underlying SQL query
[Exploit vulnerabilità SQL Injection] Dopo aver perfezionato e aggiunto varie logiche alle query SQL, crea ed esegui la query SQL sottostante che verrà utilizzata per attaccare il sistema target. L'obiettivo è rivelare, modificare e/o eliminare i dati del database, utilizzando le conoscenze ottenute nel passaggio precedente. Ciò potrebbe comportare la creazione ed esecuzione di più query SQL se l'intento è un attacco di tipo denial of service.
Creare ed Eseguire la query SQL sottostante
Attack Techniques
-
Craft and Execute underlying SQL query