Hi,
I run a chat (which is clean) which outputs an entry when a user connects to the chat. The problem is that i encounter "trolls" where we have people loggin in with 50+ different nicknames with 1 IP-address, and i need to be able to find the ones who is abusing the service.
So i made a simple script with a variable "IP" to search within the log files. Now i want to be able to fetch the unique usernames that has been used to connect with that IP (no duplicates) and do NOT have all the "dates, other info" in the results apart from "username".
The contents of the log file is as follows :
Code:
2015-07-22 12:03:37 AM GMT+2 - Username-- e8f3b769-d2b0-4149-8cad-660b4bcf3b58 -- 79.102.227.163 -- SWEDEN -- connect
What i want to do is :
a) Grep/Select out the ip address 79.102.227.163 and do a "grep search" for that ip address in all log files and pick out the "unique" Username above (between the - "UserName" -) above. I want to return / redirect all usernames into an own file.
b) Have a script for the above where "Ip-Address" is the input variable, like ./findusernames 79.102.227.163 (Which will * wildcard search on all files within the log folder) and then the script does the above in a) and output 1 file with all usernames that has been used to login to the chat with the ip above.
Below is how far i've reached, but i do not know how to use uniq | sort | and fetch the unique usernames in the result which is between the "--" Username "--" in the log file.
Code:
# Search for IP and results show all nicknames logged in with that IP
#!/bin/bash
cd /var/www/sexchatta.nu/ipl0gg
# Search for
/bin/grep -F -h -i "$1" * >/log/vaff4.html
Dumping some additional log rows to show how it looks like. The below dump can be used to find users logging in with same IP but with different usernames. Below for example "FakeUser1" / "FakeUser2" | "FakeDavid35", "David35" should be returned if you search on their individual IP's.
Code:
2015-07-22 12:25:36 AM GMT+2 - Onanilover -- 72cc07fe-d55c-48c3-b3df-a56a715f2213 -- 12.71.41.177 -- SWEDEN
-- enter room - Room name: Bild- & filmrummet
2015-07-22 12:25:46 AM GMT+2 - swe_coolio -- b2898a6b-3346-451b-b1bb-e5f0b85be164 -- 83.55.120.57 -- SWED
EN -- quit room - Room name: Rollspelsrummet
2015-07-22 12:25:51 AM GMT+2 - FakeUser1-- 6c3bcfb3-c2a7-4ec5-80ec-be426c8ac564 -- 211.112.166.103 -- SWE
DEN -- connect
2015-07-22 12:25:52 AM GMT+2 - FakeUser2 -- 6c3bcfb3-c2a7-4ec5-80ec-be426c8ac564 -- 211.112.166.103 -- SWE
DEN -- connect
2015-07-22 12:25:51 AM GMT+2 - KilleXCool -- 818584a2-c9dc-4d39-9256-2f27a0367003 -- 211.66.80.162 -- SWEDEN -
- enter room - Room name: Bild- & filmrummet
2015-07-22 12:25:54 AM GMT+2 - David35 -- 6c3bcfb3-c2a7-4ec5-80ec-be426c8ac564 -- 211.112.166.103 -- SWEDE
N -- login
2015-07-22 12:25:57 AM GMT+2 - FakeDavid35 -- 6c3bcfb3-c2a7-4ec5-80ec-be426c8ac564 -- 211.112.166.103 -- SWEDE
N -- enter room - Room name: Entrn
2015-07-22 12:25:57 AM GMT+2 - FakeDavid35 -- 6c3bcfb3-c2a7-4ec5-80ec-be426c8ac564 -- 211.112.166.103 -- SWEDE
N -- login
2015-07-22 12:25:57 AM GMT+2 - FakeDavid35 -- 6c3bcfb3-c2a7-4ec5-80ec-be426c8ac564 -- 211.112.166.103 -- SWEDE
N -- enter room - Room name: Entrn
Big Thanks in advance!