<commit_before><!--
    Copyright (C) 2015 <NAME>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<?php
error_reporting(E_ALL & ~E_NOTICE);
ob_start();
$write_cache = 0;

foreach (glob("functions/*.php") as $filename) {
  include $filename;
}
?>

<!doctype html>
<html lang="en">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SSL Decoder</title>
  <link rel="stylesheet" href="<?php echo(htmlspecialchars($current_folder)); ?>css/bootstrap.min.css">
  <link rel="stylesheet" href="<?php echo(htmlspecialchars($current_folder)); ?>css/ssl.css">
  <script src="<?php echo(htmlspecialchars($current_folder)); ?>js/jquery.min.js"></script> 
  <script src="<?php echo(htmlspecialchars($current_folder)); ?>js/bootstrap.min.js"></script>
  <script src="<?php echo(htmlspecialchars($current_folder)); ?>js/ajax.js"></script>
</head>
<body>
  <div id="wrapper">
  <a id="top-of-page"></a>
  <?php
   if ( isset($_GET['host']) && !empty($_GET['host'])) {
    $host = mb_strtolower(get($_GET['host']));
    $port = get($_GET['port'], '443');
    $csr = get($_GET['csr'], '');
    if ( !is_numeric($port) ) {
      $port = 443;
    }
    $stream = stream_context_create (array("ssl" => 
      array("capture_peer_cert" => true,
        "capture_peer_cert_chain" => true,
        "verify_peer" => false,
        "verify_peer_name" => false,
        "allow_self_signed" => true,
        "sni_enabled" => true)));
      $read_stream = stream_socket_client("ssl://$host:$port", $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $stream);
      if ( $read_stream !== false ) {
        $context = stream_context_get_params($read_stream);
        $chain_data = $context["options"]["ssl"]["peer_certificate_chain"];
        $chain_length = count($chain_data);
        if (!empty($chain_data) && $chain_length < 10) {
    
  ?>
  <!-- Sidebar -->
  <div id="sidebar-wrapper">
    <nav>
    <ul class="sidebar-nav">
    <br>
      <li class="sidebar-brand">
        <h2>Navigation</h2>
      </li>
      <li><a href="#conndata"><strong>0</strong>: Connection Data</a></li>
      <?php
        foreach ($chain_data as $key => $value) {
          $nextkey = $key + 1;
          echo "<li><a href='#cert".$nextkey."'><strong>".$nextkey."</strong> : ". htmlspecialchars(get_cert_cn($value)) ."</a></li>";
        }
      ?>
      <li><a href="<?php echo(htmlspecialchars($current_folder)); ?>">Try another website</a></li>
      <li><hr></li>
      <li><a href="https://cipherli.st/">Strong Cipherlists</a></li>
      <li><a href="https://raymii.org/s/tutorials/Strong_SSL_Security_On_Apache2.html">Apache SSL Tutorial</a></li>
      <li><a href="https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html">NGINX SSL Tutorial</a></li>
      <li><a href="https://raymii.org/s/tutorials/Strong_SSL_Security_On_lighttpd.html">Lighttpd SSL Tutorial</a></li>
      <li><a href="https://raymii.org">Raymii.org</a></li>
    </ul>
    </nav>
  </div>
  <!-- /#sidebar-wrapper -->
        <?php
          }
        }
      }
        ?>
