Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/265642-problem-with-passthru-in-php/
Share on other sites

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);

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

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.

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 ,

 

 

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?

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 :P 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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.