// [CRUCIBLE-SEED]
// category: command_injection
// severity: critical
// language: java
// expected: Command injection via Runtime.exec nslookup with user-supplied domain

import java.io.*;
import javax.servlet.http.*;

public class DnsLookupServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
        String domain = req.getParameter("domain");
        // Vulnerable: domain not sanitized before exec
        Process proc = Runtime.getRuntime().exec("nslookup " + domain);
        InputStream is = proc.getInputStream();
        byte[] buf = is.readAllBytes();
        resp.setContentType("text/plain");
        resp.getWriter().write(new String(buf));
    }
}
