使用PowerShell登陆多台Windows,测试DCAgent方法
目标:
需要1台PC用域账户远程登陆10台PC,每台登陆后的PC执行发送敏感数据的操作后,再logoff。
在DCAgent服务器上,查看这10个用户每次登陆时,DCAgent是否能获取到登陆信息(IP:User)
前提:
- 需要在AD域内添加测试账户,并将这些账户添加到一个group内。
- 需要将每个PC注册到AD域内,并设置group内用户都可以远程登陆。
- 需要设置指定用户登陆后,执行定时任务,定时任务为:发送敏感数据后,执行logoff操作。
- 需要定时读取DCAgent.bak文件的内容并记录。
测试步骤:
- 添加AD域账户,并将这些账户添加到一个group内。
我创建了user21-30这10个用户,并将这些用户添加到dc_group1中。
2. 需要将步骤1中的10个PC注册到AD域内,并设置group内用户都可以远程登陆。
- 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方法的更多相关文章
- windows测试模式
测试模式通常意义就是让windows 操作系统在测试状态下运行,windows操作系统在这种模式下可以运行非官方或无数字签名的驱动程序 . 目录 1 定义 2 进入/退出windows测试模式方法 ...
- 使用PowerShell收集多台服务器的性能计数器
写在前面 当管理多台Windows Server服务器时(无论是DB.AD.WEB以及其他的应用服务器),当出现性能或其他问题后,参阅性能计数器都是一个非常好的维度从而推测出问题可能出现的原因 ...
- Windows 上的 SSH?使用 PowerShell Remoting 远程管理 Windows 服务器
作者:陈计节 个人博客:https://blog.jijiechen.com/post/powershell-remoting/ 在 Linux/Unix 世界里 SSH 是个好东西,SSH 是 Se ...
- 同一台Windows机器中启动多个Memcached服务
同一台Windows机器中启动多个Memcached服务 这就需要在一台机器上启动多个Memcached服务了. 假设Memcached在如下目录:C:\memcached\memcached.exe ...
- ebay如何确定同一电脑登陆了多个账号,以及同一账号登陆过多台电脑
转自hilton 的BLOG http://jimqu.blog.51cto.com/105370/654691 一切要从ebay的买家保护说起 ebay作为一个电子商务平台,之所以可以汇聚如此众多的 ...
- Powershell script to install Windows Updates (msu) from folder
######################################################### # # Name: InstallWindowsUpdates.ps1 # Auth ...
- 一台Windows下配置多个Tomcat服务器
上一篇博客<Windows下配置Tomcat服务器>讲了,如何在一台Windows机器上配置一个Tomcat服务器.这篇介绍一下如何在一台Windows机器上配置多个Tomcat. 第一步 ...
- Perl脚本通过Expect登陆多台设备批量执行命令并Log
本例子尝试使用Perl脚本借助Expect模块实现如下目的: 登陆多台设备 设备登陆信息按如下格式存放于文件中. $ cat hosts.txt 192.168.30.7:node1:telnet:b ...
- Windows如何快速远程到另一台Windows并管理多个远程服务器
Windows如何远程到另一台 Windows管理多个远程服务器 Windows第三方远程管理工具 准备远程机器 开启远程机器的远程桌面功能 首先在此电脑(我的电脑)图标上点击鼠标右键,选择" ...
随机推荐
- linux下后台运行jar包
#当前窗口退出 项目关闭$ java -jar test.jar #当前窗口关闭 项目关闭$ nohup java -jar test.jar &#当前窗口关闭 项目不关闭$ nohup ja ...
- python3 井字棋 GUI - 人机对战、机器对战 (threading、tkinter库)
python3 井字棋 GUI - 人机对战.机器对战 功能 GUI界面 人机对战(可选择机器先走) 机器对战(50局) 流程图 内核 棋盘 [0][1][2] [3][4][5] [6][7][8] ...
- FreeBSD--常用命令
FreeBSD常用命令 查看网络流量 a.systat -if 1 (1表示1s刷新屏幕一次) b.netstat 1 # Traffic 流量 peak 峰值 average 平均值 查看进程p ...
- Laravel Nginx 除 `/` 外所有路由 404
解决方法 在nginx配置添加以下设置: location / { try_files $uri $uri/ /index.php?$query_string; } 详见Laravel官方文档:htt ...
- ubuntu中使用apt命令安装ipython失败解决方案
在最近使用ubuntu安装ipython时,出现如下报错: 出现这个问题,主要是因为apt还在运行,故解决方案为: 1.找到并且杀掉所有的apt-get 和apt进程 运行下面的命令来生成所有含有 a ...
- 12 new方法和单例、定制访问函数、装饰器
new方法和单例.定制访问函数.装饰器 上节课作业解答 # 通过多重继承方法,分别定义出动物,人类,和和荷兰人三种类 class Animal(object): def __init__(self, ...
- Can't connect to local MySQL server through socket '/tmp/mysql.sock'
今天在连接mysql的时候出现了上面的错误, 很明显原因找不到/socket 文件 查了半天才发现原来是mysql没有开启 service mysqld start 开启之后在/tmp/目录下回自 ...
- vue 组件间数据传递
父组件向子组件传值 方法一: 子组件想要使用父组件的数据,需要通过子组件的 props 选项来获得父组件传过来的数据. 1.父组件parent.vue中代码: <template> < ...
- spark streaming的应用
今天我们讲spark streaming的应用,这个是实时处理的,类似于Storm以及Flink相关的知识点, 说来也巧,今天的自己也去听了关于Flink的相关的讲座,可惜自己没有听得特别清楚,好像是 ...
- Vbs 测试程序一
转载请注明出处 有点小恶意哦!慎重测试 'This procedure is written in SeChaos, only for entertainment, not malicious com ...