<?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>Felipe Barriga Richards &#187; secur32.dll</title>
	<atom:link href="http://blog.felipebarriga.cl/tag/secur32-dll/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.felipebarriga.cl</link>
	<description>Blog personal de Felipe Barriga Richards</description>
	<lastBuildDate>Sat, 17 Jul 2010 23:52:35 +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>GPL Lively Client Project (OLD POST)</title>
		<link>http://blog.felipebarriga.cl/otros/gpl-lively-client-project-old-post/</link>
		<comments>http://blog.felipebarriga.cl/otros/gpl-lively-client-project-old-post/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 22:20:10 +0000</pubDate>
		<dc:creator>fbarriga</dc:creator>
				<category><![CDATA[Otros]]></category>
		<category><![CDATA[Lively]]></category>
		<category><![CDATA[reverse engineering]]></category>
		<category><![CDATA[secur32.dll]]></category>

		<guid isPermaLink="false">http://blog.felipebarriga.cl/?p=78</guid>
		<description><![CDATA[Introduction The objective of this project is to create an GPL client to Lively.com (Dead project) As the protocol is not available, the work is based on different techniques like reverse engineering, sniffers and common sense. Protocol After running a protocol analyzer (wireshark), I found that the Lively client uses XMPP (Jabber) protocol for authentication [...]]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>The objective of this project is to create an GPL client to Lively.com (<strong>Dead project</strong>)<br />
<span id="more-78"></span><br />
As the protocol is not available, the work is based on different techniques like reverse engineering, sniffers and common sense.</p>
<h1>Protocol</h1>
<p>After running a protocol analyzer (wireshark), I found that the Lively client uses XMPP (Jabber) protocol for authentication and messaging.</p>
<p>After checking the files on Google/Lively/Flex is obviuos that some of the code was made using Adobe Flex technology. The good new is that Sothink SWF Decompiler is able to dissamble the SWF file like Login.swf, so I expect to be able to analyze how to login to the server.</p>
<p>Using API Monitor I was able to determine that the library used to encrypt the XMPP messages is secur32.dll, so I’ve made a dll proxy to be able to read the data before to get encrypted and when it comes back, after been decrypted.</p>
<p>Also using HxD I was able to read the memory of the application that seems to be made with Visual C++ for 3D (DirectX) and Adobe Flash for windows and forms, I could check the strings before be encrypted and send to the server. The messages are in some kind of XML encrypted inside a XMPP message.</p>
<h1>Login.SWF Decompiled</h1>
<p>After decompiling and analyzing the code of <strong>\Google\Lively\flex\Login.SWF</strong> I’ve found:<br />
file: <strong>\LoginController.as</strong>:</p>
<pre>public function doLogin() : void
{
	username = login.username.text;
	if (useStoredPassword)
	{
	}// end if
	Antenna.instance.sendCommand("_l", login.remember.selected,
		!passwordChanged, login.username.text, login.password.text);
	return;
}// end function</pre>
<p>file: <strong>\Action\com\google\g3dweb\common\Antenna.as</strong>:</p>
<pre>public function sendCommand(... args) : Object
{
	if (!debugMode)
	{
		return ExternalInterface.call.apply(null, args);
	}// end if
	log("ANTENNA: sendCommand(" + args.join(", ") + ")");
	return {};
}// end function</pre>
<p>So in this way the Visual C++ client interact with the SWF files.</p>
<h1>Secur32.dll Proxy</h1>
<p>To been able to read the data that is send and received, I’ve done a dll proxy. More information about how to do it, can be found here:<br />
<a href="http://www.codeproject.com/KB/DLL/CreateYourProxyDLLs.aspx">http://www.codeproject.com/KB/DLL/CreateYourProxyDLLs.aspx</a></p>
<p>The source code of the dll proxy is here: <a href="http://blog.felipebarriga.cl/wp-content/uploads/2009/11/secur32.zip">secur32.zip</a> and the compiled library is here: <a href="http://blog.felipebarriga.cl/wp-content/uploads/2009/11/secur32.dll">secur32.dll</a></p>
<p>To use it, you need to create a directory in c:\logs and copy the proxy secur32.dll to the Lively directory.<br />
After doing that, rename it to secur31.dll and copy the original secur32.dll (system32) to the Lively directory.<br />
Rename the original secur32.dll in the Lively directory to secur32_.dll<br />
After that, you need to edit the client.exe and replace the string: “secur32.dll” to “secur31.dll” (using an hex editor).<br />
Now you’re done. So execute the client.exe and watch the log files in c:\logs\</p>
<p>Here you can see an example of how looks the dump:</p>
<pre>= Init =
[EncryptMessage] 0 START
cBuffers: 4
[EncryptMessage] 0 buffer[1] size: 130
[EncryptMessage] 0 buffer[1] data:
&lt;stream:stream to="gmail.com" xml:lang="en" version="1.0"
xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client"&gt;

[EncryptMessage] 0 END
[DecryptMessage] 0 START
cBuffers: 4
[DecryptMessage] 0 buffer[1] size: 176
[DecryptMessage] 0 buffer[1] data:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;&amp;lt
;stream:stream from="gmail.com" id="2352CC46DE11B711"
version="1.0"xmlns:stream="http://etherx.jabber.org/streams"
 xmlns="jabber:client"&gt;
[DecryptMessage] 0 END
[DecryptMessage] 0 START
cBuffers: 4
[DecryptMessage] 0 buffer[1] size: 166
[DecryptMessage] 0 buffer[1] data:
&lt;stream:features&gt;&lt;mechanisms
xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&gt;&lt;mechanism&gt;PLAIN&lt;/mechanism&gt;
&lt;mechanism&gt;X-GOOGLE-TOKEN&lt;/mechanism&gt;&lt;/mechanisms&gt;
&lt;/stream:features&gt;
[DecryptMessage] 0 END
[EncryptMessage] 0 START
cBuffers: 4
[EncryptMessage] 0 buffer[1] size: 385
[EncryptMessage] 0 buffer[1] data:
&lt;auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl"
mechanism="X-GOOGLE-TOKEN"&gt;XXXXXXXXXXXXXXXXXXXXXXX&lt;/auth&gt;
[EncryptMessage] 0 END
[DecryptMessage] 0 START
cBuffers: 4
[DecryptMessage] 0 buffer[1] size: 51
[DecryptMessage] 0 buffer[1] data:
&lt;success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/&gt;
[DecryptMessage] 0 END
[EncryptMessage] 0 START
cBuffers: 4
[EncryptMessage] 0 buffer[1] size: 130
[EncryptMessage] 0 buffer[1] data:
&lt;stream:stream to="gmail.com" xml:lang="en" version="1.0" xmlns:stream="
http://etherx.jabber.org/streams" xmlns="jabber:client"&gt;

[EncryptMessage] 0 END
[DecryptMessage] 0 START
cBuffers: 4
[DecryptMessage] 0 buffer[1] size: 176
[DecryptMessage] 0 buffer[1] data:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;stream:stream
from="gmail.com" id="92A4B029617BC47C" version="
1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client"&gt;
[DecryptMessage] 0 END
[DecryptMessage] 0 START
cBuffers: 4
[DecryptMessage] 0 buffer[1] size: 137
[DecryptMessage] 0 buffer[1] data:
&lt;stream:features&gt;&lt;bind xmlns="
urn:ietf:params:xml:ns:xmpp-bind"/&gt;&lt;session xmlns=quot
urn:ietf:params:xml:ns:xmpp-session"/&gt;&lt;/stream:features&gt;
[DecryptMessage] 0 END
[EncryptMessage] 0 START
cBuffers: 4
[EncryptMessage] 0 buffer[1] size: 115
[EncryptMessage] 0 buffer[1] data:
&lt;iq type="set" id="0"&gt;&lt;bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"&gt;&lt;resource&gt;
libjingleplus&lt;/resource&gt;&lt;/bind&gt;&lt;/iq&gt;
[EncryptMessage] 0 END
[DecryptMessage] 0 START
cBuffers: 4
[DecryptMessage] 0 buffer[1] size: 135
[DecryptMessage] 0 buffer[1] data:
&lt;iq id="0" type="result"&gt;&lt;bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"&gt;&lt;jid&gt;
spamfelipe2@gmail.com/libjinglep59B75216&lt;/jid&gt;&lt;/bind&gt;&lt;/iq&gt;
[DecryptMessage] 0 END</pre>
<p>* I’ve replaced my Google Token for security reason. The token is a base64 string that contains my email (username) and a big string (I think that is the token).</p>
<p>The full log dump can be found here: <a href="http://blog.felipebarriga.cl/wp-content/uploads/2009/11/sniff_secur32_a12207.txt">sniff_secur32_A12207.txt</a></p>
<h1>HxD Dump of Lively Client</h1>
<p>The complete file is here: Lively Memory Dump. I don’t know if the strings are correct, maybe they can be a little corrupt.</p>
<p>I have indented the file so is easier to read it, an extract of the file look like this:<br />
Whose room is this?</p>
<pre>&lt;message to="spamfelipe2@gmail.com/libjinglep8F9CEED3"
 type="groupchat" id="73" from="lively 108@3dconf.google.com/-5578858927619228622_2541031"&gt;
	&lt;body&gt;Whose room is this?&lt;/body&gt;
&lt;/message&gt;

&lt;presence to="spamfelipe2@gmail.com/libjinglep568823DE"
id="369" from="lively-108@3dconf.google.com/2912906431397233772_24952671"&gt;
	&lt;show&gt;away&lt;/show&gt;
	&lt;status/&gt;
	&lt;priority&gt;0&lt;/priority&gt;
	&lt;x stamp="20080711T23:40:39" xmlns="jabber:x:delay"/&gt;
	&lt;nick:nick xmlns:nick="http://jabber.org/protocol/nick"&gt;
		lucas3088
	&lt;/nick:nick&gt;
	&lt;plugin xmlns="google:plugin"&gt;
		&lt;capability&gt;
			3dweb
		&lt;/capability&gt;
		&lt;data&gt;
			CxXj3mXEHWy7qEMlwmSCwgwtAZGsPTABSt0BCJelqfr54P+XBBolCMH+w9
WF09OpNBCVn8HzwfON8H8Yl6Wp+vng/5cEINC9k/jkEBonCIC8j6fDzLPXjwEQ
vZ/26/KaiZmgARiXpan6+eD/lwQg0L2T+OQQGioImv+w89Sd6
K/lARDb3fWBzJif2rcBGJelqfr54P+XBCDsiIib9Z6utigaKQitwOyX8r+5p+cBENn0p4
jNi4XxbhiXpan6+eD/lwQg7IiIm/WerrYoGioIy92Nyqf5hcXBARD/s++qqLbP2LsBGJel
qfr54P+XBCDsiIib9Z6utig=
		&lt;/data&gt;
	&lt;/plugin&gt;
	&lt;x xmlns="vcard-temp:x:update"&gt;
		&lt;photo/&gt;
	&lt;/x&gt;
	&lt;user:x xmlns:user="http://jabber.org/protocol/muc#user"&gt;
		&lt;user:item affiliation="none" role="participant"/&gt;
	&lt;/user:x&gt;
&lt;/presence&gt;

&lt;message type="groupchat" from="lively-108@3dconf.google.com/2912906431397233772_24952671"
 to="spamfelipe2@gmail.com/libjinglep568823DE"&gt;
	&lt;plugin xmlns="google:plugin"&gt;
		&lt;capability&gt;
			3dweb
		&lt;/capability&gt;
		&lt;data&gt;
			CAmLApAC7IiIm/WerrYomAIBjAI=
		&lt;/data&gt;
	&lt;/plugin&gt;
&lt;/message&gt;</pre>
<h1>File Format</h1>
<p>After comparing the data on the memory of Lively and the data retrieved using the dll proxy, they match. So the format is basically using XMPP protocol with some extension.</p>
<p>The binary data is send inside tags and following the XMPP standard, they are coded in Base64.</p>
<p>I think that the data containing the coordinates of the user is sended in a binary format, in the tag. As this method is not efficient, the big files are downloaded using an external url. The data is compressed with gzip and samples can be found in the Temporary Internet Files. Those files are compressed with gzip:</p>

<div class="wp-terminal">user@computer:$ file gp\[8\]<br/>gp[8]: gzip compressed data, max compression<br/></div>

<p>It also appear that some of the 3D files are in Gamebryo format:</p>

<div class="wp-terminal">user@computer:$ gzip -d &lt; gp\[8\]  &gt; gp_8.dump<br/>less gp_8.dump<br/></div>

<p>And the file contains this string: <strong>Gamebryo File Format, Version 20.2.0.8</strong></p>
<p>Others interesting strings:</p>
<pre>NIF Creation Information &gt;&gt; P:/Google/3DWeb/Project/Assets/01_normals_logan/Export/NIF
 &amp; Texture Sources/geo/01_normals_logan_export-07.09.27-v01.mb &gt;&gt;
Platform = Generic &gt;&gt; Gamebryo Version:2.2.2.0
Exporter Plugin Version:7.3
&gt;&gt; NiMultiShader Version:7.0
&gt;&gt; Maya Unlimited 7.0

eyebrows.NIF
eyebrows_NiMultiShader
headShape:1
skin.NIF
skin_NiMultiShader
eyer
eyerShape
right_eye.NIF
right_eye_NiMultiShader

NIF Creation Information &gt;&gt; P:/Google/3DWeb/Project/Assets/01_normals_logan/Export/NIF
&amp; Texture Sources/geo/01_normals_logan_export-07.10.17-v02.mb &gt;&gt;
 Platform = Generic &gt;&gt; Gamebryo Version:2.2.2.0
Exporter Plugin Version:7.3
&gt;&gt; NiMultiShader Version:7.0
&gt;&gt; Maya Unlimited 7.0</pre>
<p><a href="http://ns.adobe.com/xap/1.0/">http://ns.adobe.com/xap/1.0/</a></p>
<p>So to me this seems to be a container file, with a great mix of file formats. Here are two files if you want to look at: <a href="http://blog.felipebarriga.cl/wp-content/uploads/2009/11/1.zip">1.zip</a> <a href="http://blog.felipebarriga.cl/wp-content/uploads/2009/11/2.zip">2.zip</a></p>
<p>I got the files from (as the windows cache says):</p>
<ul>
<li><a href="http://clients3.google.com/lively/s/gp?id=6330964325628602226&amp;obj_ed=0">http://clients3.google.com/lively/s/gp?id=6330964325628602226&amp;obj_ed=0</a></li>
<li><a href="http://clients3.google.com/lively/s/gp?id=7778763701070530893&amp;obj_ed=0">http://clients3.google.com/lively/s/gp?id=7778763701070530893&amp;obj_ed=0</a></li>
</ul>
<p>* You need to be logged in and send an special header with an AUTH cookie to be able to get the files</p>
<p>The problem is that Gamebryo doesn’t have a demonstration/trial kit and the format seems to be proprietary. There is a project to open Gamebryo files (NifTools) but it doesn’t work for me. Anyone want to decode it ?</p>
<h1>Useful Links</h1>
<ul>
<li><a href="http://www.mh-nexus.de/">HxD Hexeditor</a></li>
<li><a href="http://www.sothink.com/">Sothink SWF Decompiler</a></li>
<li><a href="http://www.wireshark.org/">Wireshark</a></li>
<li><a href="http://www.lively.com/">Lively Client</a></li>
<li><a href="http://www.apimonitor.com/">API Monitor</a></li>
<li><a href="http://www.xmpp.org/">XMPP Protocol</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.felipebarriga.cl/otros/gpl-lively-client-project-old-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
