세션 협상 중 서버가 빈 패킷으로 응답하여 클라이언트에 잘못된 패킷 오류가 발생 함

원격 MySQL 서버에 연결하려고합니다. 이것은 100 % 발생합니다.

클라이언트 : MySQL
32.14 Distrib 5.7.12, Win32 (AMD64) 서버 : 5.0.95

이것은 내가 얻는 오류입니다.

C:\>mysql -h example.com -P 3306 -D prod_rcadb -u username -p
Enter password: **********
ERROR 2027 (HY000): Malformed packet

mysqladmin과 동일한 오류 :

C:\>mysqladmin -h example.com -P 3306 -u username -p version
Enter password: **********
mysqladmin: connect to server at '10.106.24.79' failed
error: 'Malformed packet'

그래서 나는 그 대화가 어떻게 생겼는지에 대한 아이디어를 얻기 위해 pcap을 가져 왔습니다.

TCP 핸드 셰이크 :

1              2016-04-14 11:18:48.910690         0.000000              137.69.150.80                     10.106.24.79       TCP        66                511573306 [SYN] Seq=0 Win=8192 Len=0 MSS=1428 WS=256 SACK_PERM=1   8192
2              2016-04-14 11:18:49.019893         0.109203              10.106.24.79                       137.69.150.80     TCP        66                330651157 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460 SACK_PERM=1 WS=256           5840
3              2016-04-14 11:18:49.019893         0.000000              137.69.150.80                     10.106.24.79       TCP        54                511573306 [ACK] Seq=1 Ack=1 Win=65536 Len=0          256

MySQL 연결 협상 :

4              2016-04-14 11:18:49.144696         0.124803              10.106.24.79                       137.69.150.80     MySQL  110        Server Greeting proto=10 version=5.0.95            23
5              2016-04-14 11:18:49.144696         0.000000              137.69.150.80                     10.106.24.79       MySQL  119         Login Request user=bigdata   256<br>
6              2016-04-14 11:18:49.144696         0.000000              10.106.24.79                       137.69.150.80     TCP        60                330651157 [ACK] Seq=57 Ack=66 Win=5888 Len=0        23
7              2016-04-14 11:18:49.316301         0.171605              10.106.24.79                       137.69.150.80     MySQL  60           Response                23

따라서 클라이언트는 TCP 수준에서 연결되며 서버는 지원되는 옵션 및 상태를 알려줍니다.

Server Capabilities: 0xa22c
.... .... .... ...0 = Long Password: Not set
.... .... .... ..0. = Found Rows: Not set
.... .... .... .1.. = Long Column Flags: Set
.... .... .... 1... = Connect With Database: Set
.... .... ...0 .... = Don't Allow database.table.column: Not set
.... .... ..1. .... = Can use compression protocol: Set
.... .... .0.. .... = ODBC Client: Not set
.... .... 0... .... = Can Use LOAD DATA LOCAL: Not set
.... ...0 .... .... = Ignore Spaces before '(': Not set
.... ..1. .... .... = Speaks 4.1 protocol (new flag): Set
.... .0.. .... .... = Interactive Client: Not set
.... 0... .... .... = Switch to SSL after handshake: Not set
...0 .... .... .... = Ignore sigpipes: Not set
..1. .... .... .... = Knows about transactions: Set
.0.. .... .... .... = Speaks 4.1 protocol (old flag): Not set
1... .... .... .... = Can do 4.1 authentication: Set
Server Language: latin1 COLLATE latin1_swedish_ci (8)

클라이언트가 로그인을 요청합니다.

.... .... .... ...1 = Long Password: Set
.... .... .... ..0. = Found Rows: Not set
.... .... .... .1.. = Long Column Flags: Set
.... .... .... 0... = Connect With Database: Not set
.... .... ...0 .... = Don't Allow database.table.column: Not set
.... .... ..0. .... = Can use compression protocol: Not set
.... .... .0.. .... = ODBC Client: Not set
.... .... 1... .... = Can Use LOAD DATA LOCAL: Set
.... ...0 .... .... = Ignore Spaces before '(': Not set
.... ..1. .... .... = Speaks 4.1 protocol (new flag): Set
.... .0.. .... .... = Interactive Client: Not set
.... 0... .... .... = Switch to SSL after handshake: Not set
...0 .... .... .... = Ignore sigpipes: Not set
..1. .... .... .... = Knows about transactions: Set
.0.. .... .... .... = Speaks 4.1 protocol (old flag): Not set
1... .... .... .... = Can do 4.1 authentication: Set
Extended Client Capabilities: 0x81be
.... .... .... ...0 = Multiple statements: Not set
.... .... .... ..1. = Multiple results: Set
.... .... .... .1.. = PS Multiple results: Set
.... .... .... 1... = Plugin Auth: Set
.... .... ...1 .... = Connect attrs: Set
.... .... ..1. .... = Plugin Auth LENENC Client Data: Set
.... .... 1... .... = Session variable tracking: Set
1000 0001 .0.. .... = Unused: 0x0204

서버가 응답을 확인한 후 본질적으로 비어있는 응답

Packet Length: 1
Packet Number: 2
EOF marker: 254

그리고 즉시 클라이언트가 FIN을하고 소켓을 닫습니다.

