/*
* ftelnetd - fake telnet daemon
*
* log_stuff.c
* Logs the ipaddress, port, user and pass to the chosen logfile.
* Default logfile is declared as "ftelnetd.log in ftelnetd.c.
*
* Tue Dec 12 22:47:31 CET 2006
*
* by Levent Kayan
* levent[at]corehack[org]
* www.corehack.org
*/
#include "ftelnetd.h"
#include "ferror.h"
#include "banner.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
FILE *logfp;
void log_login(const char *user, const char *pass, const char *ip,
uint16_t port)
{
time_t ticks;
if ( (ticks = time(NULL)) == -1) {
ERR_GEN;
}
/* TODO: escape \r,\n, space, comma etc */
if (!fprintf(logfp, "%s%s:%hu -> %s -> %s:%s\n\n", ctime(&ticks),
ip, port, banner[mode].b_type, user, pass)) {
ERR_GEN;
}
}
void open_logfile(char *name)
{
if (!(logfp = fopen(name, "aw"))) {
ERR_GEN;
}
}
/* EOF */
syntax highlighted by Code2HTML, v. 0.9.1