r/PowerShell • u/[deleted] • Apr 15 '23
How to create a powershell script that will look in the eventlog for someone is authenticated from the cloud server?
I would appreciate for the help
1
u/N0-North Apr 15 '23
I mean, that sorta depends on what is meant to be generating events - Whatever app they're authenticating on would be responsible for generating events for you to review in the first place - like the others said, without a better idea of what you're trying to accomplish we're just gonna be taking shots in the dark
Are you trying to identify people logging in through RDP?
The event logs for login events are usually in security - I forget if RDP auth events are in there too, but would imagine they are since it's still winlogon
Something like this should get you events related to a specific account
Get-WinEvent -Logname Security |?{$_.message -like "*username*"}
1
Apr 15 '23
Im so sorry, the question is very complicated and not very specific. I will get up and check the questions again
2
u/N0-North Apr 15 '23
In your other comment you mentioned ownCloud - did some reading, looks like the auditing you need won't be captured in event viewer, but rather by their own auditing tools
https://doc.owncloud.com/server/next/admin_manual/enterprise/logging/admin_audit.html#view-and-download-logs
1
u/mrmattipants Apr 15 '23 edited Apr 15 '23
This looks like a good find, as well.
Tracking logon events to Owncloud with Powershell: https://www.serverbrain.org/system-administration/tracking-logon-events-to-owncloud-with-powershell.html
One of the Clients, for the Company I work for, has a NextCloud Implementation, which is built on OwnCloud.
I’ll see if I can pull some logs, from the NextCloud Server, via PowerShell. If I manage to get anywhere, I’ll be sure to post back, with my findings.
1
3
u/BlackV Apr 15 '23
look at Get-Help -Full Get-WinEvent or Get-Help -Online Get-WinEvent
is a good place to start
but more useful information would probably help too
what does "authenticated from cloud server" mean?
what "event" log?
5
u/OlivTheFrog Apr 15 '23
I love this type of question where nothing is said about the desired objective (/Ironic mode)
What is the desired objective? Proving a person's guilt for an illicit activity in the company?
If this activity is prohibited (for example: avoid exporting documents), he must not be able to do so. But let's move on, ... let's say the company hadn't blocked their site.
Suspicious activity is detected on the perimeter firewall. You have the IP and the date.
With the IP, you can go back to the machine (using DHCP, DCs eventlog, ...) .
On the machine (by requesting the eventLog) you will know who was connected to the workstation.
It remains to be proven that it was indeed the "real" owner of the account which was on the machine and not an identity theft.
By looking in the eventlog of the DCs you can know from which machine the person was identified. If it was authenticated on several machines at the same time and these machines are not close, it can be him, but not yet 100% (remote Desktop, ...).
One (or more) direct testimony can prove that at the time of the facts, it was indeed him on the incriminated machine.
There remains, however, a problem. If an activity should not be done, by design it should not be possible to do it. The company is also in default. Remember this : “Never a speed limit sign has prevented anyone from going over the limit”.
Regards
I had to do this following a judicial requisition (a kid had launched a bomb alert in a high school to avoid an exam).
1
u/Difficult-Ad7476 Apr 15 '23
Yea sound like something boss would ask. Chatgpt gonna take our jobs but these people cannot speak English the bot can understand that and they know everything
1
u/BreedScreamer Apr 15 '23
There are entire IDS/Edge/Layer7 firewalls that already do this :-) No need to reinvent the wheel guys...
1
u/rare_design Apr 15 '23
There isn’t enough information here.
What cloud system?
What Authenticator?
For instance, if you are using Azure, and Federated Services, both Azure and the FS server will have this information.
1
u/mrmattipants Apr 15 '23 edited Apr 15 '23
Without more information, pertaining to the Cloud Service, it is difficult to determine exactly which Event Logs you are looking for. Assuming you’re referring to a Windows Implementation (since you referred to Event Logs), I can help you get started by posting one of my own Scripts.
The following Script Scans the Security Logs, for Logs pertaining to Lockout Events (Event ID: 4740), that are associated with a specific User Account. It then Outputs all of the Log Data to a CSV File, which can be found on the Desktop of the User, who is Running the Script.
$Username = "user1"
$LogName = "security"
$EventId = "4740"
$DateTime = Get-Date -Format "yyyyMMdd_hhmmss"
Get-WinEvent -FilterHashtable @{logname='$LogName';Id=$EventId;data='$Username'} |
Select-Object -Property timecreated,
@{label='username';expression={$_.properties[0].value}},
@{label='computername';expression={$_.properties[1].value}},
@{label='eventid';expression={$_.id}},
@{label='taskname';expression={$_.TaskDisplayName}},
@{label='keyword';expression={$_.KeywordsDisplayNames}},
message |
Export-CSV -Path "$($ENV:USERPROFILE)\Desktop\$($Username)_$($ComputerName)_Event_$($EventId)_Logs_$($DateTime).csv" -NoTypeInformation
Of course, you'll need to update the Input Variables (Username, LogName, EventId), to match the Event Logs that you are Searching for, in specific. If you can post some additonal Information, I'll be happy to provide an updated version.
1
u/mrmattipants Apr 15 '23
I suppose that I should also ask if this is a Windows or Linux OwnCloud Implementation, since most of the documentation pertains to Linux.
OwnCloud - Retrieve Log Files and Configuration Settings: https://doc.owncloud.com/server/next/admin_manual/troubleshooting/providing_logs_and_config_files.html
OwnCloud - Auditing: https://doc.owncloud.com/server/next/admin_manual/enterprise/logging/admin_audit.html
OwnCloud - Logging Configuration: https://doc.owncloud.com/server/next/admin_manual/configuration/server/logging/logging_configuration.html
2
u/nealfive Apr 15 '23
Can you elaborate? ‘Cloud server’? In general ‘get-eventlog’ / ‘get-winevent’ can be used to get windows event logs