salman.isd Posted July 13, 2012 Share Posted July 13, 2012 I'm stuck with this problem for hours now.I'm trying to run this command echo $result=passthru('/host/Crypto/newlm/./LMSignature -verify 224 -message= text -signature= '.$signature.' -verifkey= '.$verifkeys.' -hashfunc= '.$hashfunc); on my php script but I'm not getting any output.A previous command echo $signature=passthru('/host/Crypto/newlm/./LMSignature -sign 224 -message= text -signkey= '.$signkeys); works fine.So I'm guessing it not an issue with permissions,access etc. All the variables like $verifkeys $hashfunc and $signature have been generated and stored in the php script.I can run the first command on the terminal by entering data manually but it isnt working in php. The syntax i enter in the terminal is ./LMSignature -verify 224 -message= text -signature= [keys] -verifkey= [keys] -hashfunc= [keys] Any help?thanks Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/ Share on other sites More sharing options...
requinix Posted July 13, 2012 Share Posted July 13, 2012 Assign the command to a variable, print out the variable, and see what it looks like. Also redirect stderr so you can catch any error messages. Also, 1. The /./ is unnecessary. 2. passthru() prints the output for you. 3. passthru() does not return anything. $command = '/host/Crypto/newlm/LMSignature -verify 224 -message= text -signature= ' . $signature . ' -verifkey= ' . $verifkeys . ' -hashfunc= ' . $hashfunc . ' 2>&1'; echo $command; //passthru($command); Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/#findComment-1361415 Share on other sites More sharing options...
salman.isd Posted July 13, 2012 Author Share Posted July 13, 2012 echo $command shows me all the specific keys in their respective slots (like -signature= , -verifkey= , -hashfunc=) as they should be. while, running the passthru ($command); gives me an error sh: 7: 1385284: not found ...and that 1385284 looks suspiciously like one of the generated keys :s Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/#findComment-1361416 Share on other sites More sharing options...
salman.isd Posted July 13, 2012 Author Share Posted July 13, 2012 any idea what could be going wrong? Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/#findComment-1361419 Share on other sites More sharing options...
requinix Posted July 13, 2012 Share Posted July 13, 2012 Are you escapeshellarg()ing those three variables before you put them into the command? You need to, otherwise there's a risk that there will be something in them that the shell will try to interpret. Which is the problem you're having. Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/#findComment-1361420 Share on other sites More sharing options...
salman.isd Posted July 13, 2012 Author Share Posted July 13, 2012 I tried this $command = '/opt/LMSignature -verify 224 -message= text -signature= ' . escapeshellarg($signature). ' -verifkey= ' . escapeshellarg($verifkeys). ' -hashfunc= ' . escapeshellarg($hashfunc) . ' 2>&1'; echo $command; passthru($command); Now im getting a Segmentation fault (core dumped) . From the output of "echo $command" i see single quotes added around every key batch like -verifkey= ' 9269440 6368543........9146576 , ' . Will it be passed as it is to the terminal by the passthru() fucntion ?because the C prog at the terminal will only run if the values are in the form of -verifkey= 9269440 6368543........9146576 , Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/#findComment-1361424 Share on other sites More sharing options...
requinix Posted July 13, 2012 Share Posted July 13, 2012 Alright, need more specific information. 1. What are the actual values of those variables? Only redact the bare minimum, and do that by replacing letters with 'X' and numbers with '0'. 2. Given those redacted values, what is the exact command you need to run? 3. How are you building these values? Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/#findComment-1361429 Share on other sites More sharing options...
salman.isd Posted July 14, 2012 Author Share Posted July 14, 2012 The actual values are too many to be pasted here so I'll try to attach them in txt file here 1,2)The text file contains the exact command i enter on the terminal to run the LMSignature program for verfication.As you can see its quite a big thing with lots of numbers. The main variables you can search it for are (-signature , -verifkey , -hashfunc ) and their respective keys given infront of them. 3)The values are generated by entering (on the terminal) ./LMSignature -keygen 224 ./LMSignature -sign 224 -message= any text -signkey= The above two commands I used in my php script (by using the passthru function) passthru('/host/Crypto/LMSignature -keygen 224') //outputs $verifkey $hashfunc and $signkeys passthru("/host/Crypto/LMSignature -sign 224 -message= msg -signkey= $signkeys") //outputs $signature; and they work fine giving me the correct values which i store for further use. So thats my problem. I have all the -signature , -verifkey , -hashfunc keys stored in my php script but i cant forward them using passthru("/host/Crypto/LMSignature -verify 224 -message= msg -signature= $signature -verifkey= $verifkeys -hashfunc= $hashfunc ") 18660_.txt Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/#findComment-1361440 Share on other sites More sharing options...
salman.isd Posted July 14, 2012 Author Share Posted July 14, 2012 small update: instead of passing variables,if i directly put the values stored in $signature ,$verifkeys and $hashfunc into the following code passthru("/host/Crypto/LMSignature -verify 224 -message= msg -signature= $signature -verifkey= $verifkeys -hashfunc= $hashfunc ") I get my required output. Quote Link to comment https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/#findComment-1361449 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.