doqw89029 2013-12-18 17:54
浏览 32
已采纳

来自php脚本安全的mysqldump

If I do shell_exec('mysqldump DATABASE_NAME') from a php script, is there any danger?

Is there a way to get this to work in Windows?

I am going to use mysqldump for database backup from a web page

Also should I do set_time_limit(0) when running this?

  • 写回答

1条回答 默认 最新

  • dounai9294 2013-12-18 18:47
    关注

    Yeah, there is danger: If database name comes from an untrusted source hackers could try to inject shell commands in the database name. For example:

    $dbname = 'test; cat /etc/shadow';
    

    might being used to obtain user names and encrypted passwords from the system (depends on the system)..

    To avoid that, you should use escapeshellarg() to quote the database name (and possible other arguments):

    shell_exec('mysqldump ' . escapeshellarg($database_name));
    

    set_time_limit() isn't required if you are following my hints here


    Needless to say, that you'll have to secure the page using login.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题2
  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备