2017-05-27 5 views
0

LinuxサーバーでPHPを使用して4つのファイルをテストし、その結果がテキスト領域に表示されます。これを解決する正しい方法が何であるか教えてください。phpボタンからbashコードを実行しています

のSh test_batch.sh

$ {dict_file} $ {locale} $ {keyboard_layout} $ {golden_test_file} $ 
{auto_correction_file} (optional) 

those are the four files with check box

if (isset($_POST['files'])) { 
foreach ($_POST['files'] as $value) { 
echo $dir . $value . '<br />'; 
$result = shell_exec('sudo sh test_batch.sh $dir .$value. '); 

    } 
    }else { 
    exit('No files selected'); 
    } 
    } 
    ?> 
          <br/> 
          <table> 
          <tr> 
        <td><b>Result to Display and Save:</b></td></tr> 
      <tr> 
        <td colspan="3"> 
        <textarea disabled id="inputTextToSave" style="width:512px;height:256px" value = "'.$result.'"></textarea>` 

答えて

0

まず第一に、あなたは何もするウェブスクリプトにsudoを使用を控える必要があります。誰かがあなたのサーバに$ _POSTの"& & rm -rf /"の文字列を送り、それがあなたののsudo sh test_batch.sh $ dir。$ value文字列に連結された場合はどうなりますか?それは非常に悪い日になります。代わりに

、要求は(あなたがNode.jsのと、PerlやPHPでこれを行うことができ、それにキューワーカー・プロセスのスクリプトのいくつかの種類にないものは何でもtest_batch.sh ...いくつかの方法があるの実装を検討してください。

関連する問題