11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

Appen<strong>di</strong>ce A. Script aggiuntivi<br />

if [ ${#list_server[@]} -gt 0 ]<br />

then<br />

echo >>${_dot_file}<br />

echo ’# Known Blacklist nodes’ >>${_dot_file}<br />

_dd_cnt=${#list_server[@]}<br />

for (( _dd = 0 ; _dd < _dd_cnt ; _dd++ ))<br />

do<br />

printf ’ LS%04u [label="%s"] ;\n’ \<br />

"${_dd}" "${list_server[${_dd}]}" >>${_dot_file}<br />

done<br />

fi<br />

unique_lines address_hits address_hits<br />

if [ ${#address_hits[@]} -gt 0 ]<br />

then<br />

echo >>${_dot_file}<br />

echo ’# Known address->Blacklist_hit edges’ >>${_dot_file}<br />

echo ’# CAUTION: <strong>di</strong>g warnings can trigger false hits.’ >>${_dot_file}<br />

dump_to_dot address_hits AH<br />

fi<br />

echo >>${_dot_file}<br />

echo ’ *’ >>${_dot_file}<br />

echo ’ * That is a lot of relationships. Happy graphing.’ >>${_dot_file}<br />

echo ’ */’ >>${_dot_file}<br />

echo ’}’ >>${_dot_file}<br />

return 0<br />

# # # # ’Hunt the Spammer’ execution flow # # # #<br />

# Execution trace is enabled by setting the<br />

#+ environment variable SPAMMER_TRACE to the name of a writable file.<br />

declare -a _trace_log<br />

declare _log_file<br />

# Function to fill the trace log<br />

trace_logger() {<br />

_trace_log[${#_trace_log[@]}]=${_pend_current_}<br />

}<br />

# Dump trace log to file function variable.<br />

declare -f _log_dump<br />

_log_dump=pend_dummy # Initially a no-op.<br />

# Dump the trace log to a file.<br />

dump_log() {<br />

local -i _dl_cnt<br />

_dl_cnt=${#_trace_log[@]}<br />

for (( _dl = 0 ; _dl < _dl_cnt ; _dl++ ))<br />

do<br />

echo ${_trace_log[${_dl}]} >> ${_log_file}<br />

done<br />

_dl_cnt=${#_pen<strong>di</strong>ng_[@]}<br />

684

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!