~ubuntu-branches/ubuntu/breezy/knocker/breezy

« back to all changes in this revision

Viewing changes to src/knocker_log.c

  • Committer: Bazaar Package Importer
  • Author(s): Pablo Lorenzzoni
  • Date: 2004-02-23 13:38:39 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040223133839-8nkw6632is003mrp
Tags: 0.7.1-2
* Upgraded Standard-Version
* Add URL to the description

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* knocker version 0.6.0
2
 
 * Release date: 17 February 2002
 
1
/* knocker version 0.7.1
 
2
 * Release date: 24 May 2002
3
3
 *
4
4
 * Project homepage: http://knocker.sourceforge.net
5
5
 *
21
21
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
22
*/
23
23
 
24
 
#include <time.h>
 
24
#include "knocker_core.h"
25
25
#include "knocker_log.h"
26
26
#include "knocker_args.h"
27
 
 
28
 
#ifndef FALSE
29
 
enum
30
 
{ FALSE, TRUE };
31
 
#endif
 
27
#include "knocker_user.h"
 
28
#include "knocker_time.h"
32
29
 
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";
35
32
 
36
 
char *knocker_user;
37
33
char *knocker_time;
38
34
 
39
35
/*
44
40
{
45
41
  time_t timenow;
46
42
 
47
 
  /* if logging to file is FALSE*/
 
43
  /* if logging to file is FALSE */
48
44
  if (knocker_args.logfile == FALSE)
49
45
    return 0;
50
46
 
56
52
  if (knocker_log_fp == NULL)
57
53
    return -1;
58
54
 
59
 
  knocker_user = getenv ("USER");
60
 
 
61
55
  time (&timenow);
62
56
  knocker_time = ctime (&timenow);
63
57
 
64
58
  fprintf (knocker_log_fp, "%s", knocker_log_header);
65
59
 
66
60
 
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);
69
63
  else
70
64
    fprintf (knocker_log_fp, " - %s started on %s\n", PACKAGE, knocker_time);
71
65
 
82
76
*/
83
77
void knocker_log_host_info (char *hostname_str, char *hostip_str)
84
78
{
85
 
  /* if logging to file is FALSE*/
 
79
  /* if logging to file is FALSE */
86
80
  if (knocker_args.logfile == FALSE)
87
81
    return;
88
82
 
99
93
*/
100
94
void knocker_log_resolve_error (char *hostname_str)
101
95
{
102
 
  /* if logging to file is FALSE*/
 
96
  /* if logging to file is FALSE */
103
97
  if (knocker_args.logfile == FALSE)
104
98
    return;
105
99
 
116
110
*/
117
111
void knocker_log_ports_info (int sp, int ep)
118
112
{
119
 
  /* if logging to file is FALSE*/
 
113
  /* if logging to file is FALSE */
120
114
  if (knocker_args.logfile == FALSE)
121
115
    return;
122
116
 
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");
128
122
 
129
123
  fflush (knocker_log_fp);
130
124
}
135
129
*/
136
130
void knocker_log_open_port (int port, char *service_str)
137
131
{
138
 
  /* if logging to file is FALSE*/
 
132
  /* if logging to file is FALSE */
139
133
  if (knocker_args.logfile == FALSE)
140
134
    return;
141
135
 
147
141
   ============================================================================
148
142
   ============================================================================
149
143
*/
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)
151
145
{
152
 
  /* if logging to file is FALSE*/
 
146
  /* if logging to file is FALSE */
153
147
  if (knocker_args.logfile == FALSE)
154
148
    return;
155
149
 
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);
162
156
 
163
157
  fflush (knocker_log_fp);
164
158
}
169
163
*/
170
164
void knocker_log_cancelled (void)
171
165
{
172
 
  /* if logging to file is FALSE*/
 
166
  /* if logging to file is FALSE */
173
167
  if (knocker_args.logfile == FALSE)
174
168
    return;
175
169
 
183
177
*/
184
178
void knocker_log_close (void)
185
179
{
186
 
  /* if logging to file is FALSE*/
 
180
  /* if logging to file is FALSE */
187
181
  if (knocker_args.logfile == FALSE)
188
182
    return;
189
183
 
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
192
 
  */
 
186
   */
193
187
  if (knocker_log_fp == NULL)
194
188
    return;
195
189
 
198
192
  fclose (knocker_log_fp);
199
193
 
200
194
}
201