<rdf:RDF
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xmlns:s='http://snipsnap.org/rdf/snip-schema#'
    xml:base='http://bliki.rimuhosting.com/rdf'>
    <s:Snip rdf:about='http://bliki.rimuhosting.com/rdf#knowledgebase/filtered+webmin'
         s:cUser='pablo'
         s:oUser=''
         s:mUser='pablo'>
        <s:name>knowledgebase/filtered webmin</s:name>
        <s:content>We&apos;ve all recently saw what happens when a popular running-as-root piece of package gets an exploit in the wild. I&apos;m talking about webmin. Thousands of servers were compromised in a matter of days, not just in Rimuhosting, but a lot of our customers did get their VPS compromised.&#xD;&#xA;&#xD;&#xA;Now, we can&apos;t blame the webmin developers (although they did fall for a very simple bug...), errors in software is absolutely unavoidable, sooner or later this was going to happen, and, guess what, it will happen again.&#xD;&#xA;&#xD;&#xA;Since we know this will happen again we should wonder, is there something we can do to prevent our servers and VPS from getting compromised again? Of course there is! Do you *really* use webmin all over the internet? For the 99.9% of webmin users the answer is simply *no*, at most we use it from a couple of computers, home? the office? some remote place while we are in vacations? Yes... that&apos;s basically it...&#xD;&#xA;&#xD;&#xA;So, I&apos;d recommend that if you want to prevent your server from getting compromised again you whitelist webmin.&#xD;&#xA;&#xD;&#xA;To do this you would add an allow-my-home, allow-my-office, deny-rest.&#xD;&#xA;&#xD;&#xA;Let&apos;s set it up:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;iptables -I INPUT 1 -p tcp --dport $WEBMIN_PORT -j DROP&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Now, let&apos;s write an script that will add a client as an authorized user for webmin:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;echo &apos;#!/bin/bash&#xD;&#xA;&#xD;&#xA;WEBMIN_PORT=__10000__&#xD;&#xA;&#xD;&#xA;if [ &quot;$1&quot; != &quot;&quot; ]; then&#xD;&#xA;        IP=$1;&#xD;&#xA;else&#xD;&#xA;        IP=`echo $SSH_CLIENT | cut -f1 -d&quot; &quot;`;&#xD;&#xA;fi&#xD;&#xA;&#xD;&#xA;if [ &quot;$IP&quot; = &quot;&quot; ]; then&#xD;&#xA;        echo &quot;Specify the IP address you want to add as allowed&quot;;&#xD;&#xA;        exit;&#xD;&#xA;fi&#xD;&#xA;&#xD;&#xA;iptables -I INPUT 1 -p tcp --dport $WEBMIN_PORT -s $IP -j ACCEPT&#xD;&#xA;&#xD;&#xA;if [ &quot;$?&quot; != &quot;0&quot; ]; then&#xD;&#xA;        echo &quot;IP not added&quot;;&#xD;&#xA;else&#xD;&#xA;        echo &quot;$IP added&quot;;&#xD;&#xA;fi&apos; &gt; /usr/bin/webmin_add&#xD;&#xA;&#xD;&#xA;chmod 755 /usr/bin/webmin_add&#xD;&#xA;&#xD;&#xA;echo &apos;#!/bin/bash&#xD;&#xA;&#xD;&#xA;WEBMIN_PORT=__10000__&#xD;&#xA;&#xD;&#xA;if [ &quot;$1&quot; != &quot;&quot; ]; then&#xD;&#xA;        IP=$1;&#xD;&#xA;else&#xD;&#xA;        IP=`echo $SSH_CLIENT | cut -f1 -d&quot; &quot;`;&#xD;&#xA;fi&#xD;&#xA;&#xD;&#xA;if [ &quot;$IP&quot; = &quot;&quot; ]; then&#xD;&#xA;        echo &quot;Specify the IP address you want to remove as allowed&quot;;&#xD;&#xA;        exit;&#xD;&#xA;fi&#xD;&#xA;&#xD;&#xA;iptables -D INPUT -p tcp --dport __10000__ -s $IP -j ACCEPT&#xD;&#xA;&#xD;&#xA;if [ &quot;$?&quot; != &quot;0&quot; ]; then&#xD;&#xA;        echo &quot;IP not removed&quot;;&#xD;&#xA;else&#xD;&#xA;        echo &quot;$IP removed&quot;;&#xD;&#xA;fi&apos; &gt; /usr/bin/webmin_remove&#xD;&#xA;&#xD;&#xA;chmod 755 /usr/bin/webmin_remove&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Now, whenever you want to use webmin from a different computer (or IP) you would run:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;webmin_add&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;as root, or to allow a particular IP:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;webmin_add IP&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;When you are done using webmin run:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;webmin_remove&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;or to stop allowing a particular IP:&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;webmin_remove IP&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;__NOTE:__ Throughout the scripts the port 10000 has been highlighted, replace 10000 with the port where your webmin is running.&#xD;&#xA;</s:content>
        <s:mTime>2006-08-13 10:21:24.0</s:mTime>
        <s:cTime>2006-08-13 10:21:24.0</s:cTime>
        <s:comments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
        <s:snipLinks>
            <rdf:Bag>
                <rdf:li rdf:resource='#knowledgebase'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/Security/Securing Your Server'/>
                <rdf:li rdf:resource='#snipsnap-search'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/miscapplications/webmin'/>
                <rdf:li rdf:resource='#snipsnap-index'/>
                <rdf:li rdf:resource='#pablo'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/rimuhosting/rimuhosting ssh access'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/webserver/apache/mod_rewrite'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/'/>
                <rdf:li rdf:resource='#glenn'/>
                <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/rimuhosting/vps backups'/>
            </rdf:Bag>
        </s:snipLinks>
        <s:attachments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
    </s:Snip>
</rdf:RDF>
