<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>blueblog - by Christian J. Dietrich - Securing Linux</title>
    <link>http://blog.cj2s.de/</link>
    <description>on malware, botnets and the like by Christian J. Dietrich</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.5 - http://www.s9y.org/</generator>
    <pubDate>Thu, 15 Mar 2012 17:19:39 GMT</pubDate>

    <image>
        <url>http://blog.cj2s.de/templates/bulletproof/img/s9y_banner_small.png</url>
        <title>RSS: blueblog - by Christian J. Dietrich - Securing Linux - on malware, botnets and the like by Christian J. Dietrich</title>
        <link>http://blog.cj2s.de/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Preventing ARP flux on Linux</title>
    <link>http://blog.cj2s.de/archives/29-Preventing-ARP-flux-on-Linux.html</link>
            <category>Securing Linux</category>
    
    <comments>http://blog.cj2s.de/archives/29-Preventing-ARP-flux-on-Linux.html#comments</comments>
    <wfw:comment>http://blog.cj2s.de/wfwcomment.php?cid=29</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.cj2s.de/rss.php?version=2.0&amp;type=comments&amp;cid=29</wfw:commentRss>
    

    <author>nospam@example.com (Christian J. Dietrich)</author>
    <content:encoded>
    ARP, the address resolution protocol, is used on an Ethernet network to map IP addresses to hardware (MAC) addresses. By default, a Linux box with several network interfaces will respond to ARP requests received on any interface for any of the IP addresses of its interfaces. Here is an example: Let&#039;s assume we have a box which is connected with two interfaces A (MAC 00:00:00:AA:AA:AA) and B (MAC 00:00:00:BB:BB:BB). Interface A is configured to the IP address 172.16.0.1 and B to 172.16.0.2. Thus, both interfaces point to the same segment.&lt;br /&gt;
&lt;br /&gt;
We use arping to query for the hardware address of the IP address 172.16.0.1 and expect to get the MAC address 00:00:00:AA:AA:AA of interface A in return.&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
[root@nugger]# arping -I eth0 172.16.0.1&lt;br /&gt;
ARPING 172.16.0.1 from 172.16.0.99 eth0&lt;br /&gt;
Unicast reply from 172.16.0.1 [00:00:00:AA:AA:AA]  7.889ms&lt;br /&gt;
Unicast reply from 172.16.0.1 [00:00:00:BB:BB:BB]  8.014ms&lt;br /&gt;
&lt;br /&gt;
[root@nugger]# arping -I eth0 172.16.0.2&lt;br /&gt;
ARPING 172.16.0.2 from 172.16.0.99 eth0&lt;br /&gt;
Unicast reply from 172.16.0.2 [00:00:00:AA:AA:AA]  6.612ms&lt;br /&gt;
Unicast reply from 172.16.0.2 [00:00:00:BB:BB:BB]  8.991ms&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
Instead, we get the MACs of A and B alternating. You can tune this behavior using arp_ignore and arp_announce sysctl properties:&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
arp_ignore - INTEGER&lt;br /&gt;
Define different modes for sending replies in response to&lt;br /&gt;
received ARP requests that resolve local target IP addresses:&lt;br /&gt;
0 - (default): reply for any local target IP address, configured&lt;br /&gt;
on any interface&lt;br /&gt;
1 - reply only if the target IP address is local address&lt;br /&gt;
configured on the incoming interface&lt;br /&gt;
2 - reply only if the target IP address is local address&lt;br /&gt;
configured on the incoming interface and both with the&lt;br /&gt;
sender&#039;s IP address are part from same subnet on this interface&lt;br /&gt;
3 - do not reply for local addresses configured with scope host,&lt;br /&gt;
only resolutions for global and link addresses are replied&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
arp_announce - INTEGER&lt;br /&gt;
Define different restriction levels for announcing the local&lt;br /&gt;
source IP address from IP packets in ARP requests sent on&lt;br /&gt;
interface:&lt;br /&gt;
0 - (default) Use any local address, configured on any interface&lt;br /&gt;
...&lt;br /&gt;
2 - Always use the best local address for this target.&lt;br /&gt;
In this mode we ignore the source address in the IP packet&lt;br /&gt;
and try to select local address that we prefer for talks with&lt;br /&gt;
the target host. Such local address is selected by looking&lt;br /&gt;
for primary IP addresses on all our subnets on the outgoing&lt;br /&gt;
interface that include the target IP address. If no suitable&lt;br /&gt;
local address is found we select the first local address&lt;br /&gt;
we have on the outgoing interface or on all other interfaces,&lt;br /&gt;
with the hope we will receive reply for our request and&lt;br /&gt;
even sometimes no matter the source IP address we announce.&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Setting net.ipv4.conf.all.arp_ignore=1 and net.ipv4.conf.all.arp_announce=2 in /etc/sysctl.conf provides adequate settings. However, you should check whether these settings work in your network environment, especially if you depend on reaching an IP address from any other than the interface that it is configured on.&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
net.ipv4.conf.all.arp_ignore=1&lt;br /&gt;
net.ipv4.conf.all.arp_announce=2&lt;br /&gt;
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Tue, 13 Mar 2012 09:05:11 +0100</pubDate>
    <guid isPermaLink="false">http://blog.cj2s.de/archives/29-guid.html</guid>
    
