当前位置: 首页 > 编程日记 > 正文

使用PowerShell登陆多台Windows,测试DCAgent方法

目标:

需要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 connectionif ($PSBoundParameters.ContainsKey('Credential'))
    {# extract username and password from credential$User = $Credential.UserName$Password = $Credential.GetNetworkCredential().Password# save information using cmdkey.execmdkey.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 credentialmstsc.exe /v $_ }
}#Connect-RDP 172.18.0.101 -Credential zoo\user12
$a = 1F:/press_cancel_btn.au3DO
{
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.30timeout /t 250
$a++
} While ($a -le 10)If($a -eq 11)
{
Stop-Process -processname AutoIt3*
echo finished
}

press_cancel_btn.au3代码:

需要安装autoit3程序。

#include <AutoItConstants.au3>Dim $count = 12while $count < 243;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 timewhile 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)

转载于:https://www.cnblogs.com/bonjov1/p/5302373.html

相关文章:

优雅地分离tableview回调

你是否遇到过这样的需求,在tableview中显示一列数据,点击某一个cell时&#xff0c;在此cell下显示相应的附加信息。如下图&#xff1a;你是不是觉得需求很容易实现&#xff0c;只要使用tableview的insertRowsAtIndexPaths:withRowAnimation:插入一个附加cell就可以了&#xff0…

next.js_Next.js手册

next.jsI wrote this tutorial to help you quickly learn Next.js and get familiar with how it works.我编写本教程是为了帮助您快速学习Next.js并熟悉其工作方式。 Its ideal for you if you have zero to little knowledge of Next.js, you have used React in the past,…

Redux 入门教程(一):基本用法

一年半前&#xff0c;我写了《React 入门实例教程》&#xff0c;介绍了 React 的基本用法。 React 只是 DOM 的一个抽象层&#xff0c;并不是 Web 应用的完整解决方案。有两个方面&#xff0c;它没涉及。代码结构组件之间的通信对于大型的复杂应用来说&#xff0c;这两方面恰恰…

Elasticsearch——Rest API中的常用用法

本篇翻译的是Elasticsearch官方文档中的一些技巧&#xff0c;是使用Elasticsearch必不可少的必备知识&#xff0c;并且适用于所有的Rest Api。 返回数据格式化 当在Rest请求后面添加?pretty时&#xff0c;结果会以Json格式化的方式显示。另外&#xff0c;如果添加?formatyaml…

Python几种主流框架

从GitHub中整理出的15个最受欢迎的Python开源框架。这些框架包括事件I/O&#xff0c;OLAP&#xff0c;Web开发&#xff0c;高性能网络通信&#xff0c;测试&#xff0c;爬虫等。 Django: Python Web应用开发框架Django 应该是最出名的Python框架&#xff0c;GAE甚至Erlang都有框…

Git Fetch vs Pull:Git Fetch和Git Pull命令之间有什么区别?

Git pull and fetch are two commands that are regularly used by Git users. Let’s see the difference between both commands.Git pull和fetch是Git用户经常使用的两个命令。 让我们看看两个命令之间的区别。 For the sake of context, it’s worth remembering that we’…

Redux 入门教程(二):中间件与异步操作

上一篇文章&#xff0c;我介绍了 Redux 的基本做法&#xff1a;用户发出 Action&#xff0c;Reducer 函数算出新的 State&#xff0c;View 重新渲染。但是&#xff0c;一个关键问题没有解决&#xff1a;异步操作怎么办&#xff1f;Action 发出以后&#xff0c;Reducer 立即算出…

day09_读写分离_组件介绍

mysql中间件研究&#xff08;Mysql-prxoy&#xff0c;Atlas&#xff0c;阿米巴&#xff0c;cobar&#xff0c;TDDL&#xff09;mysql-proxyMySQL Proxy就是这么一个中间层代理&#xff0c;简单的说&#xff0c;MySQL Proxy就是一个连接池&#xff0c;负责将前台应用的连接请求转…

Idea其他设置

