<div dir="ltr"><div>OK, i realize my mistake, SREV_NET_DATA_IN event is processed before msg->rcv info is set. This is kind of nice since we get completely raw message direct from receive socket. :)<br><br></div>Thank you.<br>

<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 1, 2014 at 5:49 AM, Muhammad Shahzad <span dir="ltr"><<a href="mailto:shaheryarkh@gmail.com" target="_blank">shaheryarkh@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>OK, so writing kamailio module was fun and easy. All thanks to Daniel-Constantin for providing very useful hints, it took hardly 2-3 hours to write up a functional module that exposes data received on kamailio socket and data that is about to be sent out, in an event route, where it can be manipulated e.g. to encode and decode per custom encryption algorithms defined by script writer. Here is bleeding edge code,<br>


<br><a href="http://webrtc.voip-demos.com/obfuscate.c.txt" target="_blank">http://webrtc.voip-demos.com/obfuscate.c.txt</a><br><br></div>Most of the code is borrowed from topoh, nosip and msrp modules and works fine. There is just one little problem, that is unlike nosip module, the event route for obfuscate module gives error when i try to print source address using $si and $sp variables.<br>


<br></div>Here is an example kamailio.cfg<br><br>========================<br>loadmodule "nosip.so"<br>loadmodule "obfuscate.so"<br><br>...<br><br>event_route[nosip:msg] {<br>    xlog("L_INFO", "[$pr:$si:$sp]: Received nosip message '$mb' \n");<br>


}<br><br>event_route[obfuscate:msg] {<br>    if (is_msg_obfuscated()) {<br>        xlog("L_INFO", "[$pr:$si:$sp]: Received obfuscated message '$mb' \n");<br>        $avp(msg) = $mb;<br>    } else {<br>


        xlog("L_INFO", "[$pr:$dd:$dp]: Sending obfuscated message '$mb' \n");<br>        $avp(msg) = $mb;<br>    };<br>}<br>========================<br><br><br></div>using telnet when i send some random junk i get following in kamailio logs,<br>


<br>========================<br>webrtc[13284]: : <span style="color:rgb(255,0,0)"><span style="background-color:rgb(255,255,255)">pv [../../parser/../ip_addr.h:669]: ip_addr2sbuf(): BUG: ip_addr2sbuf: unknown address family 0</span></span><br>


webrtc[13284]: INFO: <script>: <span style="color:rgb(255,0,0)">[NONE::0]</span>: Received obfuscated message 'lkasndkasldnaklsndklaskndklasnkldnasklndklasndlkasndkasndlkasnkldanskldnaslkdnlkasndlkasnldnaskdnlasdn#015#012#015#012'<br>


<br>webrtc[13284]: INFO: <script>: <span style="color:rgb(106,168,79)">[tcp:<a href="http://192.168.100.11:55206" target="_blank">192.168.100.11:55206</a>]</span>: Received nosip message 'lkasndkasldnaklsndklaskndklasnkldnasklndklasndlkasndkasndlkasnkldanskldnaslkdnlkasndlkasnldnaskdnlasdn#015#012#015#012'<br>


========================<br><div><br><br></div><div>Can you guys give any hint, what is wrong here? The "received msg" code is almost identical to nosip module yet, nosip module is able to show $si and $sp values while my module can not.<br>


</div><div><br></div>Also is it possible to expose destination socket address (ip + port) for "sent msg" (i.e. the destination socket where kamailio is about to send some sip message).<br><div><br><div>Thank you.<br>


</div><div><div><span style="background-color:rgb(255,255,255)"><span></span></span><br><br></div></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 31, 2014 at 4:38 PM, Muhammad Shahzad <span dir="ltr"><<a href="mailto:shaheryarkh@gmail.com" target="_blank">shaheryarkh@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Thanks for good insight in to this topic.<br><br></div>As mentioned in my first email, there are a number of reasons for trying out custom encryption schemes. Low-end android devices is just one of them. There is a huge market for low-end android devices in south and south east Asia for example, where over 35% of world population lives. The people there are poor and don't have much understanding of latest cutting edge smart devices and related technologies. Big brands like Apple, Samsung, Nokia etc. are virtually non-existent or have so high price that people simply can't afford them. So cheap Chinese and Indian cell phones which barely run Android are considered "smart phones" and are very popular here. Using SSL, TLS, DTLS etc. are nightmare on these devices.<br>



