Xshell7安装在win7x64里,容器CentOS8的宿主机是ubuntu18.04(安装在VMware里)
docker search cobaltstrike
docker pull xrsec/cobaltstrike
在ubuntu里启动docker:
setsid docker run -it --name cs45 -e passwd="admin888" -e server_ip="127.7.7.2"
-e server_port=43002 \
-e aliasname="Bing_Wallpaper" \
-e dname="CN=www.microsoft.com, OU=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=WA, C=US" \
-p43002:43002 -p40080:80 -p43389:3389 -p2255:22 a53c57f6c4f8 &
此时控制台可能被锁住,在ubuntu里另外开一个控制shell窗口,输入如下代码,get容器内部shell:
docker exec -it cs45 /bin/bash
执行如下命令,查看这个容器的版本:
[root@cd2ff00d25c0 cobaltstrike]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
[root@cd2ff00d25c0 cobaltstrike]#
接下来在容器内部的shell里安装openssh,并修改sshd的配置:
yum install -y openssh-server;
sed -i "s/^#\?\(PermitRootLogin\)/\1 yes#/g" /etc/ssh/sshd_config;
sed -i "s/^#\?\(GatewayPorts\)/\1 yes#/g" /etc/ssh/sshd_config;
# grep -E "X11Forwarding|PermitRootLogin|PasswordAuthentication" /etc/ssh/sshd_config
# grep X11Forwarding /etc/ssh/sshd_config ;
# 默认 X11Forwarding是yes的不用修改 .
修改root密码:
echo root:123456|chpasswd;
启动ssh_server服务:
ssh-keygen -A
setsid /usr/sbin/sshd -D &
此时在外部win7x64用Xshell连接ubuntu18.04虚拟机的tcp2244端口,提示:
WARNING! The remote SSH server rejected X11 forwarding request.
安装xorg-x11-xauth(在CentOS8里)可以解决这个问题,安装后不用重启ssh_server.
yum install -y xorg-x11-xauth
接下来在win7里安装Xming,大小2M: Xming-6-9-0-31-setup.exe
https://sourceforge.net/projects/xming/files/Xming/6.9.0.31/Xming-6-9-0-31-setup.exe/download
我在win7x64 sp1里安装Xming,一路默认安装,
安装完毕后启动XLaunch.exe,一路默认设置,
需要填写display number 的时候,默认是0 ,我填5,所以后面xshell里也要改.
然后托盘区会启动一个图标长这样,如图:
接下来安装python3的tkinter用来做GUI显示测试:
dnf install -y python3
dnf install -y python3-tkinter
继续配置xshell:
此时用Xshell SSH连接 CentOS 8,执行如下命令,显示图形:
实验成功.