<div id="page-content-wrapper">
  <div class="container-fluid">
    <div class="row">
      <?php
          if ( !isset($_GET['host']) || !isset($_GET['csr']) ) {
            ?>
            <div class="col-md-10 col-md-offset-1">
              <div class="page-header" >
                <h1>SSL Decoder</h1>
            </div>
            <div id='sslform'>
            <form class="form-horizontal">
              <p>Fill in either host + port or paste a CSR/Certficiate. Port defaults to 443.<br></p>
              <fieldset>

                <div class="form-group">
                  <label class="col-md-1 control-label" for="host">Host</label>  
                  <div class="col-md-5">
                    <input id="host" name="host" type="text" placeholder="raymii.org" class="form-control input-md" >
                  </div>
                  <label class="col-md-1 control-label" for="port">Port</label>  
                  <div class="col-md-2">
                    <input id="port" name="port" type="text" placeholder="443" class="form-control input-md">
                  </div>
                </div>
                <div class="form-group">
                  <div class="col-md-4 col-md-offset-1">
                    <div class="checkbox">
                      <label for="ciphersuites">
                        <input type="checkbox" name="ciphersuites" id="ciphersuites" value="1" checked="checked">
                        Enumerate Ciphersuites (takes longer)
                      </label>
                    </div>
                  </div>
                </div>

                <hr>

                <div class="form-group">
                  <label class="col-md-1 control-label" for="csr">CSR / Certificate</label>
                  <div class="col-md-5">                     
                    <textarea class="form-control" rows=6 id="csr" name="csr"></textarea>
                  </div>
                </div>

                <div class="form-group">
                  <div class="col-md-4">
                    <label class="col-md-2 col-md-offset-1 control-label" for="s"></label>
                    <button id="s" name="s" class="btn btn-primary" onsubmit="showElementbyID(true, 'preloader'); showElementbyID(false, 'sslform'); makeRequest('/ssl/?port=' + this.form.port.value + '&csr=' + this.form.csr.value + '&s=&host=' + this.form.host.value,, 'showContent');return false" onclick="showElementbyID(true, 'preloader'); showElementbyID(false, 'sslform'); makeRequest('/ssl/?port=' + this.form.port.value + '&csr=' + this.form.csr.value + '&ciphersuites=' + this.form.ciphersuites.value + '&s=&host=' + this.form.host.value, 'showContent');return false">Submit</button>
                  </div>
                </div>

              </fieldset>
            </form>
        </div>
        
        <div id="preloader"><p><img src="<?php echo(htmlspecialchars($current_folder)); ?>img/ajax-loader.gif" /><br>&nbsp;<br>The SSL Decoder is processing your request. Please wait a few moments.<br></p></div>

        <div id="resultDiv"></div>


            <?php
          } else {
            if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
              ?> 
              <div class="col-md-10 col-md-offset-1">
              <div class="page-header" >
                <h1>SSL Decoder</h1>
            </div>
            <?php
            // set backwrite_ to 1 after debugging
            $write_cache = 1;
            if (!is_dir('results')) {
              mkdir('results');
            }
            $epoch = date('U');
            $random_bla = md5(uniqid(rand(), true));
          }
          $host = mb_strtolower(get($_GET['host']));
          $port = get($_GET['port'], '443');
          $csr = get($_GET['csr'], '');
          if ( !is_numeric($port) ) {
            $port = 443;
          }

            if ( empty($csr) && !empty($host) ) {

              echo "<p><strong>This tool does not make conclusions. Please check the data and define the validity yourself!</strong></p><br>";

              $stream = stream_context_create (array("ssl" => 
                array("capture_peer_cert" => true,
                  "capture_peer_cert_chain" => true,
                  "verify_peer" => false,
                  "capture_session_meta" => true,
                  "verify_peer_name" => false,
                  "allow_self_signed" => true,
                  "sni_enabled" => true)));
              $read_stream = stream_socket_client("ssl://$host:$port", $errno, $errstr, 5,
                STREAM_CLIENT_CONNECT, $stream);
<commit_msg>Wrong div<commit_after><!--
    Copyright (C) 2015 <NAME>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<?php
error_reporting(E_ALL & ~E_NOTICE);
ob_start();
$write_cache = 0;

foreach (glob("functions/*.php") as $filename) {
  include $filename;
}
?>

<!doctype html>
<html lang="en">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SSL Decoder</title>
  <link rel="stylesheet" href="<?php echo(htmlspecialchars($current_folder)); ?>css/bootstrap.min.css">
  <link rel="stylesheet" href="<?php echo(htmlspecialchars($current_folder)); ?>css/ssl.css">
  <script src="<?php echo(htmlspecialchars($current_folder)); ?>js/jquery.min.js"></script> 
  <script src="<?php echo(htmlspecialchars($current_folder)); ?>js/bootstrap.min.js"></script>
  <script src="<?php echo(htmlspecialchars($current_folder)); ?>js/ajax.js"></script>
</head>
<body>
  
  <a id="top-of-page"></a>
  <?php
   if ( isset($_GET['host']) && !empty($_GET['host'])) {
    echo '<div id="wrapper">';
    $host = mb_strtolower(get($_GET['host']));
    $port = get($_GET['port'], '443');
    $csr = get($_GET['csr'], '');
    if ( !is_numeric($port) ) {
      $port = 443;
    }
    $stream = stream_context_create (array("ssl" => 
      array("capture_peer_cert" => true,
        "capture_peer_cert_chain" => true,
        "verify_peer" => false,
        "verify_peer_name" => false,
        "allow_self_signed" => true,
        "sni_enabled" => true)));
      $read_stream = stream_socket_client("ssl://$host:$port", $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $stream);
      if ( $read_stream !== false ) {
        $context = stream_context_get_params($read_stream);
        $chain_data = $context["options"]["ssl"]["peer_certificate_chain"];
        $chain_length = count($chain_data);
        if (!empty($chain_data) && $chain_length < 10) {
    
  ?>
  <!-- Sidebar -->
  <div id="sidebar-wrapper">
    <nav>
    <ul class="sidebar-nav">
    <br>
      <li class="sidebar-brand">
        <h2>Navigation</h2>
      </li>
      <li><a href="#conndata"><strong>0</strong>: Connection Data</a></li>
      <?php
        foreach ($chain_data as $key => $value) {
          $nextkey = $key + 1;
          echo "<li><a href='#cert".$nextkey."'><strong>".$nextkey."</strong> : ". htmlspecialchars(get_cert_cn($value)) ."</a></li>";
        }
      ?>
      <li><a href="<?php echo(htmlspecialchars($current_folder)); ?>">Try another website</a></li>
      <li><hr></li>
      <li><a href="https://cipherli.st/">Strong Cipherlists</a></li>
      <li><a href="https://raymii.org/s/tutorials/Strong_SSL_Security_On_Apache2.html">Apache SSL Tutorial</a></li>
      <li><a href="https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html">NGINX SSL Tutorial</a></li>
      <li><a href="https://raymii.org/s/tutorials/Strong_SSL_Security_On_lighttpd.html">Lighttpd SSL Tutorial</a></li>
      <li><a href="https://raymii.org">Raymii.org</a></li>
    </ul>
    </nav>
  </div>
  <!-- /#sidebar-wrapper -->
        <?php
          }
        }
      }
        ?>
<div id="page-content-wrapper">
  <div class="container-fluid">
    <div class="row">
      <?php
          if ( !isset($_GET['host']) || !isset($_GET['csr']) ) {
            ?>
            <div class="col-md-10 col-md-offset-1">
              <div class="page-header" >
                <h1>SSL Decoder</h1>
            </div>
            <div id='sslform'>
            <form class="form-horizontal">
              <p>Fill in either host + port or paste a CSR/Certficiate. Port defaults to 443.<br></p>
              <fieldset>

                <div class="form-group">
                  <label class="col-md-1 control-label" for="host">Host</label>  
                  <div class="col-md-5">
                    <input id="host" name="host" type="text" placeholder="raymii.org" class="form-control input-md" >
                  </div>
                  <label class="col-md-1 control-label" for="port">Port</label>  
                  <div class="col-md-2">
                    <input id="port" name="port" type="text" placeholder="443" class="form-control input-md">
                  </div>
                </div>
                <div class="form-group">
                  <div class="col-md-4 col-md-offset-1">
                    <div class="checkbox">
                      <label for="ciphersuites">
                        <input type="checkbox" name="ciphersuites" id="ciphersuites" value="1" checked="checked">
                        Enumerate Ciphersuites (takes longer)
                      </label>
                    </div>
                  </div>
                </div>

                <hr>

                <div class="form-group">
                  <label class="col-md-1 control-label" for="csr">CSR / Certificate</label>
                  <div class="col-md-5">                     
                    <textarea class="form-control" rows=6 id="csr" name="csr"></textarea>
                  </div>
                </div>

                <div class="form-group">
                  <div class="col-md-4">
                    <label class="col-md-2 col-md-offset-1 control-label" for="s"></label>
                    <button id="s" name="s" class="btn btn-primary" onsubmit="showElementbyID(true, 'preloader'); showElementbyID(false, 'sslform'); makeRequest('/ssl/?port=' + this.form.port.value + '&csr=' + this.form.csr.value + '&s=&host=' + this.form.host.value,, 'showContent');return false" onclick="showElementbyID(true, 'preloader'); showElementbyID(false, 'sslform'); makeRequest('/ssl/?port=' + this.form.port.value + '&csr=' + this.form.csr.value + '&ciphersuites=' + this.form.ciphersuites.value + '&s=&host=' + this.form.host.value, 'showContent');return false">Submit</button>
                  </div>
                </div>

              </fieldset>
            </form>
        </div>
        
        <div id="preloader"><p><img src="<?php echo(htmlspecialchars($current_folder)); ?>img/ajax-loader.gif" /><br>&nbsp;<br>The SSL Decoder is processing your request. Please wait a few moments.<br></p></div>

        <div id="resultDiv"></div>


            <?php
          } else {
            if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
              ?> 
              <div class="col-md-10 col-md-offset-1">
              <div class="page-header" >
                <h1>SSL Decoder</h1>
            </div>
            <?php
            // set back to 1 after debugging
            $write_cache = 0;
            if (!is_dir('results')) {
              mkdir('results');
            }
            $epoch = date('U');
            $random_bla = md5(uniqid(rand(), true));
          }
          $host = mb_strtolower(get($_GET['host']));
          $port = get($_GET['port'], '443');
          $csr = get($_GET['csr'], '');
          if ( !is_numeric($port) ) {
            $port = 443;
          }

            if ( empty($csr) && !empty($host) ) {

              echo "<p><strong>This tool does not make conclusions. Please check the data and define the validity yourself!</strong></p><br>";

              $stream = stream_context_create (array("ssl" => 
                array("capture_peer_cert" => true,
                  "capture_peer_cert_chain" => true,
                  "verify_peer" => false,
                  "capture_session_meta" => true,
                  "verify_peer_name" => false,
                  "allow_self_signed" => true,
                  "sni_enabled" => true)));
              $read_stream = stream_socket_client("ssl://$host:$port", $errno, $errstr, 5,
                STREAM_CLIENT_CONNECT, $stream);

{'fraction_non_alphanumeric': 0.17257824143070044, 'fraction_numerical': 0.007391952309985097, 'mean_word_length': 2.236111111111111, 'pattern_counts': {'":': 0, '<': 335, '<?xml version=': 0, '>': 363, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1390518', 'n_tokens_mistral': 5317, 'n_tokens_neox': 5104, 'n_words': 1048}