[ previous ] [ next ] [ threads ]
 
 From:  Andy Wodfer <wodfer at gmail dot com>
 To:  m0n0wall at lists dot m0n0 dot ch
 Subject:  XML import tool or trick?
 Date:  Wed, 25 May 2011 11:16:49 +0200
I need some help again here ... My webserver that's on my LAN interface
(10.0.0.10) is being DDOS'ed (TCP port 80). I need to block the attackers.

I have a txt file containing about 1300 IP addresses (one on each line).

I need to create block rules in my firewall (m0n0wall) for all these IP
addresses. The syntax is:

<rule>
<type>block</type>
<interface>wan</interface>
<protocol>tcp</protocol>
<source>
<address>IP ADDRESS</address>
</source>
<destination>
<any/>
</destination>
<descr>blocked</descr>
</rule>

The IP list .txt file looks like this (just random typed numbers):

200.200.202.2
55.33.100.224
81.55.44.75
and so on ...

Is there a way I can generate the XML data rule tags and insert one IP from
each line into the <address> tag and put everything in a new file with the
rules underneath eachother like this so I can add it to my config backup xml
file?

<rule>
<type>block</type>
<interface>wan</interface>
<protocol>tcp</protocol>
<source>
<address>IP ADDRESS</address>
</source>
<destination>
<any/>
</destination>
<descr>blocked</descr>
</rule>
<rule>
<type>block</type>
<interface>wan</interface>
<protocol>tcp</protocol>
<source>
<address>IP ADDRESS</address>
</source>
<destination>
<any/>
</destination>
<descr>blocked</descr>
</rule>
<rule>
<type>block</type>
<interface>wan</interface>
<protocol>tcp</protocol>
<source>
<address>IP ADDRESS</address>
</source>
<destination>
<any/>
</destination>
<descr>blocked</descr>
</rule>

Thanks for all help!

Cheers,
Andy