Jump to content

Executing ELF file with exec()


Bunsly

Recommended Posts

Hey guys!

My current employer contracted someone to create a script for him. (The script itself is to create a serial number for a piece of software) It's just a PHP script that executes a file and retrieves its output.

Now I've never worked with exec() in PHP, and I don't have a reliable environment to test it in. I compiled apache2 and php 5.0.4 and set them to run on a Macintosh (10.3.9) in the office, but I'm sure I've missed some crucial setup stage (mainly, I'm missing php.ini. I did a php -i | grep php.ini to find it, and it says it is in /etc/, but when I look in my PHP/etc folder, only pear.conf is there!). PHP and apache both appear to be working fine, though.

 

When I try and run the PHP script that executes the .ELF file, I get a blank page. Is this because I'm running it in OS X?  should I be running it in Linux?

Also, I don't know how to Enable exec() on my server, or to see if it's enabled. Basically, I just need someone to walk me through the basics of this. The script and executable SHOULD work fine because the contractor got it working fine.

Below is the script, and attached is the executable.

Thanks! :3

 

<?php

/*
inUID = 456890
inSerialNumUID = 123456
inMachineID_s = &6dA-8P@K-Xsq
*/

$p1 = "456890";
$p2 = "123456";
$p3 = "\&6dA-8P@K-Xsq";

exec("./create_activation_code.elf $p1 $p2 $p3", $output);

foreach ($output as $output_str)
{
echo $output_str."<br>";
}

?>

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/215797-executing-elf-file-with-exec/
Share on other sites

php.ini is probably in /etc not PHP/etc.  Also, you're not going to be able to run an ELF binary on OSX.  You can try compiling the source or there is a FreeBSD kernel module that provides some Linux compatibility and it should run on OSX.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.