<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">Security - SeeSharp</title>
  <icon>http://www.hightech.ir/favicon.ico</icon>
  <logo>http://www.hightech.ir/favicon.png</logo>
  <updated>2009-04-13T17:31:00</updated>
  <subtitle type="html">A C# development blog</subtitle>
  <id>http://www.hightech.ir/tags/security/atom</id>
  <link rel="alternate" type="text/html" hreflang="en" href="/tags/security/atom"/>
  <link rel="self" type="application/atom+xml" href="http://www.hightech.ir/Tags/Security/ATOM"/>
  <generator uri="http://oxite.net" version="1.0">Oxite</generator>
  <entry>
    <title type="html">Key-Gen for .NET Apps!</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/key-gen-for-net-apps"/>
    <id>http://www.hightech.ir/SeeSharp/key-gen-for-net-apps</id>
    <updated>2009-10-18T14:02:01.123</updated>
    <published>2009-04-13T17:31:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="Security" />
    <category term="Cracking" />
    <content type="html" xml:lang="en">
      &lt;p&gt;You all know that .NET generated application convert the high-level codes from source language (e.g. C#) and converts them to IL. Basically, if you could convert the IL code back to the high-level language, you'd have the original source code of the application, and to some extent, you can do this, but this is the story for another post. Today, I'd want to show you how your public licensing API would provide a very easy way to crack open your own application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note: I take no responsibility for how you use the piece of information. By reading these instructions  you accept the sole responsibility of any illegal use. The names and information provided here are changed to save the innocent.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose you've put a lot of energy and time and written your state-of-the-art application and you've released it to the market. After a while some junior software developer tries to inspect your assembly to see how you've managed to do a special tricks or two. (Mind you, that's not what I'd suggest you do, dear reader, because you might end-up facing copyright infringement lawsuits). 

Now when he's inspecting the API, he encounters your licensing API, and even worst, those API are public:&lt;/p&gt;  

&lt;pre class=&quot;brush:c-sharp&quot;&gt;
public class RSALicenseCodec : IEncoder, IDecoder
{
}

public class License
{
   public Guid LicenseId = Guid.NewGuid();
   public DateTime EndTime;   public string LicensedTo;
   public DateTime PurchaseDate;
   public LicenseType Type;
   public DateTime StartTime;
}

public static string LicenseToKey(IEncoder encoder, License license)
{
}

public static License KeyToLicense(IDecoder decoder, string key)
{
}
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note: Actual implementation was cut off!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/_Z5KTIfnfuNs/SeM3oQHECXI/AAAAAAAAANo/1VHcQuUrtKA/s1600-h/Licensing-API%5B4%5D.png&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline;&quot; title=&quot;Licensing-API&quot; alt=&quot;Licensing-API&quot; src=&quot;http://lh6.ggpht.com/_Z5KTIfnfuNs/SeM3pRERlsI/AAAAAAAAANs/ZD6epIBV_3M/Licensing-API_thumb%5B2%5D.png?imgmax=800&quot; width=&quot;305&quot; border=&quot;0&quot; height=&quot;109&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Now with all these public API, only thing between a novice developer with bad intentions and a perfect key-gen to for application, is the copyright infringement lawsuit! Do you think that alone is enough?&lt;/p&gt;

&lt;p&gt;I don't want to give you the idea that by only making these API private you're safe, no. There are a lot of things you should do before you're even close to being safe with hackers and crackers, but in my opinion taking all the care would no save you either. Almost nothing can stop a motivated cracker.&lt;/p&gt;
    </content>
  </entry>
  <entry>
    <title type="html">Application Security : The Very Least</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/application-security-very-least"/>
    <id>http://www.hightech.ir/SeeSharp/application-security-very-least</id>
    <updated>2009-09-27T08:27:58.837</updated>
    <published>2008-10-12T09:54:00.003</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="NET" />
    <category term="Security" />
    <category term="CodeAnalysis" />
    <content type="html" xml:lang="en">
      When developing applications, security measurements should be thought of upfront. Security is even a greater issue when the application exposes an online data source, transfers sensitive data across the wire, etc. But what happens when a careless developer hard-codes significant security information into the application code, without even obfuscating the application? Well, you WILL get hacked sooner or later. Your system will be misused without you even knowing it, and let's hope you have a backup strategy, because there is a change that your whole database will be erased by malign hacker. Don't you agree?&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;a href=&quot;http://www.hightech.ir/BlogPics/ApplicationSecurityTheVeryLeast_9A6B/AnalysedApp.png&quot;&gt;&lt;img style=&quot;border-width: 0px;&quot; alt=&quot;Analysed App&quot; src=&quot;http://www.hightech.ir/BlogPics/ApplicationSecurityTheVeryLeast_9A6B/AnalysedApp_thumb.png&quot; border=&quot;0&quot; height=&quot;140&quot; width=&quot;840&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;&lt;span style=&quot;;font-family:Tahoma;font-size:78%;&quot;  &gt;Connection string is hard-coded into the application code.&lt;/span&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;Here's what I think you should consider when building application that works over the Internet :&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;   &lt;li&gt;Never hard-code any username / password into the application &lt;/li&gt;    &lt;li&gt;Never store passwords in configuration files. &lt;/li&gt;    &lt;li&gt;Never connect directly to your database, use a service layer instead. Limit the physical / logical access to your database machine only to the server running the service layer. &lt;/li&gt;    &lt;li&gt;At least obfuscate the assemblies that contain security related code. &lt;/li&gt;    &lt;li&gt;Always store encrypted passwords in your database. That goes for application users' password as well. Apply &lt;a href=&quot;http://en.wikipedia.org/wiki/Password_salting&quot;&gt;salt&lt;/a&gt; to all passwords. &lt;/li&gt;    &lt;li&gt;Consider using two separate databases for your web site and application. &lt;/li&gt;    &lt;li&gt;Consider using an ORM for your data access. At the very least use Stored Procedures or parameterized queries if you're directly using ADO.NET. &lt;/li&gt;    &lt;li&gt;Always use a logging mechanism. Log actions performed by power users. Log unsuccessful login attempts.   &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;/p&gt; &lt;center&gt;&lt;a href=&quot;http://www.hightech.ir/BlogPics/ApplicationSecurityTheVeryLeast_9A6B/PasswordValidation.png&quot;&gt;&lt;img style=&quot;border-width: 0px; margin: 0px;&quot; alt=&quot;Password Validation&quot; src=&quot;http://www.hightech.ir/BlogPics/ApplicationSecurityTheVeryLeast_9A6B/PasswordValidation_thumb.png&quot; border=&quot;0&quot; height=&quot;149&quot; width=&quot;460&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;&lt;span style=&quot;;font-family:Tahoma;font-size:78%;&quot;  &gt;Password are stored as clear text. Power-User Validation is hard-coded into the code.&lt;/span&gt;&lt;/center&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;  &lt;p&gt;Honestly, the list is so long that I had to limit it to the VERY BASIC rules only, like things you think everyone knows, but as it turned out there are people out there that do not. Even if you do all the above there's a good chance that you still get attacked, but these are the VERY LEAST rules that you should always follow. &lt;br /&gt;&lt;br /&gt;Note : Pictures are taken from a real application! Sensitive information are erased to protect the innocent(!).     &lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6069495622049300789-5778093358561144940?l=heskandari.blogspot.com'/&gt;&lt;/div&gt;
    </content>
  </entry>
</feed>
