Jump to content
kNigHt

Remove your IP logs

Recommended Posts

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/sh

SSH_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;
done
done

Link to comment
Share on other sites

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.conf

Am pus variabila LOCATIONS, sa-si puna omul path-urile.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...