一、生成javadoc Tools->Gerenate JavaDoc 1. 选择是整个项目还是模块还是单个文件 2. 文档输出路径 3. Locale 选择地区&#xff0c;这个决定了文档的语言&#xff0c;中文就是zh_CN 4. 传入JavaDoc的参数&#xff0c;一般这样写 -encoding UTF-8 -charset UTF-8 -windowti…

freecodecamp_常见技术支持问题– freeCodeCamp常见问题解答

freecodecamp问题&#xff1a;我刚刚登录我的帐户&#xff0c;但看不到过去的任何进展。 (Question: I just signed into my account and I dont see any of my past progress.) Answer: You have created a duplicate account. Sign out of your account and try signing in u…

Redux 入门教程(三):React-Redux 的用法

前两篇教程介绍了 Redux 的基本用法和异步操作&#xff0c;今天是最后一部分&#xff0c;介绍如何在 React 项目中使用 Redux。 为了方便使用&#xff0c;Redux 的作者封装了一个 React 专用的库 React-Redux&#xff0c;本文主要介绍它。 这个库是可以选用的。实际项目中&…

SDN第二次上机作业

1、安装floodlight 2、生成拓扑并连接控制器floodlight&#xff0c;利用控制器floodlight查看图形拓扑 3、利用字符界面下发流表&#xff0c;使得‘h1’和‘h2’ ping 不通 4、利用字符界面下发流表&#xff0c;通过测试‘h1’和‘h3’的联通性&#xff0c;来验证openflow的har…

[KIWI syslog]Install document

安全日志的标准是rfc5425 它介绍SSL-tunnel日志标准和相关要求的标准定义。此外&#xff0c;IANA分配TCP端口6514作为一个标准的端口安全日志。 安装说明&#xff1a; 1.安装日志服务器 官方下载地址&#xff1a;http://www.kiwisyslog.com/products/. 安装步骤&#xff1a; 转…

机器学习数据拆分_解释了关键的机器学习概念-数据集拆分和随机森林

机器学习数据拆分数据集分割 (Dataset Splitting) Splitting up into Training, Cross Validation, and Test sets are common best practices. This allows you to tune various parameters of the algorithm without making judgements that specifically conform to trainin…

Oracle 导表异常处理方案 (解决空表导出出错问题)

Select alter table ||table_name|| allocate extent; from user_tables where num_rows0 or num_rows is null 然后执行查询语句 再导出数据 一个语句搞定&#xff1a; declare stmt varchar2(200); begin for tb in (select table_name from user_tables where seg…

10个你必须知道的ios框架

你好&#xff0c;iOS 开发者们&#xff01;我的名字叫 Pawe?&#xff0c;我是一个独立 iOS 开发者&#xff0c;并且是 Enter Universe 的作者。 接近两年前我发布了iOS开源库&#xff0c;让你的开发坐上火箭吧。这是我在这里最棒的文章了&#xff08;根据 Medium 用户的反馈来…

生成N个不相等的随机数

近期项目中须要生成N个不相等的随机数。实现的时候。赶工期&#xff0c;又有项目中N非常小(0-100)直接谢了一个最直观的方法: public static List<Integer> randomSet(int num,int threshold){Random random new Random();if(num > threshold) return null;Set<In…

kafka streams_如何使用Kafka Streams实施更改数据捕获

kafka streamsChange Data Capture (CDC) involves observing the changes happening in a database and making them available in a form that can be exploited by other systems. 更改数据捕获 (CDC)涉及观察数据库中发生的更改&#xff0c;并将其以可被其他系统利用的形式…

iOS超全开源框架、项目和学习资料汇总(1)UI篇

上下拉刷新控件**1. ** MJRefresh --仅需一行代码就可以为UITableView或者CollectionView加上下拉刷新或者上拉刷新功能。可以自定义上下拉刷新的文字说明。&#xff08;推荐&#xff09;**2. ** SVPullToRefresh --下拉刷新控件4500star&#xff0c;值得信赖**3. ** CBStoreHo…

day16 递归函数

