dnscapy使用——本质上是建立ssh的代理(通过dns tunnel)

简介:

git clone https://github.com/cr0hn/dnscapy.git

easy_install Scapy

服务端:

python dnscapy_server.py a.friendsxxx.com 45.77.39.xxx

客户端:

ssh -o ProxyCommand="sudo python dnscapy_client.py a.friendsxxx.com 45.77.39.xxx" root@45.77.39.xxx

其中:a.friendsxxx.com是我dns tunnel的域名,而45.77.39.xxx是我的域名解析服务器IP(将a.friendsxxx.com的所有解析交给45.77.39.xxx)。

然后就可以访问ssh了。

 

传输文件:

scp -o ProxyCommand='sudo python dnscapy_client.py a.friendsxxx.com 45.77.39.xxx' wanted_file root@45.77.39.xxx:/tmp/

 

抓包分析下:

sudo tcpdump -i enp0s3 port 53 -w ~/dns_tunnel_tool/dnscapy/dnscapy_ssh.pcap

 

wireshark打开:

可以看到其传输数据的样子。

 

 

DNScapy is a DNS tunneling tool. The code is very light and written in Python. It includes a server and a client. The server can handle multiple clients.

DNScapy creates a SSH tunnel through DNS packets. SSH connection, SCP and proxy socks (SSH -D) are supported. You can use CNAME records or TXT records for the tunnel. The default mode is RAND, which uses randomly both CNAME and TXT.

DNScapy uses Scapy (http://www.secdev.org/scapy) for DNS packet forging and for his network automaton API.

DNScapy is still under development. The current version is 0.99b and seems to work pretty well. Feel free to clone and test it !

Software Requirements

Python >= 2.6
Scapy >= 2.1-dev (2.2 recommended)
Openssh
Linux (should work on Windows with some minor changes) 

Note : once scapy is installed you have to patch a missing import.

Edit the file supersocket.py (located for example on /usr/local/lib/python2.6/dist-packages/scapy/supersocket.py)
Add the line: from scapy.packet import Padding 

Hardware Requirements

To make a real DNS tunnel, you will need:

a client, typically a computer on a restricted network
a server, typically a computer with a full acces to Internet
a domain name (e.g. mydomain.com ) and an access on the configuration of its DNS server in order to delegate a zone (e.g. tunnel.mydomain.com) to your tunneling server 

You can find further informations on how to delegate a DNS zone on websites like http://dnstunnel.de/ Howto

Here is a very short guide:

On the server:

sudo python dnscapy_server.py [DELEGATED_ZONE_NAME] [EXTERNAL_IP_ADDR]

On the client:

ssh -o ProxyCommand="sudo python dnscapy_client.py [DELEGATED_ZONE_NAME] [IP_ADDR_OF_CLIENT_DNS]" yourlogin@localhost

help and options:

./dnscapy_client.py -h ./dnscapy_server.py -h

It will not work if both client and server are on localhost. If you want to test it on the same computer I suggest to use a virtual machine. Why making a DNS tunnel ?

Because in most cases a security policy takes care of HTTP and forgets DNS. Let's consider two common situations:

You are not able to access to a specific website because of a HTTP proxy.
You are not be able to connect to a Hotspot because of a firewall that redirects HTTP requests of non-authenticated users. 

In general, nothing is done to control the DNS resolution. Therefore you can break the two previous restrictions by making a DNS tunnel.

DISCLAIMER: We are not responsible at all for misuse of DNScapy. Bypassing a security policy is forbidden. Please use DNScapy only for test purposes in order to detect potential security holes in your own network. Why a SSH tunnel through DNS ?














本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/8037761.html,如需转载请自行联系原作者



相关文章
|
1月前
|
Python
区域代理分红商城系统开发源码片段示例规则解析
level = Column(Integer, default=1) # 代理等级,例如:1代表普通用户,2代表初级代理,3代表高级代理等 parent_id = Column(Integer, ForeignKey('user.id')) # 上级代理ID 【更全面的开发源码搭建可V or TG我昵称】 parent = relationship("User", remote_side=[id]) # 上级代理对象
|
3月前
|
前端开发 网络安全
ssh的MVC解析
ssh的MVC解析
|
4月前
|
设计模式 XML JSON
二十三种设计模式全面解析-代理模式进阶篇:揭秘远程代理
二十三种设计模式全面解析-代理模式进阶篇:揭秘远程代理
|
8月前
|
JSON Linux 网络安全
【全面解析】Windows 如何使用 SSH 密钥远程连接 Linux 服务器
【全面解析】Windows 如何使用 SSH 密钥远程连接 Linux 服务器
419 2
|
9月前
|
Web App开发 网络协议 安全
在使用易路代理时,本地浏览器如何修改DNS 1.1.1.1?
在使用易路代理时,本地浏览器如何修改DNS 1.1.1.1?
132 0
|
24天前
|
安全 网络安全 数据安全/隐私保护
ansible 建立ssh信任并分发到各个机器
ansible 建立ssh信任并分发到各个机器
21 0
|
8天前
|
XML JSON 关系型数据库
Pandas一键解析代理IP与代理IP池的维护
Pandas一键解析代理IP与代理IP池的维护
|
5月前
|
网络协议 Linux 网络安全
suse 12 配置ip,dns,网关,hostname,ssh以及关闭防火墙
suse 12 配置ip,dns,网关,hostname,ssh以及关闭防火墙
150 0
|
1月前
|
存储 安全 网络安全
Git 安全远程访问:SSH 密钥对生成、添加和连接步骤解析
SSH(Secure Shell)是一种用于安全远程访问的协议,它提供了加密通信和身份验证机制。在使用 SSH 连接到远程 Git 存储库时,您可以使用 SSH 密钥对来确保安全性。以下是关于如何生成和使用 SSH 密钥对的详细步骤: 生成 SSH 密钥对
115 2
|
2月前
|
域名解析 缓存 网络协议

相关产品

  • 云解析DNS
  • 推荐镜像

    更多