IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類(lèi)|軟件專(zhuān)題|手機(jī)版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當(dāng)前所在位置: 首頁(yè)服務(wù)器FTP服務(wù)器 → 讓Proftpd 的數(shù)據(jù)庫(kù)模塊支持MD5驗(yàn)證

讓Proftpd 的數(shù)據(jù)庫(kù)模塊支持MD5驗(yàn)證

時(shí)間:2015-06-28 00:00:00 來(lái)源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(0)

??? 這個(gè)是筆者對(duì)論壇主機(jī)的FTP服務(wù)進(jìn)行注冊(cè)用戶(hù)驗(yàn)證,論壇采用的是VBB,看了看VBB的密碼加密方式,MD5,F(xiàn)AINT。

??? PROFTPD的MOD_SQL模塊并不支持MD5。VBB是直接調(diào)用MYSQL的MD5()函數(shù)進(jìn)行密碼加密。怎么辦?HACK!筆者用的PROFTPD是最新的Proftpd 1.2.8,mod_sql 版本是 4.10,查了一下 mod_sql.c 文件,發(fā)現(xiàn)增加一種驗(yàn)證方式還是很簡(jiǎn)單的,當(dāng)然這個(gè)要?dú)w功mod_sql.c的程序架構(gòu)設(shè)計(jì)得不錯(cuò)。

??? 下面是筆者修改后得mod_sql.c的部分代碼,有中文的地方是筆者加的。

 

