cscg24-lolpython

CSCG 2024 Challenge 'Can I Haz Lolpython?'
git clone https://git.sinitax.com/sinitax/cscg24-lolpython
Log | Files | Refs | sfeed.txt

transpile.php (412B)


      1<?php
      2
      3
      4$input = json_decode(file_get_contents('php://input'), true);
      5if (!isset($input["code"])) {
      6    echo json_encode(array("error" => "no input data"));
      7    die();
      8}
      9
     10$tmpfname = tempnam("/tmp", "lolpython_prog_");
     11$handle = fopen($tmpfname, "w");
     12fwrite($handle, $input["code"]);
     13fclose($handle);
     14
     15$stdout = shell_exec("python2 /opt/lolcode.py $tmpfname");
     16
     17echo(json_encode(array("result" => $stdout)));
     18?>