21
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include "knocker_core.h"
25
25
#include "knocker_log.h"
26
26
#include "knocker_args.h"
27
#include "knocker_user.h"
28
#include "knocker_time.h"
33
30
const char knocker_log_header[] =
34
31
"+-----------------------------------------------------------------------------+\n|--=| k n o c k e r -- t h e -- n e t -- p o r t s c a n n e r |=-=[logfile]=-|\n+-----------------------------------------------------------------------------+\n";
37
33
char *knocker_time;
56
52
if (knocker_log_fp == NULL)
59
knocker_user = getenv ("USER");
62
56
knocker_time = ctime (&timenow);
64
58
fprintf (knocker_log_fp, "%s", knocker_log_header);
67
if (knocker_user != NULL)
68
fprintf (knocker_log_fp, " - %s started by user %s on %s\n", PACKAGE, knocker_user, knocker_time);
61
if (knocker_user.name != NULL)
62
fprintf (knocker_log_fp, " - %s started by user %s on %s\n", PACKAGE, knocker_user.name, knocker_time);
70
64
fprintf (knocker_log_fp, " - %s started on %s\n", PACKAGE, knocker_time);
83
77
void knocker_log_host_info (char *hostname_str, char *hostip_str)
85
/* if logging to file is FALSE*/
79
/* if logging to file is FALSE */
86
80
if (knocker_args.logfile == FALSE)
117
111
void knocker_log_ports_info (int sp, int ep)
119
/* if logging to file is FALSE*/
113
/* if logging to file is FALSE */
120
114
if (knocker_args.logfile == FALSE)
123
117
fprintf (knocker_log_fp, " - - scan from port: %d\n", sp);
124
118
fprintf (knocker_log_fp, " - - - scan to port: %d\n", ep);
125
119
fprintf (knocker_log_fp, " - - - - scan type: tcp connect\n");
126
fprintf (knocker_log_fp, "+=- - - - - - - - - - - - - - - - - - - - - - - - - - - - - s c a n n i n g / -\n");
127
fprintf (knocker_log_fp, " \\/\n");
120
fprintf (knocker_log_fp, "+=- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s c a n n i n g -\n");
121
fprintf (knocker_log_fp, "\n");
129
123
fflush (knocker_log_fp);
136
130
void knocker_log_open_port (int port, char *service_str)
138
/* if logging to file is FALSE*/
132
/* if logging to file is FALSE */
139
133
if (knocker_args.logfile == FALSE)
147
141
============================================================================
148
142
============================================================================
150
void knocker_log_results (char *hostname_str, char *hostip_str,int tot_ps, int open_ps, int secs)
144
void knocker_log_results (char *hostname_str, char *hostip_str, int tot_ps, int open_ps, char *secs)
152
/* if logging to file is FALSE*/
146
/* if logging to file is FALSE */
153
147
if (knocker_args.logfile == FALSE)
156
fprintf (knocker_log_fp, " /\\\n");
157
fprintf (knocker_log_fp, "+=- - - - - - - - - - - - - - - - - - - - - - - - - - - / c o m p l e t e d - -\n\n");
150
fprintf (knocker_log_fp, "\n");
151
fprintf (knocker_log_fp, "+=- - - - - - - - - - - - - - - - - - - - - - - - - - - - c o m p l e t e d -\n\n");
158
152
fprintf (knocker_log_fp, " - scanned host name: %s ", hostname_str);
159
153
fprintf (knocker_log_fp, "IP: %s\n\n", hostip_str);
160
fprintf (knocker_log_fp, " - found %d open ports in a totoal of %d ports scanned.\n\n", tot_ps, open_ps);
161
fprintf (knocker_log_fp, " - port scan completed in %d seconds.\n\n", secs);
154
fprintf (knocker_log_fp, " - found %d open ports in a totoal of %d ports scanned.\n\n", open_ps, tot_ps);
155
fprintf (knocker_log_fp, " - port scan completed in %s seconds.\n\n", secs);
163
157
fflush (knocker_log_fp);
184
178
void knocker_log_close (void)
186
/* if logging to file is FALSE*/
180
/* if logging to file is FALSE */
187
181
if (knocker_args.logfile == FALSE)
190
184
/* If a previous knocker_log_open () function call
191
185
failed, we must not write to the file, since it hasn't been open
193
187
if (knocker_log_fp == NULL)