目标:

需要1台PC用域账户远程登陆10台PC,每台登陆后的PC执行发送敏感数据的操作后,再logoff。

在DCAgent服务器上,查看这10个用户每次登陆时,DCAgent是否能获取到登陆信息(IP:User)

 

前提:

  1. 需要在AD域内添加测试账户,并将这些账户添加到一个group内。
  2. 需要将每个PC注册到AD域内,并设置group内用户都可以远程登陆。
  3. 需要设置指定用户登陆后,执行定时任务,定时任务为:发送敏感数据后,执行logoff操作。
  4. 需要定时读取DCAgent.bak文件的内容并记录。

测试步骤:

  1. 添加AD域账户,并将这些账户添加到一个group内。

    我创建了user21-30这10个用户,并将这些用户添加到dc_group1中。

2.   需要将步骤1中的10个PC注册到AD域内,并设置group内用户都可以远程登陆。

  1. 1.   对指定的登陆用户设置定时任务:

PC IP地址

用户名

172.18.0.21

user21

172.18.0.22

user22

172.18.0.23

user23

172.18.0.24

user24

172.18.0.25

user25

172.18.0.26

user26

172.18.0.27

user27

172.18.0.28

user28

172.18.0.29

user29

172.18.0.30

user30

 

1)        下载curl.exe程序,用来发送http post请求。

2)        编写test.bat批处理程序,用来执行发送敏感数据和logoff操作

test.bat:

echo start
@echo off \test_folder\curl.exe -X POST http://172.16.0.10/cgi-bin/save_file_linux.py -F "filename=test.txt" -v
echo job is done
shutdown -L

3)        设置定时任务:

开始->所有程序->附件->系统工具->任务计划程序->

4.  在管理PC上执行powershell.ise:

Powershell脚本代码:

function Connect-RDP {

  param (
[Parameter(Mandatory=$true)]
$ComputerName, [System.Management.Automation.Credential()]
$Credential
) # take each computername and process it individually
$ComputerName | ForEach-Object { # if the user has submitted a credential, store it
# safely using cmdkey.exe for the given connection
if ($PSBoundParameters.ContainsKey('Credential'))
{
# extract username and password from credential
$User = $Credential.UserName
$Password = $Credential.GetNetworkCredential().Password # save information using cmdkey.exe
cmdkey.exe /generic:$_ /user:$User /pass $Password
} # initiate the RDP connection
# connection will automatically use cached credentials
# if there are no cached credentials, you will have to log on
# manually, so on first use, make sure you use -Credential to submit
# logon credential mstsc.exe /v $_
}
} #Connect-RDP 172.18.0.101 -Credential zoo\user12
$a = F:/press_cancel_btn.au3 DO
{
Connect-RDP 172.18.0.21
Connect-RDP 172.18.0.22
Connect-RDP 172.18.0.23
Connect-RDP 172.18.0.24
Connect-RDP 172.18.0.25
Connect-RDP 172.18.0.26
Connect-RDP 172.18.0.27
Connect-RDP 172.18.0.28
Connect-RDP 172.18.0.29
Connect-RDP 172.18.0.30 timeout /t
$a++
} While ($a -le ) If($a -eq )
{
Stop-Process -processname AutoIt3*
echo finished
}

press_cancel_btn.au3代码:

需要安装autoit3程序。

#include <AutoItConstants.au3>

Dim $count = 

while $count < 

;click Windows PowerShell Credential Request cancel button
ControlClick("Windows PowerShell Credential Request", "","Button3") Wend

注意:在第一次执行powershell脚本时,需要让PC记录每个远程桌面的Credential,所以在第一次时需要这样执行:

Connect-RDP 172.18.0.21 -Credential zoo\user21

Connect-RDP 172.18.0.21 -Credential zoo\user22

Connect-RDP 172.18.0.21 -Credential zoo\user23

Connect-RDP 172.18.0.21 -Credential zoo\user30

在正常的测试时,只需要按脚本执行即可。

5.在DCAgent服务器上定时查看DCAgent.bak文件并记录:

Record.py

import time

while True:
origin_file=open('DCAgent.bak','rb')
target_file=open('record.txt','a') for line in origin_file:
content = line.strip()
target_file.write(content) target_file.write('\n') origin_file.close()
target_file.close()
time.sleep(10)

