Using GnuPG via exec() on Win2k

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WebScott

    Using GnuPG via exec() on Win2k

    I am trying to run GnuPG encrypt and decrypt functions from a PHP
    script on a Win2k machine. I have tried several variations to no
    avail. Basically what I want to be able to do is something like this:

    <?php
    $cmdStr = 'C:\\GnuPG\\gpg -r recipient --encrypt file2encrypt.tx t';
    exec($cmdStr);
    ?>

    Has anyone had any success with this?

    Scott

  • Chris Newey

    #2
    Re: Using GnuPG via exec() on Win2k

    In article <1115694315.226 973.9200@z14g20 00cwz.googlegro ups.com>,
    scott@webscott. com says...[color=blue]
    > I am trying to run GnuPG encrypt and decrypt functions from a PHP
    > script on a Win2k machine. I have tried several variations to no
    > avail. Basically what I want to be able to do is something like this:
    >
    > <?php
    > $cmdStr = 'C:\\GnuPG\\gpg -r recipient --encrypt file2encrypt.tx t';
    > exec($cmdStr);
    > ?>
    >
    > Has anyone had any success with this?
    >
    > Scott
    >
    >[/color]
    Might be nice if you told us what the problem is

    Comment

    • Chris Newey

      #3
      Re: Using GnuPG via exec() on Win2k

      In article <1115694315.226 973.9200@z14g20 00cwz.googlegro ups.com>,
      scott@webscott. com says...[color=blue]
      > I am trying to run GnuPG encrypt and decrypt functions from a PHP
      > script on a Win2k machine. I have tried several variations to no
      > avail. Basically what I want to be able to do is something like this:
      >
      > <?php
      > $cmdStr = 'C:\\GnuPG\\gpg -r recipient --encrypt file2encrypt.tx t';
      > exec($cmdStr);
      > ?>
      >
      > Has anyone had any success with this?
      >
      > Scott
      >
      >[/color]
      Might be nice if you told us what the problem is

      Comment

      • WebScott

        #4
        Re: Using GnuPG via exec() on Win2k

        If I try running the code, I get no errors or warnings, but also no
        results. Basically, it runs, but does nothing.

        Comment

        • Daniel Tryba

          #5
          Re: Using GnuPG via exec() on Win2k

          WebScott <scott@webscott .com> wrote:[color=blue]
          > If I try running the code, I get no errors or warnings, but also no
          > results.[/color]

          How do you know that?
          [color=blue]
          > Basically, it runs, but does nothing.[/color]

          You did check the exit code?

          Many things can go wrong here, eg:
          -input file is not readable.
          -receipent is unknown
          -output file already exists
          -output file is not writable (IMHO most likely)

          Comment

          • WebScott

            #6
            Re: Using GnuPG via exec() on Win2k

            Let me rephrase the question:

            I want to encrypt a text file, which could contain a credit card number
            or other sensitive information, using GnuPG. If I launch a command
            prompt, I can do it by typing "c: & cd \Program Files\GnuPGExch & gpg
            -r recipientkey --encrypt fakeCC.txt".

            IUSR has modify access on the GnuPGExch folder. What do I need to do
            to have PHP run the same command I used at the command prompt?

            Comment

            • Daniel Tryba

              #7
              Re: Using GnuPG via exec() on Win2k

              WebScott <scott@webscott .com> wrote:[color=blue]
              > I want to encrypt a text file, which could contain a credit card number
              > or other sensitive information, using GnuPG. If I launch a command
              > prompt, I can do it by typing "c: & cd \Program Files\GnuPGExch & gpg
              > -r recipientkey --encrypt fakeCC.txt".[/color]

              So when you try this from php, what is the return value of gpg?
              [color=blue]
              > IUSR has modify access on the GnuPGExch folder. What do I need to do
              > to have PHP run the same command I used at the command prompt?[/color]

              1) nothing is being modified, above command creates a new file, AFAIK
              with NT ACLs create!=modify
              2) where does gpg store the its keys? On any system I used so far (win32
              is not one of them), it's in the users homedir. In this case that
              would be IUSR.

              You need to run the program in such a way you get _all_ output: stdout
              and stderr and the exitcode.

              I use http://tmp.tryba.nl/clearsign.phps to sign an arbitrary string
              with gpg, the returned array might tell you more about what's going
              wrong (don't forget to include sufficient -v options to gpg).

              BTW you shouldn't be storing the CC number on disk in an unencrypted
              file at all if you are so concerned with security. Simply deleting the
              unencrypted file is not enough (and securly wiping files on a journaled
              filesystem might be very tricky). Use gpgs capability to encrypt from
              stdin instead.

              Comment

              • WebScott

                #8
                Re: Using GnuPG via exec() on Win2k

                Thanks, Daniel.

                I'll see if I can make it work on Windows.

                Comment

                Working...