</item>
<item>
    <title>Best practice: chrooted BIND on CentOS 5.6+ with DNSSEC aware resolution</title>
    <link>http://blog.cj2s.de/archives/25-Best-practice-chrooted-BIND-on-CentOS-5.6+-with-DNSSEC-aware-resolution.html</link>
            <category>Securing Linux</category>
    
    <comments>http://blog.cj2s.de/archives/25-Best-practice-chrooted-BIND-on-CentOS-5.6+-with-DNSSEC-aware-resolution.html#comments</comments>
    <wfw:comment>http://blog.cj2s.de/wfwcomment.php?cid=25</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.cj2s.de/rss.php?version=2.0&amp;type=comments&amp;cid=25</wfw:commentRss>
    

    <author>nospam@example.com (Christian J. Dietrich)</author>
    <content:encoded>
    BIND is the most prevalent DNS server software. Since CentOS 5.6, BIND is readily available in the more recent version 9.7.0 in the packages bind97*. Among others, a preconfigured chroot environment is provided. In order to use chrooted BIND, install the package bind97-chroot and make sure that ROOTDIR is correct in /etc/sysconfig/named:&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
[us@ns ~]# grep ROOTDIR /etc/sysconfig/named&lt;br /&gt;
ROOTDIR=/var/named/chroot&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
Note that a service named restart is required in case BIND was running beforehand. &lt;br /&gt;
In order to provide the chroot environment, certain files and directories are (re)mounted under /var/named/chroot&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
/etc/named on /var/named/chroot/etc/named type none (rw,bind)&lt;br /&gt;
/var/named on /var/named/chroot/var/named type none (rw,bind)&lt;br /&gt;
/etc/named.conf on /var/named/chroot/etc/named.conf type none (rw,bind)&lt;br /&gt;
/etc/named.rfc1912.zones on /var/named/chroot/etc/named.rfc1912.zones type none (rw,bind)&lt;br /&gt;
/etc/rndc.conf on /var/named/chroot/etc/rndc.conf type none (rw,bind)&lt;br /&gt;
/etc/rndc.key on /var/named/chroot/etc/rndc.key type none (rw,bind)&lt;br /&gt;
/usr/lib/bind on /var/named/chroot/usr/lib/bind type none (rw,bind)&lt;br /&gt;
/etc/named.iscdlv.key on /var/named/chroot/etc/named.iscdlv.key type none (rw,bind)&lt;br /&gt;
/etc/named.root.key on /var/named/chroot/etc/named.root.key type none (rw,bind)&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
Thus, for example /etc/named.conf is actually made available to the chrooted BIND and you as the admin just have to take care of one file. Previously, there used to be two named.confs, one inside the chroot environment and one outside. If you do not have a named.conf yet, I suggest you start using the &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.cymru.com/Documents/secure-bind-template.html&#039;]);&quot;  href=&quot;http://www.cymru.com/Documents/secure-bind-template.html&quot;&gt;named.conf template by Rob Thomas of Team Cymru&lt;/a&gt;.&lt;br /&gt;
Heading for DNSSEC validating resolution, the most important settings in named.conf are the following:&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
    // ****** DNSSEC relevant settings ****** //&lt;br /&gt;
    // Since 9.5 the default value is dnssec-enable yes;.&lt;br /&gt;
    // This statement may be used in a view or global options clause.&lt;br /&gt;
    dnssec-enable yes;&lt;br /&gt;
    // indicates that a resolver (a caching or caching-only name server)&lt;br /&gt;
    // will attempt to validate replies from DNSSEC enabled (signed) zones.&lt;br /&gt;
    // To perform this task the server also needs either a valid trusted-&lt;br /&gt;
    // keys clause (containing one or more trusted-anchors or a managed-keys&lt;br /&gt;
    // clause. Since 9.5 the default value is dnssec-validation yes;&lt;br /&gt;
    dnssec-validation yes;&lt;br /&gt;
    dnssec-lookaside auto;&lt;br /&gt;
    /&lt;strong&gt; Path to ISC DLV key &lt;/strong&gt;/&lt;br /&gt;
    //bindkeys-file &quot;/etc/named.iscdlv.key&quot;;&lt;br /&gt;
    /&lt;strong&gt; Path to root DNSSEC key &lt;/strong&gt;/&lt;br /&gt;
    bindkeys-file &quot;/etc/named.root.key&quot;;&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
