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
    
    注:
    
    服务执行成功后不会自动删除

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    SQL查询效率100w数据查询只要1秒
    超级实用且不花哨的js代码大全 (四) JavaScript[对象.属性]集锦
    Sql Server实用操作维护小技巧集合
    asp.net截取字符串方法
    自己整理的asp.net 缓存 相关资料
    【译】初识SSRS 通向报表服务的阶梯系列(一)
    【译】无处不在的数据 通向报表服务的阶梯系列(三)
    【译】SSRS基础 通向报表服务的阶梯系列(二)
    浅谈SQL Server中的事务日志(三)在简单恢复模式下日志的角色
    SQL Server中生成测试数据
  • 原文地址:https://www.cnblogs.com/-qing-/p/10673647.html
Copyright © 2011-2022 走看看