Skip to content

Instantly share code, notes, and snippets.

View atao's full-sized avatar

ATAO atao

  • Share-Link (FR)
View GitHub Profile
@atao
atao / Wallpaper.ps1
Created July 7, 2017 12:34
Change wallpaper
# http://www.ghislain-lerda.com/2016/10/07/change-wallpaper/
$wallpaperPath = "mon_image.png"
$setwallpapersource = @"
using System.Runtime.InteropServices;
public class wallpaper
{
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
@atao
atao / ducky.vbs
Created July 3, 2017 22:28
Test script to emulate keyboard...
'https://msdn.microsoft.com/en-us/library/office/aa202943%28v=office.10%29.aspx'
Set objShell = CreateObject("WScript.Shell")
WScript.Sleep 800
objShell.SendKeys "^{ESC}"
WScript.Sleep 800
objShell.SendKeys "cmd"
'objShell.SendKeys "^+{ENTER}"
'objShell.SendKeys "{LEFT}"
WScript.Sleep 800
objShell.SendKeys "{ENTER}"
@atao
atao / eject.ps1
Created July 3, 2017 22:26
Just eject CD drives!
function Eject-CD
{
$drives = Get-WmiObject Win32_Volume -Filter "DriveType=5"
if ($drives -eq $null)
{
Write-Warning "Your computer has no CD drives to eject."
return
}
$drives | ForEach-Object {
(New-Object -ComObject Shell.Application).Namespace(17).ParseName($_.Name).InvokeVerb("Eject")
@atao
atao / lock_input.ps1
Last active June 11, 2025 22:36
⌨️ Lock keyboard and mouse during n seconds.
#Run As Administrator
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
$code = @"
[DllImport("user32.dll")]
public static extern bool BlockInput(bool fBlockIt);
"@
$userInput = Add-Type -MemberDefinition $code -Name UserInput -Namespace UserInput -PassThru
@atao
atao / RunAsAdmin.ps1
Last active October 15, 2025 13:05
🕵️ Self privileges escalation with PowerShell.
#Requires -RunAsAdministrator
#OneLine
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
#Or example :
# Store the current location
$Loc = Get-Location
@atao
atao / font_add.bat
Created April 24, 2017 10:01
Add font with GPO
net use x: "\\Path\fonts"
x:
xcopy /y *.ttf %systemroot%\fonts
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "font1 (TrueType)" /t REG_SZ /d "font1.ttf" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "font2 (TrueType)" /t REG_SZ /d "font2.ttf" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "font3 (TrueType)" /t REG_SZ /d "font3.ttf" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "font4 (TrueType)" /t REG_SZ /d "font4.ttf" /f
@atao
atao / removeappxpackages.ps1
Created February 3, 2017 14:49
Windows - Remove Apps For Every User
$appname = @(
"*BingWeather*"
"*ZuneMusic*"
"*ZuneVideo*"
)
ForEach($app in $appname){
Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue
}
@atao
atao / encoding.ps1
Created December 2, 2016 09:33
Encoding in PowerShell
$OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@atao
atao / Get-MSIFileInformation.ps1
Last active November 29, 2016 15:11
Get informations from MSI file.
#From http://www.scconfigmgr.com/2014/08/22/how-to-get-msi-file-information-with-powershell/
function Get-MSIFileInformation
{
param(
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[System.IO.FileInfo]$Path,
[parameter(Mandatory=$true)]
@atao
atao / iamroot.ps1
Created November 29, 2016 14:44
PowerShell is running with administrator rights?
#RunInAdmin?
([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)