i have a script I use that reads ipaddress or ranges lines in from a txt file and insert them into my iptables. allows me to maintain one list for many servers. Recently I have been playing with string searches and user-agents stopping bad actors that use scripts that identify themselves using weird names in the useragent that i discover using tcpdump
I am trying to read a file and read each line in and
I am reading a file full of variables using egrep for example
JuNXhgCR
sipcli/v1.8
sipcli
friendly-scanner
pplsip
Asterisk PBX
Asterisk PBX 1.6.5
erdfcvqwaszx121
sipvicious
eyeBeam
VaxIPUserAgent
VaxSIPUserAgent/3.1
siparmyknife
VoIP SIP v11.0.0
FreePBX 1.8
Test Agent
but when i
egrep -v "^#|^$" x | while IFS= read -r uas
do
iptables -A INPUT -p udp -m udp --dport 5060 -m string --string $uas --algo bm --to 65535 -j DROP
done <"${_input}"
I just get ... but anything with a space is not passed ?? where is... VoIP SIP v11.0.0 , FreePBX 1.8 , Test Agent ??
JuNXhgCR
sipcli/v1.8
sipcli
friendly-scanner
pplsip
erdfcvqwaszx121
sipvicious
eyeBeam
VaxIPUserAgent
VaxSIPUserAgent/3.1
siparmyknife
Is there a better way to read and do this?
"$uas"
, I bet.