Loading ...
Sorry, an error occurred while loading the content.

resetting folder and file permission on an Apache server

Expand Messages
  • Mike Breiding - Morgantown WV
    Greetings Anyone know how to set *all* folder to 755 and *all* file to 644 on and Apache server. One of my sites was hacked and I have thousands of files to
    Message 1 of 17 , Dec 6, 2008
    • 0 Attachment
      Greetings

      Anyone know how to set *all* folder to 755 and *all* file to 644 on and
      Apache server.

      One of my sites was hacked and I have thousands of files to clean-up and
      reset permissions to folders and files.

      Thanks,
      -Mike
    • Axel Berger
      ... Totalcommander Axel
      Message 2 of 17 , Dec 6, 2008
      • 0 Attachment
        Mike Breiding - Morgantown WV wrote:
        > Anyone know how to set *all* folder to 755 and *all* file to 644 on and
        > Apache server.

        Totalcommander

        Axel
      • loro
        ... I think most FTP clients allow you to highlight multiple files and chmod all of them at once. You d still need to open each folder though. If you have
        Message 3 of 17 , Dec 6, 2008
        • 0 Attachment
          Mike Breiding wrote:
          >Anyone know how to set *all* folder to 755 and *all* file to 644 on and
          >Apache server.

          I think most FTP clients allow you to highlight multiple files and
          chmod all of them at once. You'd still need to open each folder
          though. If you have shell access you can do it with command line. I'm
          not going to advice you about how to do that, because I always need
          to look things like that up myself and I think things can go wrong of
          you don't do it right.

          Lotta
        • Don - HtmlFixIt.com
          ... The last time I had to do it I wrote a php script to do it, or maybe it was perl, I don t remember. But you might give total commander a try if it works
          Message 4 of 17 , Dec 6, 2008
          • 0 Attachment
            loro wrote:
            > Mike Breiding wrote:
            >> Anyone know how to set *all* folder to 755 and *all* file to 644 on and
            >> Apache server.
            >
            > I think most FTP clients allow you to highlight multiple files and
            > chmod all of them at once. You'd still need to open each folder
            > though. If you have shell access you can do it with command line. I'm
            > not going to advice you about how to do that, because I always need
            > to look things like that up myself and I think things can go wrong of
            > you don't do it right.
            >
            > Lotta
            >
            The last time I had to do it I wrote a php script to do it, or maybe it
            was perl, I don't remember. But you might give total commander a try if
            it works as prior poster suggested.

            I found this on a quick google search and it seems about right:
            you can make a php script to change all the file permissions. It is
            pretty easy, you just have to cycle through every file in a directory
            and use the chmod command. See http://us3.php.net/chmod for details on
            the codes for chmod.

            CODE

            $path="yourdirectory";
            $dh = opendir($path);
            while ($temp = readdir($dh)) {
            if ($temp!='.' && $temp!='..' && $temp!='.htaccess') chmod($temp,755); }
          • Mike Breiding - Morgantown WV
            Don - HtmlFixIt.com wrote: ... Thanks everyone, but I shoulda know all the answers would be too geeky for me. Because of the number of files involved I
            Message 5 of 17 , Dec 7, 2008
            • 0 Attachment
              Don - HtmlFixIt.com wrote:
              <SNIP>
              >
              > I found this on a quick google search and it seems about right:
              > you can make a php script to change all the file permissions. It is
              > pretty easy, you just have to cycle through every file in a directory
              > and use the chmod command. See http://us3.php net/chmod
              > <http://us3.php.net/chmod> for details on
              > the codes for chmod.
              >
              > CODE
              >
              > $path="yourdirector y";
              > $dh = opendir($path) ;
              > while ($temp = readdir($dh) ) {
              > if ($temp!='.' && $temp!='..' && $temp!='.htaccess' ) chmod($temp, 755); }

              Thanks everyone, but I shoulda know all the answers would be too geeky
              for me.

              Because of the number of files involved I am just going to take the site
              down until I can get it cleaned up.

              I will then set the correct permissions as I upload them again.
              -Mike
            • Mike Breiding - Morgantown WV
              I am now finding files set to 644 which are being defaced by writing drug adds to the bottoms of the files. What can I do!? I will have so many files to clean
              Message 6 of 17 , Dec 7, 2008
              • 0 Attachment
                I am now finding files set to 644 which are being defaced by writing
                drug adds to the bottoms of the files.

                What can I do!?

                I will have so many files to clean I will never get them all done.
                I manage 10 sites. What a mess.

                -Mike
              • Axel Berger
                ... This comes too late for me now, but I build all my sites locally on my Computer at home (more precisely mirrored on two computers for backup) and mirror
                Message 7 of 17 , Dec 7, 2008
                • 0 Attachment
                  Mike Breiding - Morgantown WV wrote:
                  > I will have so many files to clean I will never get them
                  > all done. I manage 10 sites. What a mess.

                  This comes too late for me now, but I build all my sites locally on
                  my Computer at home (more precisely mirrored on two computers for
                  backup) and mirror them to the hosters. This way even a total loss
                  of 10 GB will cost no more than 120 hours solid uninterrupted upload
                  time.

                  On the bright side: All your defacements will have been done by a
                  program and there are sure to be some bits common to them all.
                  NoteTab's <Search Disk> and a little Regex is sure to be up to the
                  task.

                  I have one skeleton clip for just this kind of thing:
                  -------------------------------------------------------------
                  ; Adapt this part to the task in hand
                  ^!Set %varFIL%="F:\Webspace\index.php"
                  ^!Set %varPAT%="*.htm;*.php"
                  ; End of invidual adaptation

                  ^!SetWizardLabel "Please define the files to be converted"
                  ;^!SetDebug On
                  ^!Set %varFIL%=^?{(T=O;F="Source
                  Files|*.html;*.htm;*.?html;*.xml;*asp;*.css;*.php;*.php3;*.php4")Sample
                  file=^%varFIL%}; %varSDR%=^?{(T=L)Include Subdirectories?==_Yes|No};
                  %varPAT%=^?{Search Pattern=^%varPAT%}
                  ^!Set %varPTH%=^$GetPath(^%varFIL%)$
                  ^!If "^%varSDR%"="Yes" yessub ELSE nosub
                  :yessub
                  ^!Set %varFIL%=^$GetFileFirst("+^%varPTH%";"^%varPAT%")$
                  ^!Goto loop
                  :nosub
                  ^!Set %varFIL%=^$GetFileFirst("^%varPTH%";"^%varPAT%")$
                  :loop
                  ^!IfTrue ^$IsEmpty(^%varFIL%)$ finished
                  ;^!Continue ^%varFIL%
                  ^!Open "^%varFIL%"

                  ; Adapt this part to the task in hand

                  ^!Replace "http://www.w3.org/Icons/valid-html401" >>
                  "http://berger-odenthal.de/pics/valid-html401.png" WAS
                  ^!Replace "http://jigsaw.w3.org/css-validator/images/vcss" >>
                  "http://berger-odenthal.de/pics/vcss.png" WAS

                  ;^!Replace "//EN"> <" >> "//EN"^P
                  "http://www.w3.org/TR/html4/loose.dtd">^P<" WAS

                  ; End of invidual adaptation

                  ^!Close ALL,SAVE
                  ^!Set %varFIL%=^$GetFileNext$
                  ^!Goto loop
                  :finished
                  ^!CloseFileFind
                  -------------------------------------------------------------
                  (As ever: beware of long lines)

                  Axel
                • loro
                  ... Come on - my suggestion wasn t geeky. ;-) Lotta
                  Message 8 of 17 , Dec 7, 2008
                  • 0 Attachment
                    Mike wrote:
                    >Thanks everyone, but I shoulda know all the answers would be too geeky
                    >for me.

                    Come on - my suggestion wasn't geeky. ;-)

                    Lotta
                  • Axel Berger
                    ... What do you mean, geeky? Computers are pretty stupid you know. It s a bit like my mother, currently in hospital, trying to explain to me, on the phone,
                    Message 9 of 17 , Dec 7, 2008
                    • 0 Attachment
                      Mike Breiding - Morgantown WV wrote:
                      > Thanks everyone, but I shoulda know all the answers would
                      > be too geeky for me.

                      What do you mean, geeky? Computers are pretty stupid you know. It's
                      a bit like my mother, currently in hospital, trying to explain to
                      me, on the phone, just what housecoat in what shade of pale green
                      (I'm colourblind) to get from what wardrobe. Telling Regex exactly
                      what to find and more importantly what *not* to replace can't be
                      that much harder, can it now?

                      At least your computer is no civil servant, it is not going out of
                      its way to misunderstand you on purpose.

                      Axel
                    • Mike Breiding - Morgantown WV
                      Hi Axel, All the malicious crap is below . Is there a clip I can run to remove all text below that point? Thanks for the help. -Mike ================
                      Message 10 of 17 , Dec 7, 2008
                      • 0 Attachment
                        Hi Axel,

                        All the malicious crap is below </html>.

                        Is there a clip I can run to remove all text below that point?

                        Thanks for the help.
                        -Mike
                        ================

                        Axel Berger wrote:
                        >
                        >
                        > Mike Breiding - Morgantown WV wrote:
                        > > I will have so many files to clean I will never get them
                        > > all done. I manage 10 sites. What a mess.
                        >
                        > This comes too late for me now, but I build all my sites locally on
                        > my Computer at home (more precisely mirrored on two computers for
                        > backup) and mirror them to the hosters. This way even a total loss
                        > of 10 GB will cost no more than 120 hours solid uninterrupted upload
                        > time.
                        >
                        > On the bright side: All your defacements will have been done by a
                        > program and there are sure to be some bits common to them all.
                        > NoteTab's <Search Disk> and a little Regex is sure to be up to the
                        > task.
                        >
                        > I have one skeleton clip for just this kind of thing:
                        > ------------ --------- --------- --------- --------- --------- -
                        > ; Adapt this part to the task in hand
                        > ^!Set %varFIL%="F: \Webspace\ index.php"
                        > ^!Set %varPAT%="*. htm;*.php"
                        > ; End of invidual adaptation
                        >
                        > ^!SetWizardLabel "Please define the files to be converted"
                        > ;^!SetDebug On
                        > ^!Set %varFIL%=^?{ (T=O;F="Source
                        > Files|*.html; *.htm;*.? html;*.xml; *asp;*.css; *.php;*.php3; *.php4")Sample
                        > file=^%varFIL% }; %varSDR%=^?{ (T=L)Include Subdirectories? ==_Yes|No} ;
                        > %varPAT%=^?{ Search Pattern=^%varPAT% }
                        > ^!Set %varPTH%=^$GetPath( ^%varFIL% )$
                        > ^!If "^%varSDR%"= "Yes" yessub ELSE nosub
                        > :yessub
                        > ^!Set %varFIL%=^$GetFileF irst("+^% varPTH%"; "^%varPAT% ")$
                        > ^!Goto loop
                        > :nosub
                        > ^!Set %varFIL%=^$GetFileF irst("^%varPTH% ";"^%varPAT% ")$
                        > :loop
                        > ^!IfTrue ^$IsEmpty(^% varFIL%)$ finished
                        > ;^!Continue ^%varFIL%
                        > ^!Open "^%varFIL%"
                        >
                        > ; Adapt this part to the task in hand
                        >
                        > ^!Replace "http://www.w3. org/Icons/ valid-html401
                        > <http://www.w3.org/Icons/valid-html401>" >>
                        > "http://berger- odenthal. de/pics/valid- html401.png
                        > <http://berger-odenthal.de/pics/valid-html401.png>" WAS
                        > ^!Replace "http://jigsaw. w3.org/css- validator/ images/vcss
                        > <http://jigsaw.w3.org/css-validator/images/vcss>" >>
                        > "http://berger- odenthal. de/pics/vcss. png
                        > <http://berger-odenthal.de/pics/vcss.png>" WAS
                        >
                        > ;^!Replace "//EN"> <" >> "//EN"^P
                        > "http://www.w3. org/TR/html4/ loose.dtd
                        > <http://www.w3.org/TR/html4/loose.dtd>">^P<" WAS
                        >
                        > ; End of invidual adaptation
                        >
                        > ^!Close ALL,SAVE
                        > ^!Set %varFIL%=^$GetFileN ext$
                        > ^!Goto loop
                        > :finished
                        > ^!CloseFileFind
                        > ------------ --------- --------- --------- --------- --------- -
                        > (As ever: beware of long lines)
                        >
                        > Axel
                        >
                        >
                      • Axel Berger
                        ... That s trivial (I hope): Try the following find string as a regular expression choosing ignore case or adjusting that /html to the case you actually use:
                        Message 11 of 17 , Dec 7, 2008
                        • 0 Attachment
                          Mike Breiding - Morgantown WV wrote:
                          > All the malicious crap is below </html>.
                          > Is there a clip I can run to remove all text below that point?

                          That's trivial (I hope):

                          Try the following find string as a regular expression choosing
                          ignore case or adjusting that "/html" to the case you actually use:

                          (?s)</html>.*

                          (meaning "make the dot match line-ends too, find </html> and
                          everything after that") and replace with

                          </html>\n

                          To do that you will have do download everything to one of your
                          drives. So I suggest you keep that copy of everthing up to date from
                          then on.

                          If the above replace has worked as expected on a number of test
                          files you can then use <Search> -> <Search Disk> with
                          "subdirectories" ticked to do all the rest in one big rush. If
                          something were to go wrong you could still download everything a
                          second time or, space permitting, work on one of two local copies.
                          As you're hopefully doing all that just once and never again it's
                          not worth your while to make a clip around it.


                          Axel
                        • Mike Breiding - Morgantown WV
                          ... I am downloading the entire site now - 3.1 gig. At the slow rate it is going it looks like it will take several days. I will then try the clean-up you
                          Message 12 of 17 , Dec 8, 2008
                          • 0 Attachment
                            Axel Berger wrote:
                            >
                            >
                            > Mike Breiding - Morgantown WV wrote:
                            > > All the malicious crap is below </html>.
                            > > Is there a clip I can run to remove all text below that point?
                            >
                            > That's trivial (I hope):
                            >
                            > Try the following find string as a regular expression choosing
                            > ignore case or adjusting that "/html" to the case you actually use:
                            >
                            > (?s)</html>. *
                            >
                            > (meaning "make the dot match line-ends too, find </html> and
                            > everything after that") and replace with
                            >
                            > </html>\n
                            >
                            > To do that you will have do download everything to one of your
                            > drives. So I suggest you keep that copy of everthing up to date from
                            > then on.

                            I am downloading the entire site now - 3.1 gig.
                            At the slow rate it is going it looks like it will take several days.

                            I will then try the clean-up you suggested.
                            Thanks,
                            -Mike
                          • Axel Berger
                            ... No DSL? It ought to be less than eight hours - it s the upload that s really going to take forever. Good luck Axel
                            Message 13 of 17 , Dec 8, 2008
                            • 0 Attachment
                              Mike Breiding - Morgantown WV wrote:
                              > I am downloading the entire site now - 3.1 gig.
                              > At the slow rate it is going it looks like it will take several days.

                              No DSL? It ought to be less than eight hours - it's the upload
                              that's really going to take forever.

                              Good luck
                              Axel
                            • Mike Breiding - Morgantown WV
                              ... Seems to have been a temporary bottle neck which is not unglogged. Thanks, -Mike
                              Message 14 of 17 , Dec 8, 2008
                              • 0 Attachment
                                Axel Berger wrote:
                                >
                                >
                                > Mike Breiding - Morgantown WV wrote:
                                > > I am downloading the entire site now - 3.1 gig.
                                > > At the slow rate it is going it looks like it will take several days.
                                >
                                > No DSL? It ought to be less than eight hours - it's the upload
                                > that's really going to take forever.
                                >
                                > Good luck

                                Seems to have been a temporary bottle neck which is not unglogged.

                                Thanks,
                                -Mike
                              • sisterscape
                                I m curious why you don t have at least one local/backup copy of these files. Then all you would have to do is upload the clean ones. Backup redundancy is
                                Message 15 of 17 , Dec 8, 2008
                                • 0 Attachment
                                  I'm curious why you don't have at least one local/backup copy of these files. Then all you would have to do is upload the clean ones. Backup redundancy is always a good thing IMO. ;)
                                • Mike Breiding - Morgantown WV
                                  ... Why? Because I m a big dummy!! I have most of them, but it is an old site I more or less abandoned. Some changes were made on the server side only and some
                                  Message 16 of 17 , Dec 8, 2008
                                  • 0 Attachment
                                    sisterscape wrote:
                                    >
                                    >
                                    > I'm curious why you don't have at least one local/backup copy of these
                                    > files. Then all you would have to do is upload the clean ones. Backup
                                    > redundancy is always a good thing IMO. ;)

                                    Why?
                                    Because I'm a big dummy!!

                                    I have most of them, but it is an old site I more or less abandoned.
                                    Some changes were made on the server side only and some of the uploaded
                                    pages I have lost track of locally.

                                    Sloppy and careless and now I am paying for it.
                                    -Mike
                                  • Axel Berger
                                    ... Don t be too hard on yourself. What s eight hours between friends? I make that one good night s sleep and everything will look brighter in the morning. If
                                    Message 17 of 17 , Dec 8, 2008
                                    • 0 Attachment
                                      Mike Breiding - Morgantown WV wrote:
                                      > Sloppy and careless and now I am paying for it.

                                      Don't be too hard on yourself. What's eight hours between friends? I
                                      make that one good night's sleep and everything will look brighter
                                      in the morning. If the defacement really is as simple and dumbminded
                                      as you say, the cleaning up will be done in a jiffy and you would
                                      have the upload part on your hands anyway.
                                      Any IT house with a big outside line you might call a favour in
                                      from? That's what old friends from back when are for, isn't it?

                                      Good luck
                                      Axel
                                    Your message has been successfully submitted and would be delivered to recipients shortly.