As shown above, I changed the bindkeys-file statement to point to the root DNSSEC key instead of ISC&#039;s DLV root key. This is fine because by now there is a &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.isc.org/community/blog/201007/using-root-dnssec-key-bind-9-resolvers&#039;]);&quot;  href=&quot;http://www.isc.org/community/blog/201007/using-root-dnssec-key-bind-9-resolvers&quot; target=&quot;_blank&quot;&gt;verifiable path to validate ISC&#039;s DLV root key&lt;/a&gt; (signed root, signed .ORG and signed isc.org and dlv.isc.org zones). Thus, ISC&#039;s DLV key does not need to be included any longer.&lt;br /&gt;
&lt;br /&gt;
Please note that as of now (bind97-9.7.0-6.P2.el5_6.3), there is &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/bugzilla.redhat.com/show_bug.cgi?id=719855&#039;]);&quot;  href=&quot;https://bugzilla.redhat.com/show_bug.cgi?id=719855&quot; target=&quot;_blank&quot;&gt;a bug in the init script of bind97&lt;/a&gt; which has been acknowleged upstream. Basically, the root DNSSEC key is not mounted in the chroot environment. Until the bug will be fixed in the package, you should apply the fix (I also provided in the bug report):&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
# A possible fix is to include /etc/named.root.key in /etc/init.d/named, i.e.&lt;br /&gt;
# change the contents of the ROOTDIR_MOUNT variable in /etc/init.d/named from&lt;br /&gt;
&lt;br /&gt;
ROOTDIR_MOUNT=&#039;/etc/named /etc/pki/dnssec-keys /var/named /etc/named.conf&lt;br /&gt;
/etc/named.dnssec.keys /etc/named.rfc1912.zones /etc/rndc.conf /etc/rndc.key&lt;br /&gt;
/usr/lib64/bind /usr/lib/bind /etc/named.iscdlv.key&#039;&lt;br /&gt;
&lt;br /&gt;
# to&lt;br /&gt;
&lt;br /&gt;
ROOTDIR_MOUNT=&#039;/etc/named /etc/pki/dnssec-keys /var/named /etc/named.conf&lt;br /&gt;
/etc/named.dnssec.keys /etc/named.rfc1912.zones /etc/rndc.conf /etc/rndc.key&lt;br /&gt;
/usr/lib64/bind /usr/lib/bind /etc/named.iscdlv.key /etc/named.root.key&#039;&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Finally you should test with a domain that has authoritative DNSSEC information. The answer must contain the AD flag.&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
[us@ns ~]# dig +dnssec @127.0.0.1 gov. ns&lt;br /&gt;
; &lt;&lt;&gt;&gt; DiG 9.7.0-P2-RedHat-9.7.0-6.P2.el5_6.2 &lt;&lt;&gt;&gt; +dnssec @127.0.0.1 gov. ns&lt;br /&gt;
; (1 server found)&lt;br /&gt;
;; global options: +cmd&lt;br /&gt;
;; Got answer:&lt;br /&gt;
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 14572&lt;br /&gt;
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1&lt;br /&gt;
&lt;br /&gt;
;; OPT PSEUDOSECTION:&lt;br /&gt;
; EDNS: version: 0, flags: do; udp: 4096&lt;br /&gt;
;; QUESTION SECTION:&lt;br /&gt;
;gov.                           IN      NS&lt;br /&gt;
&lt;br /&gt;
;; ANSWER SECTION:&lt;br /&gt;
gov.                    172800  IN      NS      b.gov-servers.net.&lt;br /&gt;
gov.                    172800  IN      NS      a.gov-servers.net.&lt;br /&gt;
gov.                    172800  IN      RRSIG   NS 7 1 172800 20110609040023 &lt;br /&gt;
20110604040023 43879 gov. FnygljkPqlL9Q08CX5lixJ7O5bB6ysM...&lt;br /&gt;
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Sat, 02 Jul 2011 21:50:00 +0200</pubDate>
    <guid isPermaLink="false">http://blog.cj2s.de/archives/25-guid.html</guid>
    
