douda5227 2015-04-30 10:23
浏览 28
已采纳

用于从服务器检索密码列表的PHP解决方案

Does anyone know how I can go about using a pure php solution for retrieving a list of ciphers supported by a remote server?

This is the code to test again a local client (web browser)

$ciphers = openssl_get_cipher_methods();

foreach($ciphers as $cipher) {
    echo "{$cipher}<br>";
}

Here is what I need to do

  1. I think what I need to do is create a socket connection to a remote connection
  2. I need to use a loop to connect with a different cipher each time.
  3. For each connection that is successfully established, it should print the name of the cipher we connected with.

Here is some code to establish a secure connection but need help to factor in the above requirements.

$url = $_REQUEST['host'];


$ssloptions = array(
    "capture_peer_cert" => false, 
    "allow_self_signed"=>false, 
    "CN_match"=>$url, 
    "verify_peer"=>false, 
    "SNI_enabled"=>true,
    "SNI_server_name"=>$url,
);

$ctx = stream_context_create( array("ssl" => $ssloptions) );
$result = stream_socket_client("ssl://$url:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx);
$cont = stream_context_get_params($result);

Here is a list of some ciphers we can use to connect with:

TLS_RSA_WITH_RC4_128_MD5

TLS_RSA_WITH_RC4_128_SHA

TLS_RSA_WITH_3DES_EDE_CBC_SHA

TLS_DHE_RSA_WITH_AES_256_CBC_SHA

TLS_DHE_RSA_WITH_AES_128_CBC_SHA

  • 写回答

1条回答 默认 最新

  • duanjing3656 2015-04-30 16:19
    关注

    I needed to add this to my socket array:

    'ciphers' => $value,

    I also created an array with all the ciphersuites and put it through a foreach ($ciphersuites_to_test as $value) to cycle through all the ciphers.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable