SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to extract password protected zip files

    Hi,

    A website of mine receives updates from the client in a zip file. I can open and process this fine but they are now insisting that the file is password protected, which is a bit of a problem. I can do something like the following:

    PHP Code:
    echo shell_exec('unzip -P password file.zip'); 
    but as the server is running IIS this throws up a permissions error. Apparently we need to "give the Internet Guest Account (a.k.a. IUSR_MachineName or simply IUSR) read and execute permission to the command shell program, cmd.exe."

    So, two questions:

    1. Are there any third-party apps/plugins/etc that will allow me to unzip password protected files? (I'm running PHP5 on a Windows server)
    2. What are the security risks in giving read and execute permissions to cmd.exe?


    Any help would be gratefully received!

    Martin.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, i'm sort of getting somewhere. By using proc_open I can run unzip without cmd.exe being involved but I get the following error:

    Code:
    error:  cannot create C:/Home/.../www/zip/file.txt
    Anyone got any ideas on that one? I'm thinking it might be a permissions issue on the folder maybe?

  3. #3
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,638
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I'd look for a library that you can access from PHP rather than piping it through the shell. I know .NET has some native compression stuff you could call from PHP via .NET interop, but there is probably something more PHP specific that would be easier to wire in.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Do you mean a zip library? If so I've found a few but none of them will process password-protected archives, hence the reason I've had to resort to using the shell. I'll have a look at the .net option though.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •