kNigHt Posted June 26, 2012 Report Posted June 26, 2012 Sper ca ajuta. Sugestiile sunt binevenite, acuma invatam si eu...In textfiles sterge linia, in binary files inlocuieste IP-ul cu FAKE_IP.Va ia ip-ul din conexiunea curenta SSH, daca aveti nevioe de un altul modificati SSH_IP.#!/bin/shSSH_IP=$(echo $SSH_CONNECTION | cut -d" " -f1);SSH_ESCAPED_IP=$(echo $SSH_IP | sed 's/\./\\\./g');SSH_LINESEP_IP=$(echo $SSH_IP | sed 's/\./-/g');SSH_LINESEP_ESCAPED_IP=$(echo $SSH_LINESEP_IP | sed 's/\./\\\./g');FAKE_IP="0.0.0.0";FAKE_ESCAPED_IP=$(echo $FAKE_IP | sed 's/\./\\\./g');LOCATIONS="/var/log /tmp";for LOCATION in $LOCATIONS;do for FILE in $(grep -r -I $SSH_IP $LOCATION | cut -d":" -f1 | uniq); do echo "Removing $FILE..."; FILEPATH=$(readlink -f $FILE) sed -i "/$SSH_ESCAPED_IP/d" $FILEPATH; sed -i "/$SSH_LINESEP_ESCAPED_IP/d" $FILEPATH; done for FILE in $(grep -r $SSH_IP $LOCATION | grep "Binary file" | grep "matches" | cut -d" " -f3); do echo "Removing $FILE..."; FILEPATH=$(readlink -f $FILE); sed -i "s/$SSH_ESCAPED_IP/$FAKE_ESCAPED_IP/g" $FILEPATH; sed -i "s/$SSH_LINESEP_ESCAPED_IP/$FAKE_ESCAPED_IP/g" $FILEPATH; donedone Quote
pyth0n3 Posted June 26, 2012 Report Posted June 26, 2012 1.In sistemele Unix nu exista optiunea "-i" pentru sed (nu va functiona)2.In sistemele Unix log/urile se pot gasi si sub /var/adm , restul depinde in baza directivelor create in /etc/syslog.conf Quote
kNigHt Posted June 26, 2012 Author Report Posted June 26, 2012 1.In sistemele Unix nu exista optiunea "-i" pentru sed (nu va functiona)Mersi, o sa gasesc o alternativa.2.In sistemele Unix log/urile se pot gasi si sub /var/adm , restul depinde in baza directivelor create in /etc/syslog.confAm pus variabila LOCATIONS, sa-si puna omul path-urile. Quote