check out my patch Ive just posted to jira.<div><a href="http://jira.freeswitch.org/browse/FS-3094">http://jira.freeswitch.org/browse/FS-3094</a></div><div><br></div><div>you can subscribe to &quot;Auth&quot; events now - <span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 12px; ">SWITCH_EVENT_AUTH</span></div>

<div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 12px; ">which are generic for Register &amp; Invite ( and any other auth&#39;d packet I guess )</span></div><div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 12px; ">and there is an auth_state which will tell you if its an auth fail or a expire etc..</span></div>

<div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 12px; ">you can get the to_user, to_host, useragent, sip profile and network_ip</span></div><div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 12px; "><br>

</span></div><div><font class="Apple-style-span" face="Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;">Auth Expires also have a Log messages similar to Auth Failures ( fail2ban compatible )</span></font></div>

<div><span class="Apple-style-span" style="font-family: Arial, sans-serif; font-size: 12px; "><br></span></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>PLEASE guys give this some testing.  I only banged this together in a few hours today in my currently sleep deprived state.  So im sure its going to have things that can be improved or work better, but at least the bones of it are there now.</div>

<div><br></div><div>let me know your thoughts.</div><div><br></div><div>Jay</div><div><br></div><div><br></div><div><br><div class="gmail_quote">On Mon, Feb 21, 2011 at 11:08 PM, <a href="mailto:Jmesquita@freeswitch.org">Jmesquita@freeswitch.org</a> <span dir="ltr">&lt;<a href="mailto:jmesquita@freeswitch.org">jmesquita@freeswitch.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Just an idea for the other developers. Wouldn&#39;t be cool to have and event thrown by each module that does authentication so that other application modules are able to listen in those events and do whatever with it? Some people might even like to have that running an eel daemon and throw some snmp traps based on that?<br>


