无法访问公网ip的445端口

有关Windows10 不支持访问smb非标端口的问题 - Microsoft Community
https://answers.microsoft.com/zh-hans/windows/forum/all/有关windows10/3deecc2b-21ff-46f7-ac75-2a417231f6a3

HKLM:\SYSTEM\CurrentControlSet\Services\NetBT

继勒索病毒“永恒之蓝”445端口被封之后,在公网实现smb文件共享_云云生息的专栏-CSDN博客
https://blog.csdn.net/rocson001/article/details/86717722

电信运营商的宽带有哪些IP协议端口被封? - 知乎
https://www.zhihu.com/question/336642388

import pydivert

with pydivert.WinDivert("tcp.DstPort == 445 or tcp.SrcPort == 4455") as w:
    for packet in w:
        if packet.dst_port == 445:
            print(">") # packet to the server
            packet.dst_port = 4455
        if packet.src_port == 4455:
            print("<") # reply from the server
            packet.src_port = 445
        w.send(packet)

Windows的SMB默认使用445端口,
客户端运行上面的代码,使用SMB时改为访问4455端口。
服务端可以运行类似的代码,将SMB端口改为4455端口。
以上代码未使用多线程,访问速度可能比较慢。

GitHub - Arno0x/DivertTCPconn: A TCP packet diverter for Windows platform
https://github.com/Arno0x/DivertTCPconn
原理与上面的代码相同。

端口复用:

import pydivert

print("begin:")
#192.168.1.9 = 3232235785 
with pydivert.WinDivert("ip.SrcAddr == 3232235785 or ip.DstAddr == 3232235785") as w:
    for packet in w:
        if packet.dst_port == 80:
            print(">")
            packet.dst_port = 3389
        if packet.src_port == 3389:
            print("<") # reply from the server
            packet.src_port = 80
        w.send(packet)

服务端上运行以上代码。
当192.168.1.9访问服务端的80端口时,相当于访问服务端的3389端口,实现类似于端口复用的效果。

posted @ 2020-09-04 22:44  东坡何罪  阅读(1770)  评论(0)    收藏  举报