</item>
<item>
    <title>Protecting from SSH Bruteforce Attacks</title>
    <link>http://blog.cj2s.de/archives/13-Protecting-from-SSH-Bruteforce-Attacks.html</link>
            <category>Securing Linux</category>
    
    <comments>http://blog.cj2s.de/archives/13-Protecting-from-SSH-Bruteforce-Attacks.html#comments</comments>
    <wfw:comment>http://blog.cj2s.de/wfwcomment.php?cid=13</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.cj2s.de/rss.php?version=2.0&amp;type=comments&amp;cid=13</wfw:commentRss>
    

    <author>nospam@example.com (Christian J. Dietrich)</author>
    <content:encoded>
    Even botnet operators know the fine advantages of Linux servers: Some (if not most) operate their main C&amp;C servers as Linux hosts. When reading through server logs full of SSH authentication failures due to bruteforce scans, I sometimes wonder, do those C&amp;C servers of the botmasters also get these annoying attempts? However...&lt;br /&gt;
&lt;br /&gt;
I have used &lt;a onclick=&quot;_gaq.push([&#039;_trackPageview&#039;, &#039;/extlink/www.fail2ban.org/wiki/index.php/Main_Page&#039;]);&quot;  href=&quot;http://www.fail2ban.org/wiki/index.php/Main_Page&quot;&gt;fail2ban&lt;/a&gt; in order to prevent from these attacks for years. fail2ban scans the log files in order to identify bruteforce scans and bans the source IP addresses using iptables. If you use CentOS, you can install fail2ban from the rpmforge repository like so:&lt;br /&gt;
&lt;pre&gt;yum --enablerepo rpmforge install fail2ban.noarch&lt;/pre&gt;&lt;br /&gt;
After installation, configure fail2ban must be configured. Change the parameter ignoreip in the config file /etc/fail2ban/jail.conf to match the desired IP address ranges that shall never be blocked, e.g.:&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
ignoreip = 127.0.0.1 192.168.0.0/24 172.16.0.0/24 10.0.0.0/18&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
Furthermore, the section ssh-iptables must be enabled. NOTE: Change the email address! You probably want to change the sender email address, too.&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
[ssh-iptables]&lt;br /&gt;
enabled  = true&lt;br /&gt;
filter   = sshd&lt;br /&gt;
action   = iptables[name=SSH, port=ssh, protocol=tcp]&lt;br /&gt;
           sendmail-whois[name=SSH, dest=RECEIVER@DOMAIN, sender=fail2ban@HOSTNAME]&lt;br /&gt;
logpath  = /var/log/secure&lt;br /&gt;
maxretry = 5&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
If someone else than root shall get the mail, change the directive dest in /etc/fail2ban/action.d/mail.conf. &lt;br /&gt;
&lt;br /&gt;
Finally, make sure that it is enabled in the correct runlevels:&lt;br /&gt;
&lt;pre&gt;chkconfig fail2ban on&lt;br /&gt;
service fail2ban start&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Tue, 01 Jun 2010 15:59:00 +0200</pubDate>
    <guid isPermaLink="false">http://blog.cj2s.de/archives/13-guid.html</guid>
    
</item>

</channel>
</rss>