<center id="ssmqu"><tbody id="ssmqu"></tbody></center>
    #include "conf.h" #include "privs.h" #include "mod_sql.h" #define _MOD_VERSION "mod_sql/4.10" #ifdef HAVE_CRYPT_H #include #endif #ifdef HAVE_LIMITS_H #include #endif /**************/ /* 引入md5頭文件 */ #include /**************/ /* Uncomment the following define to allow OpenSSL hashed password checking; * you@#ll also need to link with OpenSSL@#s crypto library ( -lcrypto ) */ /* #define HAVE_OPENSSL */ #ifdef HAVE_OPENSSL #include #endif /* default information for tables and fields */ #define MOD_SQL_DEF_USERTABLE "users" #define MOD_SQL_DEF_USERNAMEFIELD "userid" #define MOD_SQL_DEF_USERUIDFIELD "uid" #define MOD_SQL_DEF_USERGIDFIELD "gid" #define MOD_SQL_DEF_USERPASSWORDFIELD "password" #define MOD_SQL_DEF_USERSHELLFIELD "shell" #define MOD_SQL_DEF_USERHOMEDIRFIELD "homedir" #define MOD_SQL_DEF_GROUPTABLE "groups" #define MOD_SQL_DEF_GROUPNAMEFIELD "groupname" #define MOD_SQL_DEF_GROUPGIDFIELD "gid" #define MOD_SQL_DEF_GROUPMEMBERSFIELD "members" /* default minimum id / default uid / default gid info. * uids and gids less than MOD_SQL_MIN_USER_UID and * MOD_SQL_MIN_USER_GID, respectively, get automatically * mapped to the defaults, below. These can be * overridden using directives */ #define MOD_SQL_MIN_USER_UID 999 #define MOD_SQL_MIN_USER_GID 999 #define MOD_SQL_DEF_UID 65533 #define MOD_SQL_DEF_GID 65533 #define MOD_SQL_BUFSIZE 32 /* Named Query defines */ #define SQL_SELECT_C "SELECT" #define SQL_INSERT_C "INSERT" #define SQL_UPDATE_C "UPDATE" #define SQL_FREEFORM_C "FREEFORM" /* authmask defines */ #define SQL_AUTH_USERS (1<<0) #define SQL_AUTH_GROUPS (1<<1) #define SQL_AUTH_USERS_DEFINITIVE (1<<2) #define SQL_AUTH_GROUPS_DEFINITIVE (1<<3) #define SQL_AUTH_USERSET (1<<4) #define SQL_AUTH_GROUPSET (1<<5) #define SQL_FAST_USERSET (1<<6) #define SQL_FAST_GROUPSET (1<<7) #define SQL_GROUPS (cmap.authmask & SQL_AUTH_GROUPS) #define SQL_USERS (cmap.authmask & SQL_AUTH_USERS) #define SQL_GROUPSET (cmap.authmask & SQL_AUTH_GROUPSET) #define SQL_USERSET (cmap.authmask & SQL_AUTH_USERSET) #define SQL_FASTGROUPS (cmap.authmask & SQL_FAST_GROUPSET) #define SQL_FASTUSERS (cmap.authmask & SQL_FAST_USERSET) #define SQL_GROUPGOD (cmap.authmask & SQL_AUTH_GROUPS_DEFINITIVE) #define SQL_USERGOD (cmap.authmask & SQL_AUTH_USERS_DEFINITIVE) /* * externs, function signatures.. whatever necessary to make * the compiler happy.. */ extern pr_response_t *resp_list,*resp_err_list; static char *_sql_where(pool *p, int cnt, ...); MODRET cmd_getgrent(cmd_rec *); MODRET cmd_setgrent(cmd_rec *); pool *sql_pool; /* * cache typedefs */ #define CACHE_SIZE 13 typedef struct cache_entry { struct cache_entry *list_next; struct cache_entry *bucket_next; void *data; } cache_entry_t; /* this struct holds invariant information for the current session */ static struct { /* * info valid after getpwnam */ char *authuser; /* current authorized user */ struct passwd *authpasswd; /* and their passwd struct */ /* * generic status information */ int status; /* is mod_sql on? */ int authmask; /* authentication mask. * see set_sqlauthenticate for info */ /* * user table and field information */ char *usrtable; /* user info table name */ char *usrfield; /* user name field */ char *pwdfield; /* user password field */ char *uidfield; /* user uid field */ char *gidfield; /* user gid field */ char *homedirfield; /* user homedir field */ char *shellfield; /* user login shell field */ char *userwhere; /* users where clause */ /* * group table and field information */ char *grptable; /* group info table name */ char *grpfield; /* group name field */ char *grpgidfield; /* group gid field */ char *grpmembersfield; /* group members field */ char *groupwhere; /* groups where clause */ /* * other information */ array_header *authlist; /* auth handler list */ char *defaulthomedir; /* default homedir if no field specified */ int buildhomedir; /* create homedir if it doesn@#t exist? */ uid_t minid; /* users UID must be this or greater */ uid_t minuseruid; /* users UID must be this or greater */ gid_t minusergid; /* users UID must be this or greater */ uid_t defaultuid; /* default UID if none in database */ gid_t defaultgid; /* default GID if none in database */ cache_entry_t *curr_group; /* next group in group array for getgrent */ cache_entry_t *curr_passwd; /* next passwd in passwd array for getpwent */ int group_cache_filled; int passwd_cache_filled; unsigned char negative_cache; /* cache negative as well as positive lookups */ /* * mod_ratio data -- someday this needs to be removed from mod_sql */ char *sql_fstor; /* fstor int(11) NOT NULL DEFAULT @#0@#, */ char *sql_fretr; /* fretr int(11) NOT NULL DEFAULT @#0@#, */ char *sql_bstor; /* bstor int(11) NOT NULL DEFAULT @#0@#, */ char *sql_bretr; /* bretr int(11) NOT NULL DEFAULT @#0@#, */ char *sql_frate; /* frate int(11) NOT NULL DEFAULT @#5@#, */ char *sql_fcred; /* fcred int(2) NOT NULL DEFAULT @#15@#, */ char *sql_brate; /* brate int(11) NOT NULL DEFAULT @#5@#, */ char *sql_bcred; /* bcred int(2) NOT NULL DEFAULT @#150000@#, */ /* * precomputed strings */ char *usrfields; char *grpfields; } cmap; /* * cache functions */ typedef unsigned int ( * val_func ) ( const void * ); typedef int ( * cmp_func ) ( const void *, const void * ); typedef struct { /* memory pool for this object */ pool *pool; /* cache buckets */ cache_entry_t *buckets[ CACHE_SIZE ]; /* cache functions */ val_func hash_val; cmp_func cmp; /* list pointers */ cache_entry_t *head; /* list size */ unsigned int nelts; } cache_t; cache_t *group_name_cache; cache_t *group_gid_cache; cache_t *passwd_name_cache; cache_t *passwd_uid_cache; static cache_t *make_cache( pool *p, val_func hash_val, cmp_func cmp ) { cache_t *res; if ( ( p == NULL ) || ( hash_val == NULL ) || ( cmp == NULL ) ) return NULL; res = ( cache_t * ) pcalloc( p, sizeof( cache_t ) ); res->pool = p; res->hash_val = hash_val; res->cmp = cmp; res->head = NULL; res->nelts = 0; return res; } static cache_entry_t *cache_addentry( cache_t *cache, void *data ) { cache_entry_t *entry; int hashval; if ( ( cache == NULL ) || ( data == NULL ) ) return NULL; /* create the entry */ entry = ( cache_entry_t * ) pcalloc( cache->pool, sizeof( cache_entry_t ) ); entry->data = data; /* deal with the list */ if ( cache->head == NULL ) { cache->head = entry; } else { entry->list_next = cache->head; cache->head = entry; } /* deal with the buckets */ hashval = cache->hash_val( data ) % CACHE_SIZE; if ( cache->buckets[ hashval ] == NULL ) { cache->buckets[ hashval ] = entry; } else { entry->bucket_next = cache->buckets[ hashval ]; cache->buckets[ hashval ] = entry; } cache->nelts++; return entry; } static void *cache_findvalue( cache_t *cache, void *data ) { cache_entry_t *entry; int hashval; if ( ( cache == NULL ) || ( data == NULL ) ) return NULL; hashval = cache->hash_val( data ) % CACHE_SIZE; entry = cache->buckets[ hashval ]; while ( entry != NULL ) { if ( cache->cmp

    關(guān)鍵詞標(biāo)簽:

    相關(guān)閱讀

    文章評(píng)論
    發(fā)表評(píng)論

    熱門(mén)文章 Linux下FTP的配置與應(yīng)用 Linux下FTP的配置與應(yīng)用 什么是ftp及ftp服務(wù)器 什么是ftp及ftp服務(wù)器 FTP出錯(cuò)解決和分析 FTP出錯(cuò)解決和分析 Windows內(nèi)置FTP服務(wù)器高級(jí)配置 Windows內(nèi)置FTP服務(wù)器高級(jí)配置

    相關(guān)下載

      人氣排行 vsftp配置大全---超完整版 IIS6.0打造FTP服務(wù)器完全圖文詳解 使用Win 2003搭建安全文件服務(wù)器 圖解Windows xp—FTP服務(wù)器配置 linux服務(wù)samba的詳細(xì)配置 在Windows 2003下搭建FTP服務(wù)器 FTP登陸錯(cuò)誤詳解 Windows內(nèi)置FTP服務(wù)器高級(jí)配置