|
| 1 | + |
| 2 | + |
| 3 | +The very first thing I did was grep out IP address from the logfiles I had |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +This showed me that only "log a" had valid Ip Addresses, so to get the Ip Addresses with the most count I wrote a script |
| 10 | + |
| 11 | +```python |
| 12 | +from collections import Counter |
| 13 | +import re |
| 14 | + |
| 15 | +# Function to extract IP addresses from a line |
| 16 | +def extract_ips(line): |
| 17 | + # Regular expression to match IPv4 addresses |
| 18 | + return re.findall(r'[0-9]+(?:\.[0-9]+){3}', line) |
| 19 | + |
| 20 | +# Read the log file and count IP occurrences |
| 21 | +def count_ips(log_file): |
| 22 | + with open(log_file, 'r') as file: |
| 23 | + # Extract all IP addresses |
| 24 | + ips = [] |
| 25 | + for line in file: |
| 26 | + ips.extend(extract_ips(line)) |
| 27 | + |
| 28 | + # Count occurrences of each IP |
| 29 | + ip_count = Counter(ips) |
| 30 | + |
| 31 | + # Print the IP addresses and their counts |
| 32 | + for ip, count in ip_count.items(): |
| 33 | + print(f"{ip}: {count}") |
| 34 | + |
| 35 | +# Example usage: replace 'logfile.txt' with your actual log file path |
| 36 | +log_file = 'logfile_a.xml' |
| 37 | +count_ips(log_file) |
| 38 | +``` |
| 39 | +I got interesting stuffs when I ran my script |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +The top 3 Ips here are `102.164.18.195`, `181.188.139.179` and `23.4.4.223`, but then `23.4.4.223` isn't a valid ip so I added the next ip that had most count which is `31.189.124.173` |
| 44 | + |
| 45 | +FLAG:```csean-ctf{102.164.18.195, 181.188.139.179, 31.189.124.173}24``` |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
1 | 70 |
|
0 commit comments