@@ -127,24 +127,24 @@ def log_scan(self, scan):
127
127
""" Log the scan to file and/or console """
128
128
129
129
srcip , dstip = utils .scan_ip2quad (scan )
130
+ zombie_host = utils .ip2quad (scan .zombie )
130
131
ports = ',' .join ([str (port ) for port in scan .ports ])
132
+ template = '{type} scan (flags:{flags}) from {srcip} to {dstip} (ports: {ports})'
133
+ line = ''
131
134
132
135
if not scan .duplicate :
133
136
# Newly detected scan
134
- tup = [scan .type ,scan .flags ,srcip ,dstip , ports ]
135
-
136
137
if not scan .slow_scan :
137
138
if scan .type != TCP_IDLE_SCAN :
138
- line = '%s scan (flags:%d) from %s to %s (ports:%s)'
139
+ line = template
139
140
else :
140
- tup .append (utils .ip2quad (scan .zombie ))
141
- line = '%s scan (flags: %d) from %s to %s (ports: %s) using zombie host %s'
141
+ line = template + ' using zombie host {zombie_host}'
142
142
else :
143
- tup .append (scan .time_avg )
143
+ # tup.append(scan.time_avg)
144
144
if scan .maybe :
145
- line = 'Possible slow %s scan (flags:%d) from %s to %s (ports:%s), average timediff %.2fs '
145
+ line = 'Possible slow ' + template + ', mean timediff: {time_avg:.2f}s '
146
146
else :
147
- line = 'Slow %s scan (flags:%d) from %s to %s (ports:%s), average timediff %.2fs'
147
+ line = 'Slow ' + template + ', mean timediff: {time_avg:.2f}s'
148
148
else :
149
149
if self .ignore_dups :
150
150
# Not logging continued/duplicate scans
@@ -158,15 +158,16 @@ def log_scan(self, scan):
158
158
custom_threshold = levelParams ['max' ][1 ]
159
159
self .custom_thresholds [scan .hash ] = custom_threshold
160
160
if scan .type != TCP_IDLE_SCAN :
161
- line = 'Continuing %s scan from %s to %s (ports:%s)'
161
+ line = 'Continuing ' + template
162
162
else :
163
- tup .append (utils .ip2quad (scan .zombie ))
164
- line = 'Continuing %s scan from %s to %s (ports: %s) using zombie host %s'
163
+ line = 'Continuing ' + template + ' using zombie host {zombie_host}'
165
164
else :
166
- tup .append (scan .time_avg )
167
- line = 'Continuing slow %s scan from %s to %s (ports:%s), average timediff %.2fs'
165
+ line = 'Continuing slow ' + template + ', mean timediff: {time_avg:.2f}s'
168
166
169
- msg = line % tuple (tup )
167
+ # Context dictionary
168
+ context_dict = locals ()
169
+ context_dict .update (scan .__dict__ )
170
+ msg = line .format (** context_dict )
170
171
self .log (msg )
171
172
172
173
def update_ports (self , scan , dport , flags ):
0 commit comments