0

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?

2
  • You have to quote "$uas", I bet. Apr 25, 2018 at 17:17
  • Yes that did it thanks Apr 27, 2018 at 1:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.