The actual combat target for the log desensitization, the log directory of all the files processed, all involved in the card number and password information, will be replaced by "*" number, to replace the contents are obtained from the corresponding tags, the script to execute the directory
Drwxr-xr-x 5 root root 4096 may 20:20 log-rw-r--r--1 root root for 20:20 cfg.log-rw-r--r--1 root root 3 20:28 cfg.time-rwxr-xr-x 1 root root 1625 may 20:30 desi.sh-rw-r--r--1 root root 856 * 20:50 Sh.log
Instructions for use
Instructions for use of this script: 1. The folder log is the log directory to be processed, as an example 2.cfg.log is used to configure the log directory to be processed 3.cfg.time the time interval for the scheduled task, in minutes of 4. Sh.log log 5.desi.sh for script execution 6. The first few lines in desi.sh are the individual profile paths and need to be configured manually, note that the absolute path PS must be : tested, Processing 80M of the log will probably need to 30s+ time, so it is best to set the time interval as long as possible, in addition, the script does not do any memory of the processed logs, that is, every time the script executes, the log directory in the log is processed, so over time, the log more and more large, The longer the script executes, the more time it takes to be aware of it. If necessary, the latter can be optimized.
desi.sh Content
# This file was used to handle log desensitization# kay# 05/31/2016#!/bin/bash# global path variabletimecfg= "/ROOT/SHELL/CF G.time "Interval= ' Cat ${timecfg} ' path="/root/shell/desi.sh "shlogpath="/root/shell/sh.log "logcfg="/root/shell/ Cfg.log "# Add Crontabdocrontab () {cronfile="/tmp/crontab.${user} "crontab-l > ${cronfile}content=" */"${interval}" * * * * "${path}grep-q" ${path} "${cronfile} && echo" | | {echo "${content}" >> ${cronfile}crontab ${cronfile}}rm-rf ${cronfile}}# desensitization functionkeylab= (track_ 2 track_3 pan Exp_dt ic_dat pin_key track_key trm_key tpklmk zaklmk zpklmk pin_data) desensitization () {for key in ${keylab[ *]}dof1= "<" ${key} ">" f2= "s/<" ${key} ">/\n" ${key} "=/GP" f3= "s/<\/" ${key} ">/\N/GP" f4= "/" ${key} "=/ P "f5=" s/"${key}" =//GP "f6=": 1; n;s/^ (\s+) ((\n.*) *) \n\1$/\1\2/m;$!b1 "list= ' grep-r ${f1} $ | Sed-n ${F2} | Sed-n ${F3} | Sed-n ${f4} | Sed-n ${f5} | Sed-r ${f6} | Cat ' for L in ${list}do cnb= "" len=${#l}if [${len}-gt 8]thencnb= "5-"$ ((${len}-4)) elsecnb=" 2-3 "Fimid= ' echo ${l} | CUT-NB ${CNB} ' mid= ' echo ' ${mid} ' | Sed ' s/*/\\\*/g ' h= ' echo ${l} | Sed ' s/' ${mid} '/*******/g ' f= ' echo ' ${l} ' | Sed ' s/*/\\\*/g ' grep-rl ${f} | Xargs sed-i ' s/' ${f} '/' ${h} '/g ' donedone}# check whether config file exists if test-f ${logcfg}then echo ' ${logcfg}. . ">> ${shlogpath}else echo" log config file not exist ">> ${shlogpath}fi# read config file and handle ever Y file and directioryfilelist= ' cat ${logcfg} ' for F in ${filelist}dodesensitization ${f}donedocrontabexit
The explanation is not written first, the hands are numb
I hope to see you next time.
Shell Combat Log desensitization