首页 > 其他分享 >dnscapy使用——本质上是建立ssh的代理(通过dns tunnel)

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

时间:2023-05-31 15:04:34浏览次数:49  
标签:tunnel py server dnscapy ssh DNS com

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" [email protected]

其中: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 [email protected]:/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 ?

 

标签:tunnel,py,server,dnscapy,ssh,DNS,com
From: https://blog.51cto.com/u_11908275/6386917

相关文章

  • DNS Tunnel判定方法
    DNSTunnel判定方法:1、查询DNS请求的域名是否存在备案; 2、查询DNS请求的域名情报信息(以及域名的alex排名); 3、查看相同主域名下子域名编码格式及长度;(存在Base32和Base64编码且较长需要多加关注,同时xshellghostdnstunnel关注下) 4、利用浏览器做实际登陆尝试(是否正常打开......
  • go 执行ssh 报错ssh: handshake failed: read tcp xxx:->xxx:22: read: connection re
    需求:解决报错go执行ssh报错ssh:handshakefailed:readtcpxxx:->xxx:22:read:connectionresetbypeer 10个以内,没有问题。10以上就报错解决:我的远程(192.168.49.171)服务器ssh默认最大限制10解除限制,下面的操作都是在49.171上操作的。1.编辑sshd_confi......
  • SSH协议-漏洞渗透挖掘
     ......
  • SSH公钥配置-Github
    配置SSH,拉取远程git仓库代码1.查看~/.ssh目录是否存在,如果存在,则说明已存在SSHKey,跳到第3步2.生成公钥文件~/.ssh目录不存在时,执行如下命令:ssh-keygen-trsa-C"[email protected]",接下来一直回车即可。如果要指定公钥名称,例如:ssh-keygen-trsa-C"[email protected]"-f~/.s......
  • 源码编译安装openssh 最新版
    #创建几个目录备用mkdir-p/usr/local/zlib/mkdir-p/usr/local/openssl/mkdir-p/usr/local/openssh/ #安装编译需要用到的依赖包yum-yinstallwgetdnfvimgccgcc-c++makeperlpam-devel #下载相关源码包cd/rootwgethttps://ftp.openbsd.org/pub......
  • hj_podman_jenkins_maven_git_springboot_ssh一键部署项目
    podmanpulljenkins/jenkins:jdk17podmanrun-d--privileged=true\-uroot--namejenkins_jdk17_8081\-p8081:8080-p50001:50000\-v/hj_files/jenkins_jdk17:/var/jenkins_home\a307650508c6http://105.35.260.230:8081/ 安装好推荐配置后.再安装俩插件  Mave......
  • Ansible 安装与ssh密钥配置
    环境系统IP名称CentOS7.610.22.86.71管理机CentOS7.610.22.86.72被控机CentOS7.610.22.86.73被控机CentOS7.610.22.86.74被控机安装#yum源[root@localhost~]#cat/etc/yum.repos.d/epel.repo[epel]name=ExtraPackagesforEnterpriseLi......
  • ssh免密码登录远程服务器
    应该有很多种方法,介绍一种只需要两步骤就能完成的方法:1、在自己的Linux系统上生成SSH密钥和公钥打开终端,使用下面的ssh-keygen来生成RSA密钥和公钥.-t表示type,就是说要生成RSA加密的钥匙.ssh-keygen-trsa2、将SSH公钥上传到Linux服务器可以使用ssh-copy-id命令来完成.ssh-cop......
  • linphone-TunnelConfigImpl文件对应的JNI层文件分析
    说明native函数privatenativeStringgetHost(longnativePtr);privatenativevoidsetHost(longnativePtr,Stringhost);privatenativeintgetPort(longnativePtr);privatenativevoidsetPort(longnativePtr,intport);privatenativeintgetRem......
  • linphone-Tunnelconfig.java文件分析
    说明此类的主要作用主要是配置Host,port等。功能设置获取Host设置获取Port设置获取RemoteUdpMirrorPort获取设置maximumamountoftimeUML类图TunnelConfig.javapackageorg.linphone.core;publicclassTunnelConfigImplimplementsTunnelConfig{longmNativePtr;pr......