go-log-analyser is a simple Linux log analyzer written in Go. This project is primarily for learning Go and exploring log analysis techniques. It analyzes SSH failed password attempts from a log file and provides a summary of the top IPs and usernames involved.
- Parses a log file line by line.
- Identifies lines indicating failed SSH password attempts.
- Extracts usernames and IP addresses from those lines using regular expressions.
- Counts the number of failed attempts per IP address and username.
- Prints a summary of the top IPs and usernames with the number of failed attempts.
- Accepts a command-line flag to specify the log file.
- Go installed on your system.
-
Clone the repository:
git clone <repository-url>
-
Navigate to the project directory:
cd go-log-analyser
-
Build the application:
go build main.go
-
Run the application:
./main -file <path/to/log-file>
For example, to analyze the
example.auth.logfile:./main -file /var/log/auth.log
Example output:
=== SSH Brute Force Summary === Top IPs: 192.168.1.102: 2 attempts 10.0.0.5: 4 attempts 203.0.113.45: 1 attempt 192.168.1.101: 3 attempts Top Usernames: admin: 2 attempts test: 2 attempts root: 4 attempts guest: 1 attempt deploy: 1 attemptIf no file is specified, the program will default to reading
auth.log.
- The log file path can be specified using the
-filecommand-line flag. - If no flag is provided, the program defaults to
auth.log.
Feel free to contribute to this project by submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
- This project was created as a learning exercise.