CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Services & Projects

Smart Solver



    Smart Solver [View] [Reply] [Top]
    Posted by CinC snarkles On 2005-02-15 17:18:56
    This thread is to discuss the development of the Smart Solver feature.
     
      Version 1.0... [View] [Reply] [Top]
      Posted by Mar Tacheon On 2005-02-26 17:38:41
      Ok,

      This has two options:

      1) verify with a given word (basically it searches the text for the word given, and gives a verified message if it's found)

      2) verify from a file (it checks each word entered against each word in the file, and reports any matches as verification)

      This is only a simple 'proof of concept' page. It just shows that it is possible. It still needs a better seareching method (this is effectively brute force) as well as changes to allow it to be called as a function.

      A test version is here: http://www.crypto-net.com/smartSolver.php

      Code (very messy at the moment, sorry) here:
      <?php
      
      /*******************************************
       * smartSolver.php.			   *
       *   					   *
       * Version: 1.0 			   *
       *					   *
       * Date: 15th Feb 2005		           *
       *                                         *
       * Author: Tacheon                         *
       *					   *
       * Purpose: To validate text that has been *
       *          decrypted or decoded           *
       *					   *
       *******************************************/
      
      ?>
      
      <html>
       <head>
        <title>smartSolver 1.0</title>
        <link rel="StyleSheet" href="./smartSolver.css" type="text/css">
       </head>
       <body bgcolor="#dddddd" text="#000000">
        <br /><center><h2><b>SmartSolver 1.0</b></h2></center>
      
      <?php
      
      if (isset($submit)) 
      {
        echo "<table width=\"450\" border=\"1\" align=\"center\" cellspacing=\"0\" cellpadding=\"10\">\n";
        echo " <tr valign=\"top\">\n";
        echo "  <td>\n";
      
        if ($text == '') 
        { 
          echo "<br /><font color=\"#ff0000\"><b>Error:</b> You must enter text into the Text Entry box!</font><br /><br />\n"; 
        } 
        else if ($verifyMode != 'word' && $verifyMode != 'file')
        { 
          echo "<br /><font color=\"#ff0000\"><b>Error:</b> You must Select a smartSolver option!</font><br /><br />\n"; 
        }
        else 
        { 
          if ($verifyMode == 'word') 
          {
            $mode = "Verify using a word";
          }
          else if ($verifyMode == 'file')
          {
            $mode = "Verify from a dictionary file";
          }
          else 
          {
            $mode = "No options selected!";
          }
      
          echo "<b>Text Entered:</b> $text<br /><br />\n"; 
          echo "<b>Option Selected:</b> $mode<br /><br />\n"; 
          $showResults = 'yes';
        }
      
        echo "  </td>";
        echo " </tr>";
        echo "</table>";
        echo "<br />";
      
        if ($showResults == 'yes')
        {
          echo "<table width=\"450\" border=\"1\" align=\"center\" cellspacing=\"0\" cellpadding=\"10\">\n";
          echo " <tr valign=\"top\">\n";
          echo "  <td>\n";
          echo "   <b>Results:</b><br /><br />\n"; 
      
          if ($verifyMode == 'word') 
          {
            // Check for word...
            
            if ($stringToVerify == '') 
            {
              echo "<br /><font color=\"#ff0000\"><b>Error:</b> No word has been entered!</font><br /><br />\n"; 
            } 
            else
            {
              // Validate with given word...
      
              $success = 'no';
              $words = explode(' ', $text);
              for($i=0;$i<count($words);$i++)
              { 
                if ($words[$i] == $stringToVerify)
                { 
                  echo "<b>VERIFIED</b> - Text contines the word '$stringToVerify'.<br /><br />\n";
                  $success = 'yes';
                  break;
                } 
              }
              if ($success == 'no')
              {
                echo "<b>Word Not Found!!</b><br /><br />\n";
              }
            } // End word check.
          }
          else if ($verifyMode == 'file')
          {
            // Validate with File...
      
            $filename = "sSdictionary.txt";
            $fp = fopen($filename, "r");
            if(!$fp) 
            {
              echo "<br /><font color=\"#ff0000\"><b>Error:</b> Cannot Open File!</font><br /><br />\n";
            }
            else
            {
              $success = 'no';
              $enteredText = explode(' ', $text);
              $words = explode(':', fread($fp, filesize($filename)));
      
              for($j=0;$j<count($enteredText);$j++)
              {
                for($i=0;$i<count($words);$i++)
                {
                  if ($enteredText[$j] == $words[$i])
                  { 
                    echo "<b>VERIFIED</b> - Text contines the word '$words[$i]'.<br /><br />\n";
                    $success = 'yes';
                    break;
                  } 
                }
              }
      
              if ($success == 'no')
              {
                echo "<b>Word Not Found!!</b><br /><br />\n";
              }
      
              if ($showWords == 'yes') 
              {
                echo "<b>Words from file:</b><br /><br />";
                for($i=0;$i<count($words);$i++)
                { 
                  echo "$i : $words[$i] <br />";
                }
              } // End show words
      
              fclose($fp);
      
            } // End file check.
          }
          
          echo "  </td>\n";
          echo " </tr>\n";
          echo "</table>\n";
          echo "<br />\n";
        }
      } 
      else 
      {
        // Input Form...
      
      ?>
      
       <center>
        <form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post">
         <table width="450" border="1" align="center" cellspacing = "0" cellpadding="10">
          <tr valign="top">
           <td>
            <b>Text Entry:</b><br /><br />
            <input type="text" name="text" size="64"><br /><br />
           </td>
          </tr>
         </table>
         <br />
         <table width="450" border="1" align="center" cellspacing = "0" cellpadding="10">
          <tr valign="top">
           <td>
            <b>smartSolver Options:</b><br /><br />
            <input type="radio" name="verifyMode" value="word" /> Verify With Word: &nbsp; &nbsp; <input type="text" name="stringToVerify" size="42"><br /><br />
            <input type="radio" name="verifyMode" value="file" /> Verify With File. &nbsp; &nbsp; <input type="checkbox" name="showWords" value="yes" /> Show Words in File?<br /><br />
           </td>
          </tr>
         </table>
         <br />
         <table border="1" align="center" cellspacing = "0" cellpadding="10">
          <tr valign="top">
           <td>
            <input type="submit" name="submit" value=" Submit " /> &nbsp; &nbsp;
            <input type="reset" value=" Clear " />
           </td>
          </tr>
         </table>
        </form>
       </center>
      
      <?php 
      
      }  // End Submit Check. 
      
      echo " </body>\n";
      echo "</html>\n";
      
      ?>
      

       
        Version 1.1 [as a function] [View] [Reply] [Top]
        Posted by Mar Tacheon On 2005-02-27 01:56:43
        ok - I removed a lot of the crap that was in the other version, and just reduced it to a function:
        function smartSolver ($text,$filename)
        {
          if ($text == '')
          { 
            // Check for text entry...
            return "Error: No Text Entered!"; 
          }
          else if ($filename == '')
          { 
            // Check for filename entry...
            return "Error: No Filename Entered!"; 
          }
          else 
          { 
            // Validate with File...
        
            $fp = fopen($filename, "r");
            if(!$fp) 
            {
              Return "Error: Cannot Open File!";
            }
            else
            {
              $success = 'Not Verified';
              $enteredText = explode(' ', $text);
              $words = explode(':', fread($fp, filesize($filename)));
              for($j=0;$j<count($enteredText);$j++)
              {
                for($i=0;$i<count($words);$i++)
                {
                  if ($enteredText[$j] == $words[$i])
                  { 
                    $success = 'Verified';
                    break;
                  } 
                }
              }
              return $success;
              fclose($fp);
            } // End file check.
          }
        }
        
        comments/suggestions ?

        Tach
         
          optimised... [View] [Reply] [Top]
          Posted by Mar Tacheon On 2005-02-27 02:01:10
          Same function optimised slightly (with help from Iota):
          function smartSolver ($text,$filename)
          {
            if ($text == '')
            { 
              // Check for text entry...
              return "Error: No Text Entered!"; 
            }
            else if ($filename == '')
            { 
              // Check for filename entry...
              return "Error: No Filename Entered!"; 
            }
            else 
            { 
              // Validate with File...
          
              if(!$fp = @fopen($filename, "r")) 
              {
                Return "Error: Cannot Open File!";
              }
              else
              {
                $enteredText = explode(' ', $text);
                $words = explode(':', fread($fp, filesize($filename)));
                for($j=0;$j<count($enteredText);$j++)
                {
                  for($i=0;$i<count($words);$i++)
                  {
                    if ($enteredText[$j] == $words[$i])
                    { 
                      return 'Verified';
                      break;
                    } 
                  }
                }
                return 'Not Verified';
                fclose($fp);
              } // End file check.
            }
          }
          

           
      How about This... [View] [Reply] [Top]
      Posted by 2nd Lt Goatrider On 2005-02-16 06:18:22
      <barking bgcolor="#00000>

      Perhaps I'm misunderstanding the whole purpose of this one, but why not just take the string that was input and print it out in a nice bulleted list or table with all the encodings/decodings. that way, the human that put the text in could look over the list for something that isn't gibberish, and that would be his answer. Wouldn't that be easier than having the script guess?

      Here's an example of what I mean:

      http://www.dufftronix.net/trunk/sneak/ss/index.html

      </barking>

       
        RE: How about This... [View] [Reply] [Top]
        Posted by Alpha Tr Vermilli0n On 2006-01-06 23:24:02
        I just wrote a function that could do all the functions...then i read your post and looks like you already did it.

        Its a simple idea, although a bit of a cop-out as far as a smart solver(its more of a brute-force solver)

        I liked the playfair solver at http://www.quinapalus.com/cgi-bin/playfair where it uses an implemented word matcher to generate a keyword. very useful.
         
          and... [View] [Reply] [Top]
          Posted by Alpha Tr Vermilli0n On 2006-01-06 23:37:11
          were you guys planning on having a hash dictionary as well? for smart-solving hashes(would look for colissions, then return the word associated with that hash)
           
        RE: How about This... [View] [Reply] [Top]
        Posted by Mar Tacheon On 2005-02-16 12:32:05
        ok for caesar, where you may only have 26 entries to look at. but what about when you have 1000's?

        I agree the format of the tool Iposted below needs changing, but as I stated it is from old code I wrote, I just removed the extra bits I had in there (for decrypting and recognising caesar) and posted the rest. In the original version I worte it had an option to verify with a word/string, OR show all results. However I dropped the second part due to the massive amount of results that would need to be checked for other ciphers.

        A second option would be to allow file input as well as dictionary (for verifying) input. That way the deciphering can create a text file (that you can view if you wish) that can be input to the solver.

        Tach


         
      PHP - smartSolver 0.1 - Pre-Approval [View] [Reply] [Top]
      Posted by Mar Tacheon On 2005-02-15 20:56:13
      Was playing with some old code I wrote a while ago.
      It splits the text entered into words, then checks against the supplied word.
      Very basic, but it's a start. Will look at validating from a text file next.

      Tach
      <?php
      
      /*******************************************
       * smartSolver.php.			   *
       *   					   *
       * Version: 0.1 			   *
       *					   *
       * Date: 15th Feb 2005		           *
       *                                         *
       * Author: Tacheon                         *
       *					   *
       * Purpose: To validate text that has been *
       *          decrypted or decoded           *
       *					   *
       *******************************************/
      
      ?>
      
      <html>
       <head>
        <title>smartSolver 0.1</title>
       </head>
       <body bgcolor="#dddddd" text="#000000">
        <br /><center><h2><b>SmartSolver 0.1</b></h2></center>
      
      <?php
      
      if (isset($submit)) 
      {
        echo "<table width=\"450\" border=\"1\" align=\"center\" cellspacing=\"0\" cellpadding=\"10\">\n";
        echo " <tr valign=\"top\">\n";
        echo "  <td>\n";
      
        if ($text == '' || $stringToVerify == '') 
        { 
          echo "<br /><font color=\"#ff0000\"><b>Error:</b> You must enter text into both boxes!</font><br /><br />\n"; 
        } 
        else 
        { 
          echo "<b>Text Entered:</b><br /><br />$text<br /><br />\n"; 
          $showResults = 'yes';
        }
      
        echo "  </td>";
        echo " </tr>";
        echo "</table>";
        echo "<br />";
      
        if ($showResults == 'yes')
        {
          // Validate...
      
          echo "<table width=\"450\" border=\"1\" align=\"center\" cellspacing=\"0\" cellpadding=\"10\">\n";
          echo " <tr valign=\"top\">\n";
          echo "  <td>\n";
          echo "   <b>Results:</b><br /><br />\n"; 
      
          $words = explode(' ', $text);
          for($i=0;$i<count($words);$i++)
          { 
            if ($words[$i] == $stringToVerify)
            { 
              echo "<b>VERIFIED</b> - Text contines the test string '$stringToVerify'.<br /><br />\n";
              break;
            } 
          }
          echo "  </td>\n";
          echo " </tr>\n";
          echo "</table>\n";
          echo "<br />\n";
        }
      
      } 
      else 
      {
        // Input Form...
      
      ?>
      
       <center>
        <form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post">
         <table width="450" border="1" align="center" cellspacing = "0" cellpadding="10">
          <tr valign="top">
           <td>
            <b>Text Entry:</b><br /><br />
            <input type="text" name="text" size="64"><br /><br />
           </td>
          </tr>
         </table>
         <br />
         <table width="450" border="1" align="center" cellspacing = "0" cellpadding="10">
          <tr valign="top">
           <td>
            <b>Verification:</b><br /><br />
            Verify With: &nbsp; &nbsp; <input type="text" name="stringToVerify" size="42"><br /><br />
           </td>
          </tr>
         </table>
         <br />
         <table border="1" align="center" cellspacing = "0" cellpadding="10">
          <tr valign="top">
           <td>
            <input type="submit" name="submit" value=" Submit " /> &nbsp; &nbsp;
            <input type="reset" value=" Clear " />
           </td>
          </tr>
         </table>
        </form>
       </center>
      
      <?php 
      
      }  // End Submit Check. 
      
      echo " </body>\n";
      echo "</html>\n";
      
      ?>
      
      

       


CyberArmy::Forum v0.6
Generated In 0.02456 seconds


About Us | Privacy Policy | Mission Statement | Help