diff options
-rw-r--r-- | mbbsd/menu.c | 5 | ||||
-rw-r--r-- | mbbsd/user.c | 54 | ||||
-rw-r--r-- | sample/pttbbs.conf | 4 |
3 files changed, 60 insertions, 3 deletions
diff --git a/mbbsd/menu.c b/mbbsd/menu.c index ad11a72a..247f515b 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -413,6 +413,7 @@ static const commands_t userlist[] = { #ifdef DEBUG int _debug_check_keyinput(); +int _debug_testregcode(); #endif /* XYZ tool menu */ @@ -437,7 +438,9 @@ static const commands_t xyzlist[] = { {x_user100 ,0, "UUsers 《使用者百大排行榜》"}, #else {_debug_check_keyinput, 0, - "MMKeycode 檢查按鍵控制碼工具"}, + "MMKeycode 檢查按鍵控制碼工具"}, + {_debug_testregcode, 0, + "RRegcode 檢查註冊碼公式"}, #endif {p_sysinfo, 0, "XXinfo 《查看系統資訊》"}, diff --git a/mbbsd/user.c b/mbbsd/user.c index 1100ef60..17c22827 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -1031,15 +1031,64 @@ removespace(char *s) } static char * -getregcode(char *buf) +getregcode(unsigned char *buf) { - strcpy(buf, crypt(cuser.userid, "02")); + unsigned char *uid = &cuser.userid[0]; + int i; + + /* init seed with magic */ + strncpy(buf, REGCODE_MAGIC, 13); /* des keys are only 13 byte */ + buf[13] = 0; + + /* scramble with user id */ + for (i = 0; i < IDLEN && uid[i]; i++) + { + buf[i] ^= uid[i]; + while (!(buf[i] >= '0' && buf[i] <= 'z')) + { + buf[i] = (buf[i] + '0') & 0xff; + buf[i+1] = (buf[i+1] + 0x17) & 0xff; + } + } + /* leave last character untouched anyway */ + buf[13] = 0; + + /* real encryption */ + strcpy(buf, crypt(buf, "pt")); /* hack to prevent trailing dots */ if (buf[strlen(buf)-1] == '.') buf[strlen(buf)-1] = 'd'; return buf; } +#ifdef DEBUG +int +_debug_testregcode() +{ + char buf[16], rcode[16]; + char myid[16]; + int i = 1; + + clear(); + strcpy(myid, cuser.userid); + do { + getdata(0, 0, "輸入 id (空白結束): ", + buf, IDLEN+1, DOECHO); + if(buf[0]) + { + move(i, 0); + strcpy(cuser.userid, buf); + prints("id: [%s], regcode: [%s]\n" ANSI_CLRTOEND, + cuser.userid, getregcode(rcode)); + } + } while (buf[0]); + strcpy(cuser.userid, myid); + + pressanykey(); + return 0; +} +#endif + static int isvalidemail(const char *email) { @@ -1397,6 +1446,7 @@ u_register(void) "或您可以輸入 x來重新填寫 E-Mail 或改由站長手動認證\n", cuser.userid, cuser.username); inregcode[0] = 0; + do{ getdata(10, 0, "您的輸入: ", inregcode, sizeof(inregcode), DOECHO); if( strcmp(inregcode, "x") == 0 || diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf index e87e34f6..f95f38e9 100644 --- a/sample/pttbbs.conf +++ b/sample/pttbbs.conf @@ -10,6 +10,10 @@ #define MYHOSTNAME "ptt2.cc" /* 網路位址 */ #define MYIP "140.112.30.143" /* IP位址 */ +/* 為減少假 email 利用 source 算出註冊碼, 我們改用新的公式。 + * 下面這個是起始的種子值,請改成任意字串 (1~13 chars) */ +#define REGISTER_MAGIC "pttbbs" + /* 定義系統資訊 */ #define BBSUSER "bbs" #define BBSUID 9999 |