title: Cut characters for a string in C
body: <p>Here's some code.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
      char npass[] = "$1$bUZXMjKz$08Ps4NPTfj6ZNkoqrsP/D.";
      char salt [12];
      int i;
      for (i = 0; i &lt; 12; i++)
      {
              npass[i+3] = salt[i];
              i++;
      }
      salt[12] = '\0';
      puts(salt);
      return 0;
  }
  </code></pre>
  
  <p>Basically, <em>npass</em> is an <code>md5crypt</code> result(password is admin). In order to verify this, I need to separate the salt from the result.</p>
  
  <p>My understanding is that a string in <code>C</code> is really a <code>char array</code> containing all the letters alone(with <code>'\0'</code> at the end). I use a <code>for</code> loop to cut the first three characters but I guess because of <code>ASLR</code>, the results that I get are always random ones. Actually, <em>without</em> <code>ASLR</code>, I get the same random result always.</p>