![]() |
|
#1
|
|||
|
|||
|
He aqui una pequeña solucion al sql injection, chequen si les es efectivo: //Creditos : FCV2005 <?php $ip = $_SERVER['REMOTE_ADDR']; $time = date("l dS of F Y h:i:s A"); $script = $_SERVER[PATH_TRANSLATED]; $fp = fopen ("C:/MuServer/[WEB]SQL_Injection.txt", "a+"); //aqui se creara un log del ataque y el ip del atacante, puedes cambiar la ubicacion del archivo. $sql_inject_1 = array(";","'","%",'"'); #Whoth need replace $sql_inject_2 = array("", "","","""); #To wont replace $GET_KEY = array_keys($_GET); #array keys from $_GET $POST_KEY = array_keys($_POST); #array keys from $_POST $COOKIE_KEY = array_keys($_COOKIE); #array keys from $_COOKIE /*begin clear $_GET */ for($i=0;$i<count($GET_KEY);$i++) { $real_get[$i] = $_GET[$GET_KEY[$i]]; $_GET[$GET_KEY[$i]] = str_replace($sql_inject_1, $sql_inject_2, HtmlSpecialChars($_GET[$GET_KEY[$i]])); if($real_get[$i] != $_GET[$GET_KEY[$i]]) { fwrite ($fp, "IP: $ip\r\n"); fwrite ($fp, "Method: GET\r\n"); fwrite ($fp, "Value: $real_get[$i]\r\n"); fwrite ($fp, "Script: $script\r\n"); fwrite ($fp, "Time: $time\r\n"); fwrite ($fp, "==================================\r\n"); } } /*end clear $_GET */ /*begin clear $_POST */ for($i=0;$i<count($POST_KEY);$i++) { $real_post[$i] = $_POST[$POST_KEY[$i]]; $_POST[$POST_KEY[$i]] = str_replace($sql_inject_1, $sql_inject_2, HtmlSpecialChars($_POST[$POST_KEY[$i]])); if($real_post[$i] != $_POST[$POST_KEY[$i]]) { fwrite ($fp, "IP: $ip\r\n"); fwrite ($fp, "Method: POST\r\n"); fwrite ($fp, "Value: $real_post[$i]\r\n"); fwrite ($fp, "Script: $script\r\n"); fwrite ($fp, "Time: $time\r\n"); fwrite ($fp, "==================================\r\n"); } } /*end clear $_POST */ /*begin clear $_COOKIE */ for($i=0;$i<count($COOKIE_KEY);$i++) { $real_cookie[$i] = $_COOKIE[$COOKIE_KEY[$i]]; $_COOKIE[$COOKIE_KEY[$i]] = str_replace($sql_inject_1, $sql_inject_2, HtmlSpecialChars($_COOKIE[$COOKIE_KEY[$i]])); if($real_cookie[$i] != $_COOKIE[$COOKIE_KEY[$i]]) { fwrite ($fp, "IP: $ip\r\n"); fwrite ($fp, "Method: COOKIE\r\n"); fwrite ($fp, "Value: $real_cookie[$i]\r\n"); fwrite ($fp, "Script: $script\r\n"); fwrite ($fp, "Time: $time\r\n"); fwrite ($fp, "==================================\r\n"); } } /*end clear $_COOKIE */ fclose ($fp); ?> Esto va en el config.php de la Muweb que usen, antes del codigo de la coneccion, cualquier cosa, prueben el script que aun lo siguen mejorando. ============== Segunda Parte: COMO FUNCIONA EL SQL INJECTION, COMO PROBARLO Y SABER SI ESTAS PROTEGIDO DE ESTE Aqui una lista de injecciones para el sql: ABORT -- abort the current transaction ALTER DATABASE -- change a database ALTER GROUP -- add users to a group or remove users from a group ALTER TABLE -- change the definition of a table ALTER TRIGGER -- change the definition of a trigger ALTER USER -- change a database user account ANALYZE -- collect statistics about a database BEGIN -- start a transaction block CHECKPOINT -- force a transaction log checkpoint CLOSE -- close a cursor CLUSTER -- cluster a table according to an index COMMENT -- define or change the comment of an object COMMIT -- commit the current transaction COPY -- copy data between files and tables CREATE AGGREGATE -- define a new aggregate function CREATE CAST -- define a user-defined cast CREATE CONSTRAINT TRIGGER -- define a new constraint trigger CREATE CONVERSION -- define a user-defined conversion CREATE DATABASE -- create a new database CREATE DOMAIN -- define a new domain CREATE FUNCTION -- define a new function CREATE GROUP -- define a new user group CREATE INDEX -- define a new index CREATE LANGUAGE -- define a new procedural language CREATE OPERATOR -- define a new operator CREATE OPERATOR CLASS -- define a new operator class for indexes CREATE RULE -- define a new rewrite rule CREATE SCHEMA -- define a new schema CREATE SEQUENCE -- define a new sequence generator CREATE TABLE -- define a new table CREATE TABLE AS -- create a new table from the results of a query CREATE TRIGGER -- define a new trigger CREATE TYPE -- define a new data type CREATE USER -- define a new database user account CREATE VIEW -- define a new view DEALLOCATE -- remove a prepared query DECLARE -- define a cursor DELETE -- delete rows of a table DROP AGGREGATE -- remove a user-defined aggregate function DROP CAST -- remove a user-defined cast DROP CONVERSION -- remove a user-defined conversion DROP DATABASE -- remove a database DROP DOMAIN -- remove a user-defined domain DROP FUNCTION -- remove a user-defined function DROP GROUP -- remove a user group DROP INDEX -- remove an index DROP LANGUAGE -- remove a user-defined procedural language DROP OPERATOR -- remove a user-defined operator DROP OPERATOR CLASS -- remove a user-defined operator class DROP RULE -- remove a rewrite rule DROP SCHEMA -- remove a schema DROP SEQUENCE -- remove a sequence DROP TABLE -- remove a table DROP TRIGGER -- remove a trigger DROP TYPE -- remove a user-defined data type DROP USER -- remove a database user account DROP VIEW -- remove a view END -- commit the current transaction EXECUTE -- execute a prepared query EXPLAIN -- show the execution plan of a statement FETCH -- retrieve rows from a table using a cursor GRANT -- define access privileges INSERT -- create new rows in a table LISTEN -- listen for a notification LOAD -- load or reload a shared library file LOCK -- explicitly lock a table MOVE -- position a cursor on a specified row of a table NOTIFY -- generate a notification PREPARE -- create a prepared query REINDEX -- rebuild corrupted indexes RESET -- restore the value of a run-time parameter to a default value REVOKE -- remove access privileges ROLLBACK -- abort the current transaction SELECT -- retrieve rows from a table or view SELECT INTO -- create a new table from the results of a query SET -- change a run-time parameter SET CONSTRAINTS -- set the constraint mode of the current transaction SET SESSION AUTHORIZATION -- set the session user identifier and the current user identifier of the current session SET TRANSACTION -- set the characteristics of the current transaction SHOW -- show the value of a run-time parameter START TRANSACTION -- start a transaction block TRUNCATE -- empty a table UNLISTEN -- stop listening for a notification UPDATE -- update rows of a table VACUUM -- garbage-collect and optionally analyze a database Con esto, los lammers se creen hackers y empiezan a borrar o alterar cosas a su gusto. Tambien existe un pequeña y molestosa inyeccion que es apagar el sql ('';shutdown;--). La mayoria de veces las inyecciones son puestas en el registro o en la recuperacion de clave, en la casilla del email. un ejemplo para saber si nuestra pagina es vulnerable seria poner esto de la siguiente manera: NOTA:si vas a probar esto, te recuerdo hacer una copia de tu base de datos. - vas a crear una cuenta o recuperar clave y donde dice email pones: '';shutdown;-- (apagar SQL), tambien puedes poner otro tipo de inyeccion como el de borrar tablas que mayormente hacen : '';Drop Table Character;-- (esto quiere decir que borrara la tabla de los pjs). despues de eso esperas menos de 10 segundos y tu pagina mostrara error sea el caso que hayas botado una tabla o que hayas apagado tu sql, en caso de que estas inyecciones no hagan efecto, felicidades, estas protegido. Una recomendacion que todos dicen es usar la muweb 0.3 o la muweb 0.9 con el xampp, bueno, aunque tambien poniendo el script ya mencionado puede ayudar a evitar esto de forma temporal, ya que los hackers si sabran como, pero no los lammers que esos si hay bastantes. Saludos denuevo a toda la comunidad |
![]() |
| Etiquetas |
| seguridad web mu online |
| Herramientas | |
| Desplegado | |
|
|