gpt4 book ai didi

ios - SSH 协商 : Bad SSH2_MSG_KEX_DH_GEX_REPLY or something else?

转载 作者:可可西里 更新时间:2023-11-01 06:14:24 25 4
gpt4 key购买 nike

我正在为 iOS 进行 unix 服务器 ssh 模拟。在谈判过程中,我遇到了很多障碍,并且仍在与这些障碍作斗争。最新的一个是关于 SSH2_MSG_KEX_DH_GEX_REPLY 数据包数据,我在其中收到错误的数据包长度(可能是无关的填充)。整个流程的数据包描述如下:

Client : connection with aix.polarhome.com with port 775 (changed port for ssh) using GCDAsyncSocket
Server : SSH-2.0-OpenSSH_6.0
Client : send SSH-2.0-OpenSSH_6.0

(Rest packet will follow BPP protocol)
Server : SSH2_MSG_KEXINIT with set of supported algorithms
Client : SSH2_MSG_KEXINIT with set of common algorithms

Client : SSH2_MSG_KEX_DH_GEX_REQUEST_OLD
code:
SignedByte sendByte[1920];
int writeIndex = 0;

minGroupLength = 1024;
prefGroupLength = 1024;
maxGroupLength = 4096;

sendByte[writeIndex++] = SSH2_MSG_KEX_DH_GEX_REQUEST_OLD;

[self write32BitInteger:prefGroupLength toPacket:sendByte fromIndex:writeIndex];
writeIndex += 4;

[self sendSSHBinaryPacketPayload:sendByte toLength:writeIndex];
writeIndex = 0;

Server : SSH2_MSG_KEX_DH_GEX_GROUP

client -> fetch values of p and g
compute value of e (1 < e < (p-1)/2)

Client : SSH2_MSG_KEX_DH_GEX_INIT
Code
SignedByte sendByte[1920];
int writeIndex = 0;

NSInteger eByteCount = [[e description] stringByReplacingOccurrencesOfString:@" " withString:@""].length/2;

sendByte[writeIndex++] = SSH2_MSG_KEX_DH_GEX_INIT;

[self write32BitInteger:eByteCount toPacket:sendByte fromIndex:writeIndex];
writeIndex += 4;

Byte eBytes[eByteCount];
NSInteger length = [self getBytes:eBytes fromBigInteger:e];
for (int i = 0; i < length; i++) {
sendByte[writeIndex++] = eBytes[i];
}

[self sendSSHBinaryPacketPayload:sendByte toLength:writeIndex];
writeIndex = 0;

Server : SSH2_MSG_KEX_DH_GEX_REPLY
Total length : 720
Packet length (4 bytes): 00 00 02 bc (700 which should be 720 - 4 = 716) Don't Know why this 700?

client -> read host key and verify it
read value of f
read signature and verify it

Client : SSH2_MSG_NEWKEYS

现在在发送最后一个数据包后服务器模拟并且没有数据返回 SSH2_MSG_NEWKEYS。

我查看了其他 ssh 模拟器的代码,但没有一个有帮助。我完全无能为力,我需要做什么,请帮忙,我真的很沮丧。

最佳答案

根据@revinder 的评论:

我解决了这个问题,我自己的服务器将两个数据包合并为一个,SSH2_MSG_KEX_DH_GEX_REQUEST 和 SSH2_MSG_NEWKEYS。

关于ios - SSH 协商 : Bad SSH2_MSG_KEX_DH_GEX_REPLY or something else?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29643876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com