<br>
Just an idea that might be completely ridiculous or might raise some interest. Events are pretty cheap so there wouldn&#39;t be a lot of overhead involved.<br>
<br>
Regards,<br>
<br>
João Mesquita<br>
<div><div></div><div class="h5"><br>
On 21/02/2011, at 07:28, Spencer Thomason &lt;<a href="mailto:spencer@5ninesolutions.com">spencer@5ninesolutions.com</a>&gt; wrote:<br>
<br>
&gt; After tinkering with it, I think that might be the best way.  The<br>
&gt; iptables method is cool but I&#39;d like to have more dynamic control and<br>
&gt; with Fail2Ban looking at the challenges you could specifically ignore<br>
&gt; certain high traffic IPs and block others.  What would be very cool is<br>
&gt; if instead of logging every challenge, a log entry was written if<br>
&gt; there was a high number from a specific IP, then you could decide what<br>
&gt; to do about it with fail2ban, similar to the pike module for opensips<br>
&gt; does.<br>
&gt;<br>
&gt;<br>
&gt; On Feb 21, 2011, at 1:31 AM, <a href="mailto:covici@ccs.covici.com">covici@ccs.covici.com</a> wrote:<br>
&gt;<br>
&gt;&gt; I would change sip auth failure to challenge and then have sufficient<br>
&gt;&gt; times to only block if there are too many challenges in a certain<br>
&gt;&gt; time.<br>
&gt;&gt; I am not even sure the failure works any more in recent gits.<br>
&gt;&gt;<br>
&gt;&gt; Spencer Thomason &lt;<a href="mailto:spencer@5ninesolutions.com">spencer@5ninesolutions.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; Yes, that works great if they respond to the challenge with a failed<br>
&gt;&gt;&gt; auth. But the scenario I&#39;m trying to prevent is if they just send the<br>
&gt;&gt;&gt; INVITE and never respond to the challenge.  Fail2Ban will not work as<br>
&gt;&gt;&gt; every endpoint will initially send an INVITE and receive a challenge.<br>
&gt;&gt;&gt; Legit calls will then respond correctly and not be logged as a SIP<br>
&gt;&gt;&gt; auth failure but every call that is challenged will show up as SIP<br>
&gt;&gt;&gt; auth challenge in the logs so there is no regex to differentiate<br>
&gt;&gt;&gt; between legit an non legit traffic.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Spencer<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Feb 20, 2011, at 10:39 PM, Ken Rice wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Fail2Ban ... This is block an IP with too many failed attempts from<br>
&gt;&gt;&gt;&gt; something like SipVicious pretty quickly<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 2/20/11 11:07 PM, &quot;Spencer Thomason&quot; &lt;<a href="mailto:spencer@5ninesolutions.com">spencer@5ninesolutions.com</a>&gt;<br>
&gt;&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;&gt;&gt; We run hosted Freeswitch instances in VMs with the internal profile<br>
&gt;&gt;&gt;&gt;&gt; on<br>
&gt;&gt;&gt;&gt;&gt; port 5060 connecting to clients mostly behind NAT and then the<br>
&gt;&gt;&gt;&gt;&gt; external profile connecting to our proxies only.  Protecting the<br>
&gt;&gt;&gt;&gt;&gt; external profile its straightforward.. we only allow traffic to/<br>
&gt;&gt;&gt;&gt;&gt; from<br>
&gt;&gt;&gt;&gt;&gt; our proxies at the firewall level.  But protecting the internal<br>
&gt;&gt;&gt;&gt;&gt; profile seems to be a bit more difficult because the UACs could be<br>
&gt;&gt;&gt;&gt;&gt; theoretically anywhere on the network.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I&#39;m currently using Fail2Ban to prevent brute force registration<br>
&gt;&gt;&gt;&gt;&gt; and<br>
&gt;&gt;&gt;&gt;&gt; INVITEs on auth failures, e.g.:<br>
&gt;&gt;&gt;&gt;&gt; failregex = \[WARNING\] sofia_reg.c:\d+ SIP auth failure \<br>
&gt;&gt;&gt;&gt;&gt; (REGISTER\)<br>
&gt;&gt;&gt;&gt;&gt; on sofia profile \&#39;\w+\&#39; for \[.*\] from ip &lt;HOST&gt;<br>
&gt;&gt;&gt;&gt;&gt;           \[WARNING\] sofia_reg.c:\d+ SIP auth failure \(INVITE\)<br>
&gt;&gt;&gt;&gt;&gt; on sofia profile \&#39;\w+\&#39; for \[.*\] from ip &lt;HOST&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; My question is, since its part of a normal SIP dialog to challenge<br>
&gt;&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt;&gt; INVITE, is there any way to prevent a possible DoS from just sheer<br>
&gt;&gt;&gt;&gt;&gt; volume of incoming INVITEs on an Internet facing server<br>
&gt;&gt;&gt;&gt;&gt; automatically.  I.e., If you block the logged challenge, you&#39;d<br>
&gt;&gt;&gt;&gt;&gt; block<br>
&gt;&gt;&gt;&gt;&gt; all legitimate INVITEs and registrations.  Since its UDP traffic I<br>
&gt;&gt;&gt;&gt;&gt; couldn&#39;t come up with a way to do it automatically at the iptables<br>
&gt;&gt;&gt;&gt;&gt; level. i.e. number of concurrent connections.  Is there some option<br>
&gt;&gt;&gt;&gt;&gt; to<br>
&gt;&gt;&gt;&gt;&gt; just not respond if a client is sending a number of requests over a<br>
&gt;&gt;&gt;&gt;&gt; certain threshold?  It might not stop them from sending the traffic<br>
&gt;&gt;&gt;&gt;&gt; but pretty soon they&#39;d get the idea that it wasn&#39;t going to go<br>
&gt;&gt;&gt;&gt;&gt; anywhere.  My concern is say there are 50 Freeswitch instances on a<br>
&gt;&gt;&gt;&gt;&gt; box (albeit 8 core, 32GB ram, 8 15K raid 10 storage) and someone<br>
&gt;&gt;&gt;&gt;&gt; starts sending thousands of rouge INVITEs to every VM on a physical<br>
&gt;&gt;&gt;&gt;&gt; box that the CPU load from just challenging the incoming INVITEs<br>
&gt;&gt;&gt;&gt;&gt; would<br>
&gt;&gt;&gt;&gt;&gt; create a DoS.  We the logs regularly to try to catch people doing<br>
&gt;&gt;&gt;&gt;&gt; this<br>
&gt;&gt;&gt;&gt;&gt; sort of thing and drop them at a router upstream of the core<br>
&gt;&gt;&gt;&gt;&gt; network,<br>
&gt;&gt;&gt;&gt;&gt; but I&#39;d like to have it happen without human intervention.  Have I<br>
&gt;&gt;&gt;&gt;&gt; completely over thought this and am missing something obvious?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Thanks,<br>
&gt;&gt;&gt;&gt;&gt; Spencer<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt; FreeSWITCH-users mailing list<br>
&gt;&gt;&gt;&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt;&gt;&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt;&gt;&gt;&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt;&gt;&gt;&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; FreeSWITCH-users mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt;&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt;&gt;&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt;&gt;&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; FreeSWITCH-users mailing list<br>
&gt;&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt;&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt;&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Your life is like a penny.  You&#39;re going to lose it.  The question is:<br>
&gt;&gt; How do<br>
&gt;&gt; you spend it?<br>
&gt;&gt;<br>
&gt;&gt;        John Covici<br>
&gt;&gt;        <a href="mailto:covici@ccs.covici.com">covici@ccs.covici.com</a><br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; FreeSWITCH-users mailing list<br>
&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; FreeSWITCH-users mailing list<br>
&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br>
_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Sincerely<br><br>Jay<br>
</div>