-
Notifications
You must be signed in to change notification settings - Fork 110
/
Anonymous FTP FAQ.htm
1355 lines (632 loc) · 28.1 KB
/
Anonymous FTP FAQ.htm
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
<HEAD>
<!---SHOWDOWN.ORG--->
<TITLE>Anonymous FTP FAQ</TITLE>
<script type="text/javascript"><!--// <![CDATA[ - Ad Muncher helper script: do not remove without removing all references to this in the below page (eg: everything containing "ywzw", "ywzf" or "ywb")
var ywzwa,ywzwb,ywzwc,ywzwd,ywzwff,ywzwh,ywzwi,ywzwir,ywzwk,ywzwm,ywzwn,rp,ywzwq,ywzws,ywzwv,ywzww,ywzwy,ywzwro,ywzwolp,ywzwqn,ywzwqnbu,ywzwtop,ywzwpld,ywzwplt,ywzwtopt,ywzwagt;ywzwpld=1;ywzwh=1;ywzwk=1;ywzwd=1;ywzww=0;ywzwy=0;ywzwro=0;ywzwi="";ywzwz="http://www.admuncher.com/";
function ywzwps(){eval("ywzwtop="+ywzwtopt+";");};
function ywb(z){if(z.location)return false;else return z.blur();};
function ywzwj(){ywzwps();if(ywzwtop.ywzwolp)ywzwf();return true;};
function ywzf(z){if(z.location)return false;else return z.focus();};
function ywzwf(){ywzwps();ywzwtop.ywzwqn=ywzwtop.ywzwqnbu;ywzwtop.ywzwolp=0;};
function ywzwr(e){ywzwps();if((e&&e.which==1)||(window.event.button==1)){ywzwtop.ywzwqn=1;setTimeout("ywzwtop.ywzwqn=0;",500);};};
function ywzwe(z){ywzwps();ywzwtop.ywzwa=0;ywzwtop.ywzwqnbu=ywzwtop.ywzwqn;ywzwtop.ywzwqn=0;ywzwtop.ywzwolp=1;setTimeout("ywzwtop.ywzwa=1;",5000);ywzwx();if(ywzwh){ywzwh=0;if(ywzwff)ywzwff();};if(z!=7)ywzwf();};
function ywzwx(){ywzwq=""+document.onmousedown;if(!document.onmousedown||!ywzwq||ywzwq.indexOf("ywzwr")!=-1){if(document.layers)document.captureEvents(Event.MOUSEDOWN);document.onmousedown=ywzwr;};ywzwq=""+window.onload;if(!window.onload||!ywzwq||(ywzwq.indexOf("ywzwe")!=-1&&ywzwq.indexOf("ywzwf")==-1))window.onload=ywzwe;};
function ywzwu(a){ywzwps();ywzwtop.ywzwi=ywzwtop.ywzwi.substring(0,1024);while(ywzwtop.ywzwi.indexOf('"')!=-1)ywzwtop.ywzwi=ywzwtop.ywzwi.replace('"',"<~am~`");while(ywzwtop.ywzwi.indexOf("<~am~`")!=-1)ywzwtop.ywzwi=ywzwtop.ywzwi.replace("<~am~`",'\\"');ywzwtop.ywzwir='ywzwtop.defaultStatus="'+ywzwtop.ywzwi+'";';if(!ywzwtop.ywzws){ywzwtop.ywzws=1;setInterval("eval(ywzwtop.ywzwir);",3000);};setTimeout("eval(ywzwtop.ywzwir);",1000);};
function ywzwt(a){ywzwps();if(ywzwtop.ywzwqn||ywzwtop.ywzwa){ywzwtop.ywzwqn=0;return alert(a);};if(a&&ywzwd){ywzwv=a;while(ywzwv.indexOf("\n")!=-1)ywzwv=ywzwv.replace("\n"," ");ywzwtop.ywzwi="Alert message blocked by Ad Muncher: "+ywzwv;ywzwu();};return false;};
function ywzwo(a,b,c,d){ywzwps();ywzwtop.ywzwqn=0;if(!a)a="";if(c){c=c.toLowerCase();while(c.indexOf(" ")!=-1)c=c.replace(" ","");if(ywzww){c=c.replace("height=","xxx=");c=c.replace("width=","xxx=");c=c.replace("top=","xxx=");c=c.replace("left=","xxx=");c=c.replace("screenx=","xxx=");c=c.replace("screeny=","xxx=");};if(ywzwy){c=c.replace("location=","xxx=");c=c.replace("toolbar=","xxx=");c=c.replace("menubar=","xxx=");c=c.replace("resizable=","xxx=");c=c.replace("scrollbars=","xxx=");c=c.replace("status=","xxx=");c=c.replace("titlebar=","xxx=");c=c.replace("fullscreen=","xxx=");c=c.replace("directories=","xxx=");};};if(ywzwy){if(c)c+=",";else c="";c+="location,toolbar,menubar,resizable,scrollbars,status,titlebar,directories";};if(d)return open(a,b,c,d);else if(c)return open(a,b,c);else if(b)return open(a,b);else return open(a);};
function ywzw(a,b,c,d){ywzwps();ywzwagt=navigator.userAgent.toLowerCase();if(ywzwro||ywzwtop.ywzwa||ywzwtop.ywzwqn||typeof(parent.frames[b])=="subwindow"||typeof(parent.frames[b])=="object"||b=="_top"||b=="_self"||b=="_parent"||((ywzwagt.indexOf("msie")!=-1&&ywzwagt.indexOf("opera")==-1)&&(b=="_search"||b=="_media"))){return ywzwo(a,b,c,d);};if(a){ywzwp="/admuncherpopcheck&"+Math.random();ywzwm=new Image();ywzwm.src=a+ywzwp;ywzwm=ywzwm.src.replace(ywzwp,"");ywzwn=ywzwm.toLowerCase();}else{ywzwm="(No URL)";ywzwn=document.URL.toLowerCase();};if(ywzwa==-1||(ywzwn.indexOf(".aol.com/aimexpress")!=-1)||(ywzwn.indexOf(".bcn-hj.com/")!=-1)||(ywzwn.indexOf(".cnn.com/pr/video/")!=-1)||(ywzwn.indexOf(".com/gp/")!=-1&&ywzwn.indexOf(".asp")!=-1&&ywzwn.indexOf("packageid=")!=-1)||(ywzwn.indexOf(".feedroom.com/")!=-1)||(ywzwn.indexOf(".mail.com/templates/common/")!=-1)||(ywzwn.indexOf("//go.icq.com/")!=-1)||(ywzwn.indexOf("/register/register.jsp?")!=-1)||(ywzwn.indexOf("download.com/")!=-1)||(ywzwn.indexOf("ebizautos.com/shared/viewer.cfm")!=-1)||(ywzwn.indexOf("fiv.sp.co.gg")!=-1)||(ywzwn.indexOf("novapal.com/")!=-1&&ywzwn.indexOf(".pdf")!=-1)||(ywzwn.indexOf("pogo.com/arena/game-outerframeset.jsp?")!=-1)||(ywzwn.indexOf("zdnet.com/")!=-1)){return ywzwo(a,b,c,d);};if(ywzwd&&ywzwm){if(ywzwtop.ywzwb){ywzwc="s";ywzwtop.ywzwb+=", "+ywzwm;}else{ywzwc="";ywzwtop.ywzwb=ywzwm;};ywzwtop.ywzwi="Popup"+ywzwc+" on page blocked by Ad Muncher: "+ywzwtop.ywzwb;ywzwu();};return false;};
ywzwx();try{if(top.ywzwpld){top.rplt=1;ywzwtopt="top";}else ywzwtopt="self";}catch(e){ywzwtopt="self";};if(ywzwk)window.onerror=ywzwj;
// ]]>> --></script>
</HEAD>
<BODY>
<H1>Anonymous FTP FAQ</h1>
<i>Version: 3.00</i>
<p>
<h2>How to Set up a Secure Anonymous FTP Site
</h2>
<p>
The following is a FAQ on setting up a secure FTP Site. FTP sites
are known for much abuse by transferring illegal files. They also open many
oppurtunities for intruders to gain access via misconfigured setups. And
lastly many versions of ftp servers have had security holes. This FAQ is
intended to clean up this abuse by allowing administrators to go through this
check list of steps to make sure their FTP is correctly configured and that
they are running the most current ftp daemon.
<p>
This is organized in the following fashion, I am breaking into several parts
as follows:
<br>
<ol>
<li>
<a href = "#general">
General Description of Setting up an "Anonymous" FTP server.
</a>
<li>
<a href = "#chroot">Setting up a chrooted Secure Anonymous FTP server.
</a>
<li>
<a href = "#os">
OS Specific needed information and suggestions.
<ul>
<li>
<a href = "#att">
Older SVR2 and SVR3 system,
RTU 6.0 (Masscomp, now Concurrent Real Time UNIX),
and AT&T 3B1 and 3B2 machines
</a>
<li>
<a href = "#hpux">
HPUX
</a>
<li>
<a href = "#sol">
Solaris 2.x
</a>
<li>
<a href = "#sun">
SunOS
</a>
</ul>
</a>
<li>
<a href = "#other">
Where to get other FTP daemons
</a>
<li>
<a href = "#secure">
How to Know if your Anonymous FTP Server is Secure
</a>
<li>
<a href = "#archie">
Archie
</a>
</ol>
<hr size=5>
<h3>
<a name = "general">
1. General Description of Setting up an "anonymous" ftp server.
</a></h3>
<ol>
<li> Create the user ftp in /etc/passwd. Use a misc group. The user's home
directory will be ~ftp where ~ftp is the root you wish anonymous users to
see. Creating this user turns on anonymous ftp.
<p>
Use an invalid password and user shell for better security. The entry in the
passwd file should look something like:
<blockquote>
ftp:*:400:400:Anonymous FTP:/home/ftp:/bin/true
</blockquote>
<li> Create the home directory ~ftp. Make the directory owned by root (NOT ftp)
with the same group as ftp. Thus, owner permissions are for root and group
permissions are for the anonymous users. Set the permissions for ~ftp to 555
(read, nowrite, execute).
<p>
<b>Warning:</b>
Some MAN pages recommend making the ~ftp directory owned by ftp.
This is a big NO-NO, if you want any type of security on your system.
<p>
<li>Create the directory ~ftp/bin. This directory is owned by root (group
e.g. wheel) with permissions 111 (noread, nowrite, execute).
<p>
<li>Copy the program ls into ~ftp/bin. ls is owned by root with permissions
111 (noread, nowrite, execute). Any other commands you put in ~ftp/bin
should have the same permissions as well.
<p>
<li> Make the directory ~ftp/etc. This directory is owned by root with
permissions 111.
<p>
<li> Create from scratch the files /etc/passwd and /etc/group in ~ftp/etc.
These files should be mode 444. The passwd file should only contain root,
daemon, uucp, and ftp. The group file must contain ftp's group. Use your
/etc/passwd and /etc/group files as a template for creating passwd and group
files going to ~ftp/etc. You may even change the user names in this file,
they are used only for 'ls' command. So for example if all files in your
~ftp/pub/linux hierarchy will be maintained by a real user 'balon' with
uid=156 you may put
<blockquote>
linux:*:156:120:Kazik Balon::
</blockquote>
in the ~ftp/etc/passwd file (regardless of his real username). Leave only
these users who will own files under ftp hierarchy (e.g. root, daemon,
ftp...) and definitely remove *ALL* passwords by replacing them with '*' so
the entry looks like:
<blockquote>
root:*:0:0:Ftp maintainer::
<br>
ftp:*:400:400: Anonymous ftp::
</blockquote>
For more security, you can just remove ~ftp/etc/passwd and
~ftp/etc/group (the effect is that ls -l will not show the directories' group
names). Wuarchive ftp daemon (and some others) have some extensions based on
the contents of the group/passwd files, so read the appropriate documentation.
<p>
<li> Make the directory ~ftp/pub. This directory is owned by you and has the
same group as ftp with permissions 555. On most systems (like SunOS) you may
want to make this directory 2555, ie. set-group-id, in order to create new
files with the same group ownership.
<p>
Files are left here for public distribution. All folders inside ~ftp/pub
should have the same permissions as 555.
<p>
<b>Warning: </b>
Neither the home directory (~ftp) nor any directory below it should be
owned by ftp! No files should be owned by ftp either. Modern ftp daemons
support all kinds of useful commands, such as chmod, that allow outsiders to
undo your careful permission settings. They also have configuration options
like the following (WuFTP) to disable them:
<pre>
# all the following default to "yes" for everybody
delete no guest,anonymous # delete permission?
overwrite no guest,anonymous # overwrite permission?
rename no guest,anonymous # rename permission?
chmod no anonymous # chmod permission?
umask no anonymous # umask permission?
</pre>
<p>
<li> If you wish to have a place for anonymous users to leave files, create
the directory ~ftp/pub/incoming. This directory is owned by root with
permissions 733. Do a 'chmod +t ~ftp/pub/incoming'. The ftp daemon will
normally not allow an anonymous user to overwrite an existing file, but a
normal user of the system would be able to delete anything. By setting the
mode to '1733' you prevent this from happening. In wuftpd you may configure
the daemon to create new files with permissions '600' owned by root or any
other user. Many times, incoming directories are abused by exchanging pirated
and pornographic material. Abusers often create hidden directories there for
this purpose. Making the incoming directory unreadable by anonymous ftp helps
to some extent. With ordinary ftp severs there is no way to prevent
directories being created in incoming. The WUarchive ftp server can limit
uploads to certain directories and can restrict characters used in file names
like this:
<pre>
# specify the upload directory information
upload /var/spool/ftp * no
upload /var/spool/ftp /incoming yes ftp staff 0600 nodirs
# path filters # path-filter...
path-filter anonymous /etc/msgs/pathmsg ^[-A-Za-z0-9_\.]*$ ^\. ^-
path-filter guest /etc/msgs/pathmsg ^[-A-Za-z0-9_\.]*$ ^\. ^-
</pre>
<p>
Suggestion: Create an extra file-system for your ftp-area (or at least for
your incoming-area) to prevent a denial-of-service attack by filling your
disk with garbage (inside your incoming directory).
<p>
If you have wuftpd you may want to add some ftp extensions like
compression/decompression 'on the fly' or creation of tar files for the
directory hierarchies. Get the appropriate sources (gzip, gnutar, compress),
compile them and link statically, put in the ~ftp/bin directory and edit the
appropriate file containing the definitions of the allowed conversions.
/usr/bin/tar is already statically-linked. You may wish to use gnu tar
anyway.
<p>
Gary Mills wrote a small program to support the following:
<p>
To do tar and compress, he wrote a tiny program called `pipe', and
statically-linked it. His /etc/ftpconversions file looks like this:
<pre>
#strip prefix:strip postfix:addon prefix:addon postfix:external command:
#types:options:description
:.Z: : :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
:-z: : :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
: : :.Z:/bin/compress -c %s:T_REG:O_COMPRESS:COMPRESS
: : :.tar:/bin/tar cf - %s:T_REG|T_DIR:O_TAR:TAR
: : :.tar.Z:/bin/pipe /bin/tar cf - %s | /bin/compress -c:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
: : :.tar:/bin/gtar -c -f - %s:T_REG|T_DIR:O_TAR:TAR
: : :.tar.Z:/bin/gtar -c -Z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
: : :.tar.gz:/bin/gtar -c -z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+GZIP
</pre>
Here it is: <p>
-----------------8<-------------cut---------------
<pre>
/* pipe.c: exec two commands in a pipe */
#define NULL (char *)0
#define MAXA 16
main(argc, argv) int argc; char *argv[]; {
char *av1[MAXA], *av2[MAXA];
int i, n, p[2], cpid;
i = 0; n = 0;
while ( ++i < argc && n < MAXA ) {
if ( *argv[i] == '|' && *(argv[i]+1) == '\0' ) break;
av1[n++] = argv[i];
}
if ( n == 0 ) uexit();
av1[n] = NULL;
n = 0;
while ( ++i < argc && n < MAXA )
av2[n++] = argv[i];
if ( n == 0 ) uexit();
av2[n] = NULL;
if ( pipe(p) != 0 ) exit(1);
if ( ( cpid = fork() ) == (-1) ) exit(1);
else if ( cpid == 0 ) {
(void)close(p[0]);
(void)close(1);
(void)dup(p[1]);
(void)close(p[1]);
(void)execv(av1[0], av1);
_exit(127);
}
else {
(void)close(p[1]);
(void)close(0);
(void)dup(p[0]);
(void)close(p[0]);
(void)execv(av2[0], av2);
_exit(127);
}
/*NOTREACHED*/
}
uexit() {
(void)write(2, "Usage: pipe <command> | <command>\n", 34);
exit(1);
}
</pre>
-------- CUT HERE ------------
<p>
<li> Other things to do:
<p>
as root:
<blockquote>
touch ~ftp/.rhosts
<br>
touch ~ftp/.forward
<br>
chmod 400 ~ftp/.rhosts
<br>
chmod 400 ~ftp/.forward
</blockquote>
ie. make these files zero-length and owned by root.
<p>
Due to the last /bin/mail bugs in SunOS:
<blockquote>
touch /usr/spool/mail/ftp; chmod 400 /usr/spool/mail/ftp
</blockquote>
Consider an email-alias for the ftp-admin(s) to provide an email-address for
problems-reports.
<p>
If you are mounting some disks from other machines (or even your own) to the
~ftp hierarchy, mount it read-only. The correct entry for the /etc/fstab (on
the host with ftpd) is something like:
<blockquote>
other:/u1/linux /home/ftp/pub/linux nfs ro,noquota,nosuid,intr,bg 1 0
</blockquote>
This mounts under /home/ftp/pub/linux the disk from host 'other' with no
quota, no 'suid' programs (just in case), interruptible (in case 'other'
goes down) and 'bg' - so if 'other' is down when you reboot it will not stop
you trying to mount /home/ftp/pub/linux all over again.
</ol>
<hr size=5>
<h3>
<a name = "chroot">
2. Setting up a chrooted Secure Anonymous ftp server.
</a></h2>
This part was contributed by Marcus J Ranum <[email protected]>
<ol>
<li>Build a statically linked version of ftpd and put it in ~ftp/bin.
Make sure it's owned by root.
<p><li>
Build a statically linked version of /bin/ls if you'll need one.
Put it in ~ftp/bin. If you are on a Sun, and need to build
one, there's a ported version of the BSD net2 ls command
for SunOs on ftp.tis.com: pub/firewalls/toolkit/patches/ls.tar.Z
Make sure it's owned by root.
<p>
<li> Chown ~ftp to root and make it mode 755 THIS IS VERY IMPORTANT
<p>
<li> Set up copies of ~ftp/etc/passwd and ~ftp/etc/group just as you would normally, EXCEPT make 'ftp's home directory '/' -- make sure
they are owned by root.
<p>
<li> Write a wrapper to kick ftpd off and install it in /etc/inetd.conf
The wrapper should look something like: (assuming ~ftp = /var/ftp)
<pre>
main()
{
if(chdir("/var/ftp")) {
perror("chdir /var/ftp");
exit(1);
}
if(chroot("/var/ftp")) {
perror("chroot /var/ftp");
exit(1);
}
/* optional: seteuid(FTPUID); */
execl("/bin/ftpd","ftpd","-l",(char *)0);
perror("exec /bin/ftpd");
exit(1);
}
</pre>
Options:
<p>
You can use 'netacl' from the toolkit or tcp_wrappers to achieve
the same effect.
<p>
We use 'netacl' to switch so that a few machines that connect to
the FTP service *don't* get chrooted first. This makes transferring
files a bit less painful.
<p>
You may also wish to take your ftpd sources and find all the places
where it calls seteuid() and remove them, then have the wrapper do
a setuid(ftp) right before the exec. This means that if someone
knows a hole that makes them "root" they still won't be. Relax and
imagine how frustrated they will be.
<p>
If you're hacking ftpd sources, I suggest you turn off a bunch of
the options in ftpcmd.y by unsetting the "implemented" flag in
ftpcmd.y. This is only practical if your FTP area is read-only.
<p><li>
As usual, make a pass through the FTP area and make sure that the files
are in correct modes and that there's nothing else in there that
can be executed.
<p>
<li>
Note, now, that your FTP area's /etc/passwd is totally separated from
your real /etc/passwd. This has advantages and disadvantages.
<p>
<li> Some stuff may break, like syslog, since there is no /dev/log. Either
build a version of ftpd with a UDP-based syslog() routine or
run a second syslogd based on the BSD Net2 code, that maintains
a unix-domain socket named ~ftp/dev/log with the -p flag.
<p>
REMEMBER:
<p>
If there is a hole in your ftpd that lets someone get "root"
access they can do you some damage even chrooted. It's just
lots harder. If you're willing to hack some code, making the
ftpd run without permissions is a really good thing. The
correct operation of your hacked ftpd can be verified by
connecting to it and (while it's still at the user prompt)
do a ps-axu and verify that it's not running as root.
</ol>
<hr size=5>
<h3>
<a name = "os">
3. OS Specific needed information and suggestions.
</a></h3>
These machines may need dev/tcp:
<ul>
<a name = "att">
<li>Older SVR2 and SVR3 system
<li> RTU 6.0 (Masscomp, now Concurrent Real Time UNIX),
<li>AT&T 3B1 and 3B2 machines
<p>
</ul>
<h4>
[dev/tcp]
</h4>
These ftpd implementations may require a ~ftp/dev/tcp in order for anonymous
ftp to work.
<p>
You have to create a character special device with the appropriate major and
minor device numbers. The appropriate major and minor numbers of ~ftp/dev/tcp
are what the major and minor numbers of /dev/tcp are.
<p>
The ~ftp/dev is a directory and ~ftp/dev/tcp is a character special device.
Make them owned and grouped by root. Permissions for ~ftp/dev is root
read/write/exec and other & group read and exec. The permissions for
~ftp/dev/tcp is root read/write, other & group read.
<p>
<h4>
<a name = "hpux">
HPUX
</h4>
<i>[Logging]
</i>
If you're using HP's native ftpd, the line in /etc/inetd.conf
should execute ftpd -l, which does extra logging.
<h4>
<a name = "sol"> Solaris 2.x
</h4>
<i>[Script]
</i> Solaris' man page contains a script for installing anonymous ftpd
which saves time. You may still want to check over your anonymous ftpd
for vulnerabilities.
<p>
Command for reading the man page is:
<blockquote>
$ man ftpd
</blockquote>
<h4>
<a name = "sun">
SunOS
</h4>
<i>[Libraries]
</i>
To set up SunOS to use its shared dynamic libraries, follow these
steps:
<ol>
<li> Create the directory ~ftp/usr. This directory is owned by root with
permissions 555.
<p>
<li>
Create the directory ~ftp/usr/lib. This directory is owned by root with
permissions 555.
<p>
<li>
Copy the runtime loader ld.so into ~ftp/usr/lib for use by ls. ld.so is
owned by root with permissions 555.
<p>
<li>
Copy the latest version of the shared C library, libc.so.* into
~ftp/usr/lib for use by ls.
<p>
libc.so.* is owned by root with permissions 555.
<p>
Note:
4.1.2(or above) users: you also need to copy /usr/lib/libdl.so.* to
~ftp/lib.
<p><li>
Create the directory ~ftp/dev. This directory is owned by root with
permissions 111.
<p><li>
~ftp/dev/zero is needed by the runtime loader. Move into the directory
~ftp/dev and create it with the command:
<blockquote>
mknod zero c 3 12
</blockquote>
chown ~ftp/dev/zero to root. Make sure it's readable.
<p>
Warning:
For novices: Don't try to copy /dev/zero to ~ftp/dev/zero!
This is an endless file of zeroes and it will completely fill your filesystem!