zoukankan      html  css  js  c++  java
  • Windows下计划任务的使用

    0x01 前言

    在渗透测试中,尤其是域渗透,常常会用到Windows系统的计划任务,一是用于远程启动程序,二是用于程序的自启动

    那么,计划任务具体有哪些使用技巧呢?是否对权限有要求?一定需要管理员权限才能运行吗?

     

    官方说明文档:

    https://msdn.microsoft.com/en-us/library/windows/desktop/aa446802(v=vs.85).aspx

    需要开启服务Task Scheduler

     

     

    可在以下情况触发:

    When a specific system event occurs.

    At a specific time.

    At a specific time on a daily schedule.

    At a specific time on a weekly schedule.

    At a specific time on a monthly schedule.

    At a specific time on a monthly day-of-week schedule.

    When the computer enters an idle state.

    When the task is registered.

    When the system is booted.

    When a user logs on.

    计划任务创建后,会在C:WindowsSystem32Tasks保存XML格式的配置文件

     

    例如我创建了一个名为test的定时任务,此目录下会生成相应的XML配置文件

     

     

     

    0x02 计划任务的配置方式

    1、界面操作

    执行taskschd.msc,如下图

     

    选中任务计划程序,右键 -> 创建任务

    弹出界面,逐个配置即可,如下图

     

     

    2、命令行配置

    (1) at 命令

    At 运行时间 运行程序

     

    (管理员权限)

    eg:

    at 23:53 notepad.exe

     

     

     

    默认以system权限启动,适用于Win7

    Win8开始不再支持at命令,所以不过多介绍

     

     

    (2) schtasks命令

    支持Win7-Win10

     

    1. 每天固定时间,以普通权限启动notepad.exe

     

    命令如下:

    schtasks /Create /TN TestService1 /SC DAILY /ST 01:02 /TR notepad.exe

    C:WindowsSystem32Tasks产生新文件TestServ

     

     

     

    值得注意的是<RunLevel>LeastPrivilege</RunLevel>,代表权限为普通用户

     

     

     

     

     

    2.每天固定时间,以system权限启动notepad.exe

    命令如下(管理员权限):

    schtasks /Create /TN TestService2 /SC DAILY /ST 01:02 /TR notepad.exe /RL HIGHEST

    C:WindowsSystem32Tasks产生新文件TestService2,内容如下:

    值得注意的是<RunLevel>HighestAvailable</RunLevel>,代表权限为最高,一般为System权限

     

    3.每天固定时间,以system权限启动notepad.exe,通过导入xml文件的方式

    以文件TestService2作为模板,修改启动时间,保存为1.xml,内容如下:

     

     

    通过xml文件导入配置,建立计划任务,以system权限启动,命令如下(管理员权限):

    schtasks /create /xml c: est1.xml /tn TestService3

    注:

    如果是一个新的系统,修改<Author><Date><StartBoundary><UserId><Command>即可

     

    4.每天固定时间,以普通权限启动notepad.exe,通过导入xml文件的方式

    修改1.xml:
    
    <RunLevel>HighestAvailable</RunLevel>改为<RunLevel>LeastPrivilege</RunLevel>即可
    
    导入配置的命令如下:
    
    schtasks /create /xml c:	est1.xml /tn TestService4

    补充:schtasks的其他命令用法

    查看服务状态:
    
    schtasks /Query /TN TestService1
    
    删除服务:
    
    schtasks /Delete /TN TestService1 /F
    
    注:
    
    服务执行成功后不会自动删除

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    linux 11201(11203) ASM RAC 安装
    [学习笔记]多项式对数函数
    linux 10201 ASM RAC 安装+升级到10205
    tar
    [学习笔记]多项式开根
    gzip
    小朋友和二叉树
    zip
    bzoj5016 一个简单的询问
    unzip
  • 原文地址:https://www.cnblogs.com/-qing-/p/10673647.html
Copyright © 2011-2022 走看看