Results 1 to 6 of 6

Thread: How to Inject SQL Statements in PHP?

  1. #1
    Join Date
    Jul 2006
    Posts
    273

    How to Inject SQL Statements in PHP?

    Hi friends,
    I have used SQL queries with the other programming languages but not with the PHP. I want to use the SQL statements with the PHP programming language. I have done the basic programs in PHP and also tried to use SQL statements into it but was not succeeded. So please help me by telling how to Inject SQL Statements in PHP? Also provide any related coding which would be very helpful for me.!! Thanks in Advance.!!
    (\__/)
    (='.'=) This is Bunny. Copy and paste bunny into your
    (")_(") signatureto help him gain world domination

  2. #2
    Join Date
    Jul 2006
    Posts
    442

    Re: How to Inject SQL Statements in PHP?

    Many web developers are unaware of opportunities to manipulate SQL queries, and assume that the SQL commands are safe. This means that SQL queries are able to circumvent controls and audits, such as identification, and sometimes SQL queries have access to administrative commands. Direct SQL Command Injection is a technique where an attacker creates or alters existing SQL commands to expose hidden data or to override valuable ones or even to execute dangerous commands to the database. This is where application data is sent by the user and used directly to construct an SQL query.
    "When they give you ruled paper, write the other way..." J.R.J.

  3. #3
    Join Date
    Aug 2006
    Posts
    227

    Re: How to Inject SQL Statements in PHP?

    With the lack of verification of data and connecting to the server with root privileges, the attacker can create users and create another superuser. I have provided you with an example of splitting the result set into pages and making superusers, so just have a look at the sample of coding :
    PHP Code:
    <?php
     
    $offset 
    $argv[0]; 
    $query  "SELECT id, name FROM sales ORDER BY name LIMIT 25 OFFSET $offset;";
    $result pg_query($conn$query);
     
    ?>
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  4. #4
    Join Date
    Aug 2006
    Posts
    235

    Re: How to Inject SQL Statements in PHP?

    Normal users click on the buttons 'next' and 'previous', which are then placed in the variable $ offset is encoded in the URL. The script expects that the incoming $ offset is a decimal number. However, it is possible to change the URL by adding a new value, the URL format, like this :
    PHP Code:
    0;
    INSERT INTO pg_shadow(usename,usesysid,usesuper,usecatupd,passwd)
        
    SELECT 'crack'usesysid't','t','crack'
        
    FROM pg_shadow WHERE usename='postgres';
    -- 
    If this happens, the script will create a new superuser. Note that the value 0 is used to complete the original query and to complete successfully.
    3.2 (northwood)
    2gig ram
    ATI AIW X800xt 256mb
    Gigabyte GA-8knxp 875p Chipset
    Optiwrite 8X DVD Burner
    Win XP PRO Sp2 (Works Perfectly)
    2 SATA Raptor 74gig Raid 0
    2 7200 IDE 320gig HD

  5. #5
    Join Date
    Jul 2006
    Posts
    286

    Re: How to Inject SQL Statements in PHP?

    One way to gain passwords is to circumvent the search page. What the attacker needs to do is to see if a form variable is used in the application, and if it is mismanaged. These filters can be configured in a previous page to be used in WHERE clauses, ORDER BY, LIMIT and OFFSET SELECT queries. If your database supports the UNION construct, the attacker may try to append an entire query to list passwords from any table. Using the technique of encrypted passwords is strongly recommended. Also the code provided by the 'MELTRONICS', you can observe the symbol - in that. This is a common technique to force the SQL parser to ignore the rest of the request, using the symbols - to put in comments.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  6. #6
    Join Date
    Mar 2008
    Posts
    672

    Re: How to Inject SQL Statements in PHP?

    SQL UPDATE's are also prone to attacks of your database. These queries can also introduce a new application on your initial order. But the attacker might fiddle with the SET command. In this case, he must know something about your database. This can be guessed by examining the variable names in forms, or just simply brute forcing more traditional. There are not many naming conventions to store usernames and passwords. But a rogue user can send a value 'or uid like'% admin% '; - to $ uid to change the user password. The following is a query and its injection :
    PHP Code:
    <?php
     
    $query 
    "UPDATE usertable SET pwd='...' WHERE uid='' or uid like '%admin%'; --";
     
    $query "UPDATE usertable SET pwd='pass', admin='yes', trusted=100 WHERE
    ...;"
    ;
     
    ?>

Similar Threads

  1. Remove the Trojan.Inject.WX
    By Gaelic in forum Networking & Security
    Replies: 4
    Last Post: 06-03-2010, 07:28 PM
  2. Help to eradicate Backdoor.Inject.abg
    By mesterio in forum Networking & Security
    Replies: 6
    Last Post: 04-03-2010, 10:34 PM
  3. Difference between DML statements and DDL statements
    By Prashobh Mallu in forum Software Development
    Replies: 5
    Last Post: 11-01-2010, 01:07 PM
  4. Problem with my IF ELSE IF statements in C++
    By KACY5 in forum Software Development
    Replies: 2
    Last Post: 04-09-2009, 05:12 PM
  5. SQL statements with JSP
    By blindsleeper in forum Software Development
    Replies: 2
    Last Post: 16-05-2009, 09:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,875,057.87060 seconds with 17 queries