<br></div><div>The other reasons to develop and try out custom encryption algorithms are voip blockage by GSM providers in various Middle Eastern and European counties,<br></div><div><br><a href="http://www.linphone.org/news/11/26/Linphone-over-3G.html" target="_blank">http://www.linphone.org/news/11/26/Linphone-over-3G.html</a><br>



<a href="http://xerocrypt.wordpress.com/2012/07/06/inspecting-your-packets/" target="_blank">http://xerocrypt.wordpress.com/2012/07/06/inspecting-your-packets/</a><br><a href="http://www.telecomrecorder.com/world-premium-telecom/pak-telecom-authority/pta-and-ip-blocking/" target="_blank">http://www.telecomrecorder.com/world-premium-telecom/pak-telecom-authority/pta-and-ip-blocking/</a><br>



<br></div><div>And the rogue agencies of evil empires,<br><br><a href="http://en.wikipedia.org/wiki/Five_Eyes" target="_blank">http://en.wikipedia.org/wiki/Five_Eyes</a><br><a href="http://en.wikipedia.org/wiki/PRISM_%28surveillance_program%29" target="_blank">http://en.wikipedia.org/wiki/PRISM_%28surveillance_program%29</a><br>



<a href="http://en.wikipedia.org/wiki/Booz_Allen_Hamilton#Activities_in_foreign_countries" target="_blank">http://en.wikipedia.org/wiki/Booz_Allen_Hamilton#Activities_in_foreign_countries</a><br><a href="http://www.itv.com/news/update/2013-09-06/report-us-and-uk-agencies-cracked-encryption-codes/" target="_blank">http://www.itv.com/news/update/2013-09-06/report-us-and-uk-agencies-cracked-encryption-codes/</a><br>



<br></div><div>Nearly all encryption algorithms are defined and advocated by US and UK intelligence agencies and it is quite obviously possible that they either have crack or backdoors into them. So, we can't blindly trust them anymore and should look into defining our own algorithms and security standards.<br>



<br></div><div>Just to note, i don't claim that ITV or any other custom encryption discussed here can or would resolve all these problems. The main focus is on trying something new and out of the box to improve the voip and network security conditions. I find Kamailio as open source SIP server and doubango as open source SIP SDK as best platforms for these efforts and experimentation.<br>



</div><div><br></div><div>Thank you.<br></div><div><br><br></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 31, 2014 at 2:08 PM, Daniel Tryba <span dir="ltr"><<a href="mailto:daniel@pocos.nl" target="_blank">daniel@pocos.nl</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[remove dev from cc]<br>
<div><br>
> The key purpose of ITV encryption is to avoid making a pattern of any sort.<br>
<br>
</div>The pattern is in SIP itself, regardless of encryption.<br>
<br>
-OPTIONS keepalives and response at regular intervals of nearly fixed size.<br>
-INVITE and its predictable responses of nearly fixed sizes per type followed<br>
by a steady stream of upd on random ports with the same bandwidth flowing both<br>
sides.<br>
<br>
Unless this random utp traffic is encrypted it is obvious you are using rtp<br>
with something like SIP. Even if it is encrypted the symmetric streams give<br>
away clues. A simple xor isn't enough, silences will result in the same<br>
pattern.<br>
<br>
Daniel(-Constanting) already suggested interval randomizing (which is to be<br>
applied to any response) and padding of all data.<br>
<br>
But I wouldn't trust any non vetted encryption scheme, it is much easier to<br>
fix timing/padding with the standard tls scheme. Which brings me to the<br>
question: what kind of device on the market capable of running apps isn't fast<br>
enough for TLS?<br>
<div><div><br>
_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>