Skip to content

Commit b4e1cd1

Browse files
authored
Update README.md
1 parent b65e75c commit b4e1cd1

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,70 @@
1+
![image](https://github.com/user-attachments/assets/5aad3886-6693-4f2e-bf2d-72e62fdb9eba)
2+
3+
The very first thing I did was grep out IP address from the logfiles I had
4+
5+
![image](https://github.com/user-attachments/assets/9d501017-2a79-4139-ac8c-e8f238f72235)
6+
![image](https://github.com/user-attachments/assets/ac2411fb-799e-4e27-898a-96d4af9359bf)
7+
![image](https://github.com/user-attachments/assets/6b9da9d7-c473-4bd0-856a-7e6734dcef21)
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+
![image](https://github.com/user-attachments/assets/7a4f399a-f31c-4382-be07-db46a23cf1d9)
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+
170

0 commit comments

Comments
 (0)