8              2016-04-14 11:18:49.316301         0.000000              137.69.150.80                     10.106.24.79       TCP        54                511573306 [FIN, ACK] Seq=66 Ack=62 Win=65536 Len=0            256
9              2016-04-14 11:18:49.332901         0.016600              10.106.24.79                       137.69.150.80     TCP        60                330651157 [ACK] Seq=62 Ack=67 Win=5888 Len=0        23
10           2016-04-14 11:18:49.391904         0.059003              10.106.24.79                       137.69.150.80     TCP        60                330651157 [FIN, ACK] Seq=62 Ack=67 Win=5888 Len=0              23
11           2016-04-14 11:18:49.391904         0.000000              137.69.150.80                     10.106.24.79       TCP        54                511573306 [ACK] Seq=67 Ack=63 Win=65536 Len=0     256

따라서 연결 클라이언트는 서버가 보낸 빈 패킷을 좋아하지 않았습니다.

동일한 클라이언트에서 동일한 버전의 다른 mysql 서버에 대해서는 이것을 얻지 못합니다. 다음은 서버 2의 로그인 요청에 대한 응답 패킷입니다.

Packet Length: 7
Packet Number: 2
Affected Rows: 0
Server Status: 0x0002
.... .... .... ...0 = In transaction: Not set
.... .... .... ..1. = AUTO_COMMIT: Set
.... .... .... .0.. = More results: Not set
.... .... .... 0... = Multi query - more resultsets: Not set
.... .... ...0 .... = Bad index used: Not set
.... .... ..0. .... = No index used: Not set
.... .... .0.. .... = Cursor exists: Not set
.... .... 0... .... = Last row sent: Not set
.... ...0 .... .... = database dropped: Not set
.... ..0. .... .... = No backslash escapes: Not set
.... .0.. .... .... = Session state changed: Not set
.... 0... .... .... = Query was slow: Not set
...0 .... .... .... = PS Out Params: Not set

나는이 db를 직접 관리하지 않지만 로그에서 찾을 것을 제안하는 경우 해당 정보를 요청할 수 있습니다.

서버에서 빈 패킷을 다시받는 이유에 대한 생각이 있습니까?



답변

내가 비어 있다고 생각한 패킷은 실제로 그렇지 않습니다. 이전 인증 스위치 요청 이었습니다 .

Payload
1     [fe]
Fields
status (1) -- 0xfe
Returns
Protocol::AuthSwitchResponse with old password hash
Example
01 00 00 02 fe

wireshark가 구문 분석 한 1, 2, 254는 실제 바이트 문자열을 보면 실제로 01 00 00 02 fe입니다.

따라서 오해가있는 것은 아니며, 서버는 협상을 할 수 없기 때문에 서버가 완벽하고 정확하게 응답하고 클라이언트가 올바르게 종료된다는 것을 이해합니다. 프로토콜은 4.1에서 변경되어 너무 오래되지 않았으므로 5.0과 5.7은 서로를 완벽하게 이해합니다. 더 명확한 오류 메시지 여야합니다.

–skip-secure-auth ( reference ) 를 사용하기에는 클라이언트가 너무 새롭습니다 . 그들은 5.7 이전에 협상 할 수있는 능력을 의도적으로 제거했다.

따라서 내 옵션은 서버에서 새 암호 (전역 서버 옵션이 아닌 사용자 별 구성)를 허용하거나 이전 바이너리를 사용하는 것입니다.

특정 구성 문제는 내가 제공 한 사용자 이름을 기반으로합니다. 과거 어느 시점 에서이 사용자 이름을 사용하는 누군가가 이전 클라이언트를 사용하고 있었고 비밀번호 방법변경했습니다 .

B.5.2.4 Client does not support authentication protocol

The current implementation of the authentication protocol uses a password hashing algorithm that is incompatible with that used by older (pre-4.1) clients. Attempts to connect to a 4.1 or newer server with an older client may fail with the following message:

shell> mysql
Client does not support authentication protocol requested
by server; consider upgrading MySQL client

To deal with this problem, the preferred solution is to upgrade all client programs to use a 4.1.1 or newer client library. If that is not possible, use one of the following approaches:

    To connect to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password.

    Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program. This can be done using the SET PASSWORD statement and the OLD_PASSWORD() function. As of MySQL 5.6.6, it is also necessary to first ensure that the authentication plugin for the account is mysql_old_password:

    mysql> UPDATE mysql.user SET plugin = 'mysql_old_password'
    mysql> WHERE User = 'some_user' AND Host = 'some_host';
    mysql> FLUSH PRIVILEGES;
    mysql> SET PASSWORD FOR
        -> 'some_user'@'some_host' = OLD_PASSWORD('new_password');


답변

@@old_passwords활성화 된 오래된 MySQL 서버에 연결하려고 할 때이 오류가 발생했습니다 . mysql-client v5.7.19 및 서버 버전 5.1.73을 사용하고 있습니다.

MySQL SHA1 암호 해시를 수동으로 작성하여 (필요한 목적으로 작성한 프로그램을 사용하여) 문제를 해결 한 다음 서버에서이 명령을 실행했습니다.

SET PASSWORD FOR 'nagios'@'10.10.10.201' = 'xxxx';

( xxxx실제로는 해시가있었습니다.)


답변