Включить сжатие SSL на сервере nginx

Я пытался сделать демонстрацию атаки CRIME, для которой требуются браузер и сервер с включенным сжатием SSL. . Я приобрел такой браузер и установил HTTPS-сервер nginx на локальном хосте с параметрами, которые, как я думал, будут включать сжатие (DEFLATE).

Вот мой nginx.conf :

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # victim's bank server - HTTPS
    server {
        listen       443 ssl;
        #listen       81; # used to observe GET requests
        server_name  www.thebank.com thebank.com;
        ssl_certificate path/to/bank.crt;
        ssl_certificate_key path/to/bank.key;
        ssl_protocols SSLv2 SSLv3 TLSv1; #TLSv1.1 TLSv1.2;

        gzip         on;
        #gzip_types   *;
        #gzip_min_length 0;
        #gzip_comp_level 9;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   path/to/bank;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # evil server
    server {
        listen       80;
        server_name  evil.com www.evil.com;

        location / {
            root   path/to/evil;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
# ...
    include servers/*;
}

(Отказ от ответственности:Я никогда особо не работал с nginx, поэтому прошу прощения, если это нарушает некоторые соглашения, я просто скопировал предоставленный файл conf и при необходимости изменил его. Вот почему так много дополнительных комментариев.)

Было сложно найти информацию о включении чего-то небезопасного, но я подумал, что строка gzip on; включает сжатие SSL. Тем не менее, когда я прослушиваю кольцевой трафик с помощью Wireshark, я вижу, что DEFLATE указан как метод сжатия в клиентском приветствии, но только null в методах сжатия сервера hello.

Я использовал старую версию nginx (1.1.6) и OpenSSL (0.9.8zb) в надежде, что это сработает. Также пробовал nginx 1.0.6, но все равно не повезло.

Кто-нибудь может мне помочь? Кажется, я все перепробовал.

Edit: Даже с OpenSSL 0.9.7 и nginx 1.0.6 Server Hello по-прежнему не показывает методов сжатия.

Edit: По запросу @Steffen Ullrich , и чтобы предоставить более подробную информацию о компиляциях OpenSSL и nginx, вот результат моей последней попытки:

# install OpenSSL from source in /path/to/Downloads
wget https://www.openssl.org/source/old/0.9.x/openssl-0.9.8zb.tar.gz
tar xvf openssl-0.9.8zb.tar.gz
cd openssl-0.9.8zb
./config zlib
make
sudo make install

# check for zlib support
openssl version -a
# OpenSSL 0.9.8zb 6 Aug 2014
# built on: Fri Sep 27 01:59:42 EDT 2019
# platform: linux-x86_64
# options:  bn(64,64) md2(int) rc4(1x,char) des(idx,cisc,16,int) idea(int) blowfish(idx) 
# compiler: gcc -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DMD32_REG_T=int -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM
# OPENSSLDIR: "/usr/local/ssl"

# install nginx 1.0.6 from source with custom OpenSSL source
wget http://nginx.org/download/nginx-1.0.6.tar.gz
tar xvfz nginx-1.0.6.tar.gz
cd nginx-1.0.6
./configure --with-http_ssl_module --without-http_rewrite_module --with-openssl=/path/to/Downloads/openssl-0.9.8zb
sudo make
sudo make install

# check for zlib support
openssl version -a
# OpenSSL 0.9.8zb 6 Aug 2014
# built on: Fri Sep 27 02:57:12 EDT 2019
# platform: linux-x86_64
# options:  bn(64,64) md2(int) rc4(1x,char) des(idx,cisc,16,int) idea(int) blowfish(idx) 
# compiler: gcc -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DMD32_REG_T=int -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM
# OPENSSLDIR: "/path/to/Downloads/openssl-0.9.8zb/.openssl/ssl"
2
задан 27 September 2019 в 10:35
1 ответ

Согласно эта информация вам понадобится старый nginx и старый OpenSSL - намного более старый, чем тот, который вы использовали:

Атака CRIME творит чудеса с помощью сжатия SSL. Сжатие SSL по умолчанию отключено в nginx 1.1.6 + / 1.0.9 + (если используется OpenSSL 1.0.0+) и nginx 1.3.2 + / 1.2.2 + (если используются более старые версии OpenSSL).

Таким образом, использование nginx 1.1.5 или nginx 1.0.8 должно работать, но только если вы также используете OpenSSL 0.9.8. В более новых версиях OpenSSL сжатие TLS по умолчанию отключено. Обратите внимание, что эта старая версия OpenSSL не поддерживает TLS 1.1 или TLS 1.2.

0
ответ дан 3 December 2019 в 13:40

Теги

Похожие вопросы