Skip to content

Instantly share code, notes, and snippets.

@JonathonAnderson
JonathonAnderson / dns.c
Created November 29, 2021 04:52 — forked from fffaraz/dns.c
DNS Query Code in C with linux sockets
//DNS Query Program on Linux
//Author : Silver Moon (m00n.silv3r@gmail.com)
//Dated : 29/4/2009
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
# Check for pending reboots before attempting to update
reboot { 'pre_patch_reboot':
schedule => 'patch_window',
when => 'pending',
message => 'Reboot pending. Rebooting before attempting updates...',
}
Reboot['pre_patch_reboot'] -> Reboot['post_patch_reboot']
# Apply allowed/needed updates
$updates.each | $kb | {
#include <stdio.h>
int main(int argc, char* argv[])
{
FILE *fpt;
char byte;
long int where,move;
if(argc != 2)
{
$PendingReboot = Invoke-Command -ComputerName $Target -ScriptBlock `
{
#Checks if the registry key RebootRequired is present. It is created when Windows Updates are applied and require a reboot to take place
$PatchReboot = Get-ChildItem -Path REGISTRY::"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -ErrorAction SilentlyContinue
#Checks if the RebootPending key is present. It is created when changes are made to the component store that require a reboot to take place
$ComponentBasedReboot = Get-ChildItem -Path REGISTRY::"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -ErrorAction SilentlyContinue
#Checks if File rename operations are taking place and require a reboot for the operation to take effect
$PendingFileRenameOperations = (Get-ItemProperty -Path REGISTRY::"HKEY_LOCA
@JonathonAnderson
JonathonAnderson / Uninstall-Win10Driver.ps1
Last active September 4, 2019 15:47
Remove-DeviceDriver
$InstalledDrivers = $(pnputil.exe /enum-drivers)
$DriversToDelete = @( "netwtw04.inf"; "netwtw06.inf"; "netwtw08.inf" )
$OemInfs = New-Object -TypeName System.Collections.ArrayList -ArgumentList $DriversToDelete.Count
for($i = 0; $i -lt $InstalledDrivers.Length ; $i++ )
{
foreach($Driver in $DriversToDelete)
{
if($InstalledDrivers[$i] -like "*$Driver")
"{0:N2} MB" -f ((Get-ChildItem -Path '.\SQL Developer\Files' -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1MB)
@JonathonAnderson
JonathonAnderson / Find-LoggedOnUser.ps1
Created May 3, 2019 21:44
Finding logged on users, concept
#Get Currently logged in user
$ExplorerProcess = gwmi win32_process | where name -Match explorer
if($ExplorerProcess.getowner().user.count -gt 1){
$LoggedOnUser = $ExplorerProcess.getowner().user[0]
}
else{
$LoggedOnUser = $ExplorerProcess.getowner().user
}
Add-Type -Namespace Import -Name Win32 -MemberDefinition @'
[DllImport("advapi32.dll", SetLastError = true)]
public static extern bool LogonUser(string user, string domain, string password, int logonType, int logonProvider, out IntPtr token);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool CloseHandle(IntPtr handle);
'@
$Global:ImpersonatedUser = @{}
$tokenHandle = 0