使用PowerShell登陆多台Windows,测试DCAgent方法的更多相关文章

  1. windows测试模式

    测试模式通常意义就是让windows 操作系统在测试状态下运行,windows操作系统在这种模式下可以运行非官方或无数字签名的驱动程序 .   目录 1 定义 2 进入/退出windows测试模式方法 ...

  2. 使用PowerShell收集多台服务器的性能计数器

    写在前面     当管理多台Windows Server服务器时(无论是DB.AD.WEB以及其他的应用服务器),当出现性能或其他问题后,参阅性能计数器都是一个非常好的维度从而推测出问题可能出现的原因 ...

  3. Windows 上的 SSH?使用 PowerShell Remoting 远程管理 Windows 服务器

    作者:陈计节 个人博客:https://blog.jijiechen.com/post/powershell-remoting/ 在 Linux/Unix 世界里 SSH 是个好东西,SSH 是 Se ...

  4. 同一台Windows机器中启动多个Memcached服务

    同一台Windows机器中启动多个Memcached服务 这就需要在一台机器上启动多个Memcached服务了. 假设Memcached在如下目录:C:\memcached\memcached.exe ...

  5. ebay如何确定同一电脑登陆了多个账号,以及同一账号登陆过多台电脑

    转自hilton 的BLOG http://jimqu.blog.51cto.com/105370/654691 一切要从ebay的买家保护说起 ebay作为一个电子商务平台,之所以可以汇聚如此众多的 ...

  6. Powershell script to install Windows Updates (msu) from folder

    ######################################################### # # Name: InstallWindowsUpdates.ps1 # Auth ...

  7. 一台Windows下配置多个Tomcat服务器

    上一篇博客<Windows下配置Tomcat服务器>讲了,如何在一台Windows机器上配置一个Tomcat服务器.这篇介绍一下如何在一台Windows机器上配置多个Tomcat. 第一步 ...

  8. Perl脚本通过Expect登陆多台设备批量执行命令并Log

    本例子尝试使用Perl脚本借助Expect模块实现如下目的: 登陆多台设备 设备登陆信息按如下格式存放于文件中. $ cat hosts.txt 192.168.30.7:node1:telnet:b ...

  9. Windows如何快速远程到另一台Windows并管理多个远程服务器

    Windows如何远程到另一台 Windows管理多个远程服务器 Windows第三方远程管理工具 准备远程机器 开启远程机器的远程桌面功能 首先在此电脑(我的电脑)图标上点击鼠标右键,选择" ...

随机推荐

  1. Mysql5.7创建存储过程中调用自定义函数报错Not allowed to return a result set from a function

    因为很多存储过程都会共用一段sql语句,所以我把共用的sql封装成一个自定义函数 AddCapital(); 然后通过存储过程调用,创建存储过程会报错1415,Not allowed to retur ...

  2. Spring MVC 接收前端参数的方式

    方式一: 普通方式接收 1 @RequestMapping("/index") 2 public String getUserName(String username) { 3 S ...

  3. keepalived实现nginx的高可用

    1.使用yum安装keepalived yum install keepalived -y 2.修改配置文件keepalived.conf 主服务器配置文件 global_defs { router_ ...

  4. tcl之string操作-length/index/range/replace

  5. 【linux】【指令】systemctl 指令部分解读

    systemctl [OPTIONS...] {COMMAND} ... Query or send control commands to the systemd manager. -h --hel ...

  6. html常用的实体符号

    HTML中有用的字符实体 字符实体的书写方式如:&entity_name(实体名称法) 或 &#entity_number(实体数字法) 例如用字符实体的形式表示小于号:< 或 ...

  7. SQL Server 数据库内部版本号

    数据库还原或版本升级出现版本错误时可参考 可以利用SQL语句查看本机数据库版本:select @@VERSION 如果你不确定是源数据库的版本,下面的映射表的SQL Server版本的内部版本号,以便 ...

  8. C语言数组篇(一)一维数组

       0.  数组的两种表现形式         一种是常见的a[10];         //初学者常用         另一种是用指针表示的数组.   //实际工程使用.常用于参数传递       ...

  9. java和c/c++

    写c/c++的人,羡慕java可以自己管理内存 写java的人,羡慕c/c++没有gc问题

  10. 《Cracking the Coding Interview》——第14章:Java——题目1

    2014-04-26 18:20 题目:从继承的角度,把构造函数设成private有什么意义? 解法:就不能继承了.单体模式里也这么干,目的是为了不让使用者自主生成对象,进行限制. 代码: // 14 ...