Ceci & Tati

Gentoo proftpd + mysql + clamav + phpnuke

от на ное..18, 2007, категории Линукс

1. Инсталиране на ClamAV:

emerge -pv clamav
[ebuild R ] app-antivirus/clamav-0.91.2 USE=“bzip2 crypt nls -mailwrapper -milter (-selinux) (-logrotate%*)“
emerge clamav
rc-update add clamd default
/etc/init.d/clamd start

2. Инсталиране на ProFTPd:

emerge -pv proftpd
[ebuild R ] net-ftp/proftpd-1.3.1_rc2-r3 USE=“clamav ipv6 ldap mysql ncurses nls opensslcrypt pam radius ssl tcpd xinetd -acl -authfile -hardened -ifsession -noauthunix -postgres -rewrite (-selinux) -shaper -sitemisc -softquota -vroot“
ebuild /usr/portage/net-ftp/proftpd/proftpd-1.3.1_rc2-r3.ebuild fetch

#patch file: /usr/portage/distfiles/mod_clamav_new.c

– modules/mod_clamav.c.orig Sat Sep 29 15:34:01 2007
+++ modules/mod_clamav.c Mon Oct 1 17:34:04 2007
@@ -157,6 +157,7 @@
c = find_config(CURRENT_CONF, CONF_PARAM, „ClamWarn“, TRUE);

/* Figure out the full path */
+#if 0
if(session.chroot_path) {
sstrncpy(fullpath, strcmp(pr_fs_getvwd(), „/“) ?
pdircat(cmd->tmp_pool, session.chroot_path, pr_fs_getvwd(), NULL) :
@@ -164,6 +165,9 @@
} else {
sstrncpy(fullpath, pr_fs_getcwd(), 4096);
+ sstrncpy(fullpath, pdircat(cmd->tmp_pool, session.chroot_path, NULL, NULL), 4096);
sstrcat(fullpath, „/“, 4096 – strlen(fullpath));
sstrcat(fullpath, cmd->arg, 4096 – strlen(fullpath));

ebuild /usr/portage/net-ftp/proftpd/proftpd-1.3.1_rc2-r3.ebuild digest
emerge proftpd

Пача се слага защото mod_clamav/0.4 има проблем с chroot+Far.

mod_clamav/0.4: error: „/home/ftp/incoming//incoming/test.com: lstat() failed. ERROR“

3. Настройки на ProFTPd:
3.1 Добавяне на потребител и група.

echo „ftpgroup:x:5500:ftpuser“ >> etc/group
echo „ftpuser:x:5500:5500::/home:“ >> /etc/passwd

3.2 Конфигурационен файл.

ServerName „Proftpd Server“
ServerType Standalone
#ServerType inetd
ServerAdmin stephen@khoosys.net

# Hide as much as possible to outside users
ServerIdent on „Welcome to the FTP server. Please login…“
DeferWelcome on

DefaultServer on

UseReverseDNS off
IdentLookups off

SystemLog /var/log/proftpd.log
TransferLog /var/log/xferlog

PassivePorts 1050 1051 1052 1053

# Allow FTP resuming.
# Remember to set to off if you have an incoming ftp for upload.
AllowStoreRestart on

# Port 21 is the standard FTP port.
Port 21

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022

# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30

# Set the user and group under which the server will run.
User nobody
Group nogroup

# To cause every FTP user to be „jailed“ (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~

# Normally, we want files to be overwriteable.

AllowOverwrite on

# The passwords in MySQL are encrypted using CRYPT
# SQLAuthTypes Plaintext Crypt
SQLAuthTypes OpenSSL Crypt
SQLAuthenticate users* groups*

# used to connect to the database
# databasename@host database_user user_password
SQLConnectInfo nuke@localhost root passworda

# Here we tell ProFTPd the names of the database columns in the „usertable“
# we want it to interact with. Match the names with those in the db
SQLUserInfo nuke_users username user_password ftp_uid ftp_gid ftp_homedir ftp_shell

# Here we tell ProFTPd the names of the database columns in the „grouptable“
# we want it to interact with. Again the names match with those in the db
SQLGroupInfo nuke_ftpgroups groupname gid members

# set min UID and GID – otherwise these are 999 each
SQLMinID 500

# create a user’s home directory on demand if it doesn’t exist
# SQLHomedirOnDemand on
CreateHome on 755

# Update count every time user logs in
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE „count=count+1, accessed=now() WHERE userid=’%u'“ ftpuser

# Update modified everytime user uploads or deletes a file
SQLLog STOR,DELE modified
SQLNamedQuery modified UPDATE „modified=now() WHERE userid=’%u'“ ftpuser

<IfModule mod_clamav.c>
ClamAV on
# ClamWarn on
ClamLocalSocket /var/run/clamav/clamd.sock

<Limit LOGIN>
Order allow,deny
Allow from 192.168.
Deny from all

<Anonymous ~ftpuser>
RequireValidShell off
User ftpuser
Group ftpgroup
# We want clients to be able to login with „anonymous“ as well as „ftp“
UserAlias anonymous ftpuser

# Limit the maximum number of anonymous logins
MaxClients 100

# We want ‘welcome.msg’ displayed at login, and ‘.message’ displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayChdir .message

# Limit WRITE everywhere in the anonymous chroot
<Limit WRITE>

<Limit LOGIN>

RootLogin off
RequireValidShell off

4. Промяна на PHP-Nuke-7.5:
Приемаме че вече PHP-Nuke е работил! При мен то се намира в:
4.1 Променя се криптацията на паролите на потребителите в PHP-Nuke.

#редактиране на /var/www/localhost/htdocs/modules/Your_Account/admin/index.php
#$cpass = md5($chng_pass);
# Намира ме горния ред и го коментираме, след което добавяме долния ред.
$cpass = „{md5}“.base64_encode(pack(„H*“, md5($chng_pass)));

4.2 Добавяне на лична папка на всеки потребител.

#редактиране на /var/www/localhost/htdocs/modules/Your_Account/admin/index.php
$sql = „insert into “ . $user_prefix . „_users „;
#Намирате горепосочения ред, коментирате следващите два реда и добавяте долупосочените два реда
$sql .= „(user_id,name,username,user_email,femail,user_website,user_regdate,user_icq,
user_avatar,user_sig,user_password,newsletter,broadcast,popmeson,ftp_homedir,ftp_shell) „
$sql .= „values (NULL,’$add_name’,’$add_uname’,’$add_email’,’$add_femail’,’$add_url’,

5. Добавяне на четири реда „ftp_uid ftp_gid ftp_homedir ftp_shell“ в таблицата „nuke_users“ на базата данни „nuke“:

ALTER TABLE nuke_users ADD `ftp_uid` smallint(6) NOT NULL default ‘5500’;
ALTER TABLE nuke_users ADD `ftp_gid` smallint(6) NOT NULL default ‘5500’;
ALTER TABLE nuke_users ADD `ftp_homedir` varchar(255) default NULL;
ALTER TABLE nuke_users ADD `ftp_shell` varchar(255) default NULL;

Чрез добавянето на тези редове в таблицата „nuke_users“ автоматично потребителя се регистриране в портала и в ftp сървъра.

Папката на дадения потребител се създава автоматично при първото му логване в ftp сървъра!
Антивирусната програма сканира само входящия трафик. Това ще рече че системата се товари при „upload“, а не при „download“!

Вашият коментар

За да докажете че не сте бот, въведете този код
Anti-Spam Image

Нещто не намирате ли?

Потърси в блога ми:

Моля Ви не прекалявайте с информацията!