C
C
chief2020-03-18 19:07:12
bash
chief, 2020-03-18 19:07:12

How to parse a file in bash and generate an IP list?

People, help.
I want to make myself filtering brute-forcers on OpenWRT.
What is there:
- there is a rule that catches too active IPs and puts them in the iptables table: /proc/net/xt_recent/bruters
- the table looks like:

cat /proc/net/xt_recent/bruters
src=185.164.72.162 ttl: 246 last_seen: 61021963 oldest_pkt: 1 61021963
src=61.184.189.52 ttl: 240 last_seen: 61249181 oldest_pkt: 1 61249181
src=92.118.160.61 ttl: 244 last_seen: 61342224 oldest_pkt: 1 61342224
src=80.211.46.104 ttl: 246 last_seen: 61262803 oldest_pkt: 1 61262803
src=61.190.70.130 ttl: 109 last_seen: 61111780 oldest_pkt: 1 61111780
src=94.153.228.18 ttl: 125 last_seen: 61111633 oldest_pkt: 1 61111633
src=93.89.190.250 ttl: 119 last_seen: 61130407 oldest_pkt: 1 61130407
src=46.211.71.104 ttl: 124 last_seen: 61042906 oldest_pkt: 1 61042906
src=185.200.118.42 ttl: 243 last_seen: 61114713 oldest_pkt: 1 61114713
src=194.5.207.105 ttl: 246 last_seen: 61375038 oldest_pkt: 1 61375038
src=49.88.112.109 ttl: 239 last_seen: 61056683 oldest_pkt: 1 61056683
src=94.153.66.55 ttl: 124 last_seen: 60887417 oldest_pkt: 1 60887417


Needed:
- a script that will parse /proc/net/xt_recent/brutersand write the result to /etc/bruteiplist in the form:
173.245.48.0
103.21.244.0
103.22.200.0
103.31.4.0

- somehow make this script run once a day (for example) using cron

Thanks in advance. I hope for your help.
I'll be sure to share the results :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2020-03-18
_

awk -F'[=, ]' '{print $2}' /proc/net/xt_recent/bruters > /etc/bruteiplist

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question