<?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>Miguel Moraleda &#187; security</title>
	<atom:link href="http://as3.miguelmoraleda.com/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://as3.miguelmoraleda.com</link>
	<description>Unity3D &#38; Actionscript examples, resources, source code, etc</description>
	<lastBuildDate>Fri, 16 Apr 2010 12:55:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Protecting your SWF with secureSWF</title>
		<link>http://as3.miguelmoraleda.com/2010/02/08/protecting-your-swf-with-secureswf/</link>
		<comments>http://as3.miguelmoraleda.com/2010/02/08/protecting-your-swf-with-secureswf/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 15:31:15 +0000</pubDate>
		<dc:creator>miguelMoraleda</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://as3.miguelmoraleda.com/?p=255</guid>
		<description><![CDATA[I’ve been worried about this topic for a long time now, especially when I work as freelancer. Because every time I demo a project to a clients, I always fear they will decompile the SWF and disappear. I might be paranoid, but not too far from reality. Fortunately I’ve never had any problems like this, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kindisoft.com/"><img class="alignleft size-full wp-image-263" title="secureswf-150" src="http://as3.miguelmoraleda.com/wp-content/uploads/2010/02/secureswf-150.jpg" alt="secureSWF" width="150" height="175" /></a><br />
I’ve been worried about this topic for a long time now, especially when I work as freelancer.  Because every time I demo a project to a clients, I always fear they will decompile the SWF and disappear. I might be paranoid, but not too far from reality. Fortunately I’ve never had any problems like this, but I still prefer to be protected. Besides, these attacks are used for other purposes such as intellectual property theft, search for security flaws and exploits, and so on. It is also a very important issue when your application is of commercial value, as it is even more tempting to get the full benefit in a gruesome way.<br />
Anyone with a copy of a Flash decompiler such as ASV or Sothink Decompiler can look at your ActionScript code. Suddenly, your licensing code, copy protection mechanisms, and proprietary logic are available for all to see – whether it’s legal or not. Anyone can use the details of your software for whatever reason they like. They can search for security flaws to exploit, steal unique ideas, crack programs, etc.</p>
<p>ActionScript is very easy to decompile. There are over 22 decompilers today. This is not a design flaw in the language; it’s a reality of all <a href="http://en.wikipedia.org/wiki/Interpreted_language">interpreted language</a> such as Java, .NET, etc.</p>
<p>The encryption of the SWF (more like the <a href="http://en.wikipedia.org/wiki/Obfuscation"> code obfuscation</a>) is to make the code difficult to understand. It’s noteworthy that it’s not actual encryption.</p>
<p>Despite all the protection it gives us, the <a href="http://en.wikipedia.org/wiki/Obfuscation">obfuscation code</a> is still vulnerable to illegal redistribution; anyone can download the SWF and republish it. To solve this issue, <a href="http://www.kindisoft.com/"> secureSWF</a> has a protective system of domains (the movie will only work on the list of domains we specify) and also an encrypted loader (generates a separate swf to load our movie, assigns an encrypted name to the swf and decrypt it at runtime making it harder to download our swf), the grace of this protects us from attackers or SWF rippers grabbers.</p>
<p>secureSWF is the most sophisticated ActionScript obfuscation, code protection, and SWF encryption solution for Adobe’s Flash and Flex.<br />
It provides state-of-the-art techniques to stop Flash decompilers, prevent illegal copying and redistribution, and help you increase your Flash application’s security.<br />
<br/></p>
<h4>What secureSWF&#8217;s SWF Encryption Does</h4>
<p><br/></p>
<li><strong>Control Flow Obfuscation</strong></li>
<p>Changes possible areas of the code flow that doesn’t affect the way the application runs. It also inserts extra control flow statements in certain areas of the code to make decompilation virtually impossible.</p>
<li><strong>Dynamic Code Wrapping</strong></li>
<p>Dynamically wraps up the ActionScript byte-code blocks in SWF files to make finding entry points of the code very difficult for Flash decompilers. This will usually crash the decompiler.</p>
<li><strong>Statement-level Randomization</strong></li>
<p>Will randomly restructure the sequence of the byte-code instructions that the decompiler uses to reform a complete ActionScript statement. It removes all the possible links between the compiled byte-code and the ActionScript source code making decompiling a very difficult process.</p>
<li><strong>String Encryption</strong></li>
<p>Will replace sensitive literal strings in your code with a function call that gets the string from an encrypted byte array.<br />
<br/></p>
<h4>The Information secureSWF Removes</h4>
<p><br/></p>
<li>Packages (and internal namespaces for AS3)</li>
<li>Classes</li>
<li>Functions (getters and setters as well)</li>
<li>Variables (local and global variables for AS1 and AS2)</li>
<li>Handles Inheritance and Polymorphism</li>
<li>Dynamic Variables (even the ones done by AS2 eval)</li>
<li>Removes Function Parameters Names</li>
<li>Frame Labels</li>
<li>Symbol Instance Names</li>
<li>Button Names</li>
<li>Textfield Names</li>
<li>Edit Textfield Variables</li>
<li>SWF Metadata</li>
<li>ActionScript 3 Metadata</li>
<p><br/></p>
<h3><a href="http://www.kindisoft.com/secureSWF/getting-started.php">Getting Started secureSWF</a></h3>
<p><br/></p>
<h3><a href="http://www.kindisoft.com/secureSWF/help/v3.4/">secureSWF Manual</a></h3>
<p><br/></p>
<h4>Demo</h4>
<p><br/><br />
Only to show you the result of the <a href="http://www.kindisoft.com/">secureSWF</a> encryption I wrote this basic class.<br />
<br/></p>
<h5>Before</h5>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageAlign</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageQuality</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">StageScaleMode</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _draw:Sprite;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			configStage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			createDraw<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			testFor<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> testFor<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">10</span>; i++<span style="color: #66cc66;">&#41;</span> 
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createDraw<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_draw = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>_draw<span style="color: #66cc66;">&#41;</span>;
			_draw.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xff0000<span style="color: #66cc66;">&#41;</span>;
			_draw.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
			_draw.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> configStage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">scaleMode</span> = StageScaleMode.<span style="color: #006600;">NO_SCALE</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">quality</span> = StageQuality.<span style="color: #006600;">BEST</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">align</span> = StageAlign.<span style="color: #006600;">TOP_LEFT</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h5>After</h5>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> <span style="color: #b1b100;">do</span> <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">Object</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #b1b100;">do</span><span style="color: #66cc66;">&#40;</span>  <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> _local_1:boolen;
			<span style="color: #000000; font-weight: bold;">var</span> _local_2 = false<span style="color: #66cc66;">&lt;</span>NULL<span style="color: #66cc66;">&amp;</span>param2;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_2<span style="color: #66cc66;">&amp;&amp;</span>_local_1 <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_2 <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">this</span>.<span style="color: #b1b100;">break</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_2 <span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					<span style="color: #0066CC;">this</span>.<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
					<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_2<span style="color: #66cc66;">&amp;&amp;</span>_local_2 <span style="color: #66cc66;">&#41;</span>
					<span style="color: #66cc66;">&#123;</span>
						<span style="color: #0066CC;">this</span>. <span style="color: #b1b100;">do</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
					<span style="color: #66cc66;">&#125;</span>
					<span style="color: #b1b100;">return</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>  <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> _local_1:boolen;
			<span style="color: #000000; font-weight: bold;">var</span> _local_2 = ^===<span style="color: #66cc66;">&lt;</span>-^false++;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_1 <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				 <span style="color: #b1b100;">case</span> = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_2<span style="color: #66cc66;">&amp;&amp;</span>this <span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
				<span style="color: #66cc66;">&#125;</span>
				addChild<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>. <span style="color: #b1b100;">case</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_2<span style="color: #66cc66;">&amp;&amp;</span>_local_1 <span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					<span style="color: #0066CC;">this</span>. <span style="color: #b1b100;">case</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">16711680</span><span style="color: #66cc66;">&#41;</span>;
					<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_1 <span style="color: #66cc66;">&#41;</span>
					<span style="color: #66cc66;">&#123;</span>
						_local_2 = <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&gt;</span><span style="color: #cc66cc;">0</span>;
						drawRect<span style="color: #66cc66;">&#40;</span>,<span style="color: #0066CC;">this</span> <span style="color: #0066CC;">instanceof</span> <span style="color: #cc66cc;">0</span>-<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
						<span style="color: #0066CC;">this</span>. <span style="color: #b1b100;">case</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
					<span style="color: #66cc66;">&#125;</span>
				<span style="color: #66cc66;">&#125;</span>
				<span style="color: #b1b100;">return</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span>  <span style="color: #b1b100;">case</span>:Sprite;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #b1b100;">break</span><span style="color: #66cc66;">&#40;</span>  <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> _local_1:boolen;
			<span style="color: #000000; font-weight: bold;">var</span> _local_2:<span style="color: #0066CC;">Object</span>;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_2 <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">scaleMode</span> = StageScaleMode.<span style="color: #006600;">NO_SCALE</span>;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _local_2 <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">quality</span> = StageQuality.<span style="color: #006600;">BEST</span>;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>-<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">||</span>this <span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">align</span> = StageAlign.<span style="color: #006600;">TOP_LEFT</span>;
				<span style="color: #66cc66;">&#125;</span>
				<span style="color: #b1b100;">return</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span>  <span style="color: #b1b100;">do</span><span style="color: #66cc66;">&#40;</span>  <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> _local_2 = <span style="color: #000000; font-weight: bold;">true</span> as param2<span style="color: #66cc66;">&gt;</span>=param2;
			<span style="color: #000000; font-weight: bold;">var</span> _local_3:boolen;
			<span style="color: #000000; font-weight: bold;">var</span> _local_1:<span style="color: #0066CC;">int</span>;
			<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span> _local_1<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">10</span> <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">return</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><br/><br />
You can see, the result is very crazy, but the code executes exactly the same as the original. For this example I used the standard encryption preset (among other presets), but with more security settings my decompiler crashed. Very nice!!<br />
Well, this example is the end of my post. I hope you like it. Any comment or suggestions will be welcomed.</p>
<p>Sponsored by <a href="http://www.kindisoft.com/"> secureSWF</a></p>
]]></content:encoded>
			<wfw:commentRss>http://as3.miguelmoraleda.com/2010/02/08/protecting-your-swf-with-secureswf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
