IRC DCC接收文件 [英] IRC DCC Receive files

查看:70
本文介绍了IRC DCC接收文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为我已经阅读了IRC RFC. 我唯一了解的是:当用户向我发送文件时,我收到这样的CTCP:DCC SEND<文件名>< ipaddress><端口><文件大小> IPAddress必须从长格式转换为标准IP格式.

I premise that I have already read the IRC RFC. The only thing that I know: when a user sends me a File i receive a CTCP like this: DCC SEND < filename > < ipaddress > < port > < filesize > Where IPAddress must be converted from long to standard IP format.

转换后如何开始接收文件? 我在这里停留:

After conversion how can I start receiving file? I stopped here:

Dim sendMatch As Match = Regex.Match(b_data, "DCC SEND (.*?) (\d+) (\d+) (\d+?).?$")
   If (sendMatch.Captures.Count > 0) Then
       Dim send_filename As String = sendMatch.Groups.Item(1).Value
       Dim send_fromip As String = IPConvert(sendMatch.Groups.Item(2).Value)
       Dim send_fromport As String = sendMatch.Groups.Item(3).Value
       Dim send_filesize As String = sendMatch.Groups.Item(4).Value
       ...

对不起,我的英语不好,谢谢!

Sorry for my bad english, and thanks in advance!

推荐答案

为CTCP DCC命令提供的参数包括建议的文件名,IP地址(仅ipv4,以ASCII格式编码为32位整数,例如2130706433表示127.0.0.1.下一个字段包含端口号,最后一个字段包含文件大小.

The parameters given to the CTCP DCC command include a suggested filename, IP address (this is ipv4 ONLY, encoded as a 32 bit integer in ASCII format, e.g. 2130706433 meaning 127.0.0.1. The next field contains the port number and the final field contains the file size.

通过TCP连接在给定端口上简单地连接到给定IP,并连续接收4k块.在收到每个块之后,以网络字节顺序发送4字节计数,以计数您到目前为止已收到的总字节数.继续此操作,直到连接关闭和/或您收到的文件大小与给定的字节数一样多.通常,在连接关闭之前,您必须发送最后一块的字节数.

Simply connect to the given IP on the given port via a TCP connection, and continually receive in 4k blocks. After each block received send a 4 byte count of how many bytes total you've received so far in network byte order. Continue this until the connection closes and/or you've received as many bytes as given for the file size. You must usually send the count of bytes for the final block before the connection closes.

通常,发送客户端可以在发送完成后关闭连接,但不要依靠它们来执行此操作.

Generally, the sending client MAY close the connection on completion of the send, but don't rely on them to do this.

此外,永远不要只将给定的文件名当做面值使用,而要让用户能够选择自己的文件名并对其进行清理,过滤出恶意文件类型,否则,您可能会在DCC SEND的接收端收到请求.例如名称为".. \ .. \ .. \ .. \.\ windows \ notepad.exe"的文件,或者如果直接使用,如果用户具有正确的权限,则将覆盖系统文件.

Also, never EVER just take the given filename at face value, give the user the ability to select their own and to sanitise it, filtering out malicious file types, otherwise you could be on the receiving end of a DCC SEND for a file for example with the name "..\..\..\..\..\windows\notepad.exe" or such which if taken directly will overwrite a system file if the user has the correct permissions.

您可以在此处更多信息.

希望这会有所帮助!

这篇关于IRC DCC接收文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