一、递归 函数 为什么要有函数&#xff0c;提高代码的可读性&#xff0c;避免重复的代码&#xff0c;提高代码的复用性 在函数中能用return的不要print 1、递归的最大深度997 def foo(n):print(n)n1foo(n) foo(1) 递归的最大深度2、修改递归的最大深度 由此我们可以看出&#x…

设计模式之笔记--抽象工厂模式(Abstract Factory)

抽象工厂模式&#xff08;Abstract Factory&#xff09; 定义 抽象工厂模式&#xff08;Abstract Factory&#xff09;&#xff0c;提供一个创建一系列相关或相互依赖对象的接口&#xff0c;而无需指定它们具体的类。 类图 描述 多个抽象产品类&#xff0c;每个抽象产品类可以派…

用户体验改善案例_如何检测用户的设备,以便改善他们的用户体验

用户体验改善案例A few months ago I watched a great talk from the Chrome Dev Summit about performance in slow devices.几个月前&#xff0c;我观看了Chrome开发者峰会上有关慢速设备性能的精彩演讲。 It blew my mind all the work done by Facebook in identifying de…

【如何快速的开发一个完整的iOS直播app】(采集篇)

前言在看这篇之前&#xff0c;如果您还不了解直播原理&#xff0c;请查看这篇文章如何快速的开发一个完整的iOS直播app(原理篇)开发一款直播app&#xff0c;首先需要采集主播的视频和音频&#xff0c;然后传入流媒体服务器&#xff0c;本篇主要讲解如何采集主播的视频和音频&am…

easyui 报表合并单元格

前段时间工作中碰到有需求&#xff0c;要求数据按下图所示格式来显示&#xff0c;当时在园子里看到了一篇文章&#xff08;时间久了&#xff0c;想不起是哪一篇&#xff09;&#xff0c;研究了后做出了如下的DEMO&#xff0c;在此当作学习笔记&#xff0c;简单记录一下。 首先是…

HDU2594 KMP next数组的应用

这道题就是给你两个串s1, s2让你求出s1 s2的最长相同前缀和后缀&#xff0c; 我们直接将s1 s2连接到一起然后处理一下next数组即可&#xff0c; 注意答案应该是min(len(s1), len(s2) , next[len]), 代码如下&#xff1a; #include <cstdio> #include <cstring> #in…

c语言中浮点数和整数转换_C中的数据类型-整数,浮点数和空隙说明

c语言中浮点数和整数转换C中的数据类型 (Data Types in C) There are several different ways to store data in C, and they are all unique from each other. The types of data that information can be stored as are called data types. C is much less forgiving about d…

【如何快速的开发一个完整的iOS直播app】(美颜篇)

前言在看这篇之前&#xff0c;如果您还不了解直播原理&#xff0c;请查看这篇文章如何快速的开发一个完整的iOS直播app(原理篇)开发一款直播app&#xff0c;美颜功能是很重要的&#xff0c;如果没有美颜功能&#xff0c;可能分分钟钟掉粉千万&#xff0c;本篇主要讲解直播中美颜…

Linux内核分析——第五章 系统调用

第五章 系统调用 5.1 与内核通信 1、系统调用在用户空间进程和硬件设备之间添加了一个中间层&#xff0c;该层主要作用有三个&#xff1a; &#xff08;1&#xff09;为用户空间提供了一种硬件的抽象接口 &#xff08;2&#xff09;系统调用保证了系统的稳定和安全 &#xff08…

BZOJ 3110

http://www.lydsy.com/JudgeOnline/problem.php?id3110 整体二分区间修改树状数组维护 #include<cstdio> #define FOR(i,s,t) for(register int is;i<t;i) inline int max(int a,int b){return a>b?a:b;} inline int min(int a,int b){return a<b?a:b;} type…

css 选择器 伪元素_CSS伪元素-解释选择器之前和之后

css 选择器 伪元素选择器之前 (Before Selector) The CSS ::before selector can be used to insert content before the content of the selected element or elements. It is used by attaching ::before to the element it is to be used on.CSS ::before选择器可用于在选定…