$Source = @" [DllImport("BluetoothAPIs.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall)] [return: MarshalAs(UnmanagedType.U4)] static extern UInt32 BluetoothRemoveDevice(IntPtr pAddress); public static UInt32 Unpair(UInt64 BTAddress) { GCHandle pinnedAddr = GCHandle.Alloc(BTAddress, GCHandleType.Pinned); IntPtr pAddress = pinnedAddr.AddrOfPinnedObject(); UInt32 result = BluetoothRemoveDevice(pAddress); pinnedAddr.Free(); return result; } "@ Function Get-BTDevice { Get-PnpDevice -class Bluetooth | ?{$_.HardwareID -match 'DEV_'} | select Status, Class, FriendlyName, HardwareID, # Extract device address from HardwareID @{N='Address';E={[uInt64]('0x{0}' -f $_.HardwareID[0].Substring(12))}} } ################## Execution Begins Here ################ $BTR = Add-Type -MemberDefinition $Source -Name "BTRemover" -Namespace "BStuff" -PassThru $BTDevices = @(Get-BTDevice) # Force array if null or single item Do { If ($BTDevices.Count) { "`n******** Bluetooth Devices ********`n" | Write-Host For ($i=0; $i -lt $BTDevices.Count; $i++) { ('{0,5} - {1}' -f ($i+1), $BTDevices[$i].FriendlyName) | Write-Host } $selected = Read-Host "`nSelect a device to remove (0 to Exit)" If ([int]$selected -in 1..$BTDevices.Count) { 'Removing device: {0}' -f $BTDevices[$Selected-1].FriendlyName | Write-Host $Result = $BTR::Unpair($BTDevices[$Selected-1].Address) If (!$Result) {"Device removed successfully." | Write-Host} Else {"Sorry, an error occured." | Write-Host} } } Else { "`n********* No devices found ********" | Write-Host } } While (($BTDevices = @(Get-BTDevice)) -and [int]$selected)
Мне, на память...
среда, 25 июня 2025 г.
Windows 11 отключить bluetooth гарнитуру
среда, 4 июня 2025 г.
hyper-v saved-critical windows 11
$VMManagementService = Get-WmiObject -Namespace 'root\virtualization\v2' -Class Msvm_VirtualSystemManagementService
$vmobject = Get-WmiObject -Namespace 'root\virtualization\v2' -Class 'msvm_computersystem' | Where-Object { $_.elementname -match $vmname }
$VMManagementService.DestroySystem($vmobject)
Меняется разрешение при выключении экрана
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\SIMULATED_8086_46A8_00000000_00020000_800050^1A6FF0E82864B84FCEAD280EFF0E764B\00]
"PrimSurfSize.cx"=dword:00000a00
"PrimSurfSize.cy"=dword:000005a0
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\SIMULATED_8086_46A8_00000000_00020000_800050^1A6FF0E82864B84FCEAD280EFF0E764B\00\00]
"ActiveSize.cx"=dword:00000a00
"ActiveSize.cy"=dword:000005a0
"PrimSurfSize.cx"=dword:00000a00
"PrimSurfSize.cy"=dword:000005a0
"DwmClipBox.right"=dword:00000a00
"DwmClipBox.bottom"=dword:000005a0
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\SIMULATED_8086_46A8_00000000_00020000_2045^DD31C473FFED3913883A19534512E68D\00]
"PrimSurfSize.cx"=dword:00000a00
"PrimSurfSize.cy"=dword:000005a0
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\SIMULATED_8086_46A8_00000000_00020000_2045^DD31C473FFED3913883A19534512E68D\00\00]
"ActiveSize.cx"=dword:00000a00
"ActiveSize.cy"=dword:000005a0
"PrimSurfSize.cx"=dword:00000a00
"PrimSurfSize.cy"=dword:000005a0
"DwmClipBox.right"=dword:00000a00
"DwmClipBox.bottom"=dword:000005a0
Заменить циферки на циферки в кавычечках
вторник, 4 марта 2025 г.
Alt linux в WSL
Нам нужен tar файл из архива:
https://ftp.altlinux.org/pub/distributions/ALTLinux/p11/images/cloud/x86_64/alt-p11-rootfs-systemd-x86_64.tar.xz
```powershell
$distro_name = "alt-p11"
$distro_storage = "c:\vm\_wsl\$($distro_name)"
$distro_tarball = "c:\users\public\iso\alt-p11-rootfs-systemd-x86_64.tar"
7z e c:\users\public\iso\alt-p11-rootfs-systemd-x86_64.tar.xz
wsl --unregister $distro_name
wsl --import $distro_name $distro_storage $distro_tarball
wsl -d alt-p11
```
```bash
apt-get update; apt-get install -y passwd sudo
wsluser=appc
adduser -G wheel $wsluser
echo -e "$wsluser ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$wsluser
passwd $wsluser
cat > /etc/wsl.conf <<EOF
[user]
default=$wsluser
[automount]
enabled = true
mountFsTab = false
root = /mnt/
options = "metadata,umask=22,fmask=11"
[network]
generateHosts = true
generateResolvConf = true
EOF
```
```powershell
wsl --terminate $distro_name
wsl -d $distro_name
```
четверг, 13 февраля 2025 г.
Не запускается sshd на Windows 10 The process terminated unexpectedly.
среда, 12 февраля 2025 г.
Конвертер Windows DHCP в kea-dhcp4.conf
powershell Convert-WindowsDHCPToKea.ps1 \ -in_xml "/var/tmp/win_dhcp.xml" \ -in_template "/etc/kea/kea-dhcp4.conf" \ -out_confdir "/etc/kea" \ -split "all" \ -out_dhcp4_conf "/etc/kea/kea-dhcp4.conf.json" \ -out_confd "/etc/kea/conf.d"
вторник, 3 декабря 2024 г.
Полезные фильтры для LDAP запросов в AD
List all users
To do this we select all the users ((objectClass=user)
) and all the people ((objectClass=person)
) of the LDAP:
(&(objectCategory=person)(objectClass=user))
List of all kerberoastables users
To do this we select all the users ((objectClass=user)
) having a Service Principal Name (SPN) defined ((servicePrincipalName=*)
) and we remove from our results:
- The user
krbtgt
(which by definition has an SPN) with the filter(!(cn=krbtgt))
. - Disabled users, with the filter
(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
Which gives us:
(&(objectClass=user)(servicePrincipalName=*)(!(cn=krbtgt))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
List of all asrep-roastables users
To do this we select all the users ((objectClass=user)
) that have "Do not require Kerberos preauthentication" flag set in their userAccountControl
:
(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304))
Find all Users that need to change password on next login.
(&(objectCategory=user)(pwdLastSet=0))
Find all Users that are almost Locked-Out
(&(objectCategory=user)(badPwdCount>=4))
Find all Users with *pass* or *pwd* in their description
(&(objectCategory=user)(|(description=*pass*)(description=*pwd*)))
List of all users protected by adminCount
The adminCount
attribute specifies that a given object has had its access control lists (ACLs) changed to a more secure value by the Active Directory system because it is a member of one of the administrative groups, either directly or transitively.
(&(objectCategory=user)(adminCount=1))
Groups
List all groups
(objectCategory=group)
List of all groups protected by adminCount
The adminCount
attribute specifies that a given object has had its access control lists (ACLs) changed to a more secure value by the Active Directory system because it is a member of one of the administrative groups, either directly or transitively.
(&(objectCategory=group)(adminCount=1))
Services
Listing all servicePrincipalName
(servicePrincipalName=*)
Listing specific services from their servicePrincipalName
To list specific services, we can use the beginning of the servicePrincipalName
attribute:
(servicePrincipalName=http/*)
Here is a few examples of servicePrincipalName
:
ldap/DC01.LAB.local
kadmin/changepw
(of kerberos serviceCN=krbtgt,CN=Users,DC=LAB,DC=local
)MSSQLSvc/DC01.LAB.local
Computers
Listing all computers with a given Operating System
For example to list all the machines under Windows XP
:
(&(objectCategory=Computer)(operatingSystem=Windows XP*))
With operatingSystem
in:
Windows Server 2022*
Windows Server 2019*
Windows Server 2016*
Windows Server 2008*
Windows 11*
Windows 10*
Windows 8*
Windows 7*
Windows Vista*
Windows XP*
Windows Server 2003*
Windows 2000*
Find all Workstations
(sAMAccountType=805306369)
Find all computers having a KeyCredentialLink
This is useful to check for shadow credentials on machine accounts:
(&(objectClass=computer)(msDS-KeyCredentialLink=*))
Find all computers having an Obsolete OS
(&(objectCategory=Computer)(|(operatingSystem=Windows 2000*)(operatingSystem=Windows Vista*)(operatingSystem=W
WSL ansible и правильные права на локальные диски
Create this file in your wsl: /etc/wsl.conf
Content:
[automount]
enabled = true
mountFsTab = false
root = /mnt/
options = "metadata,umask=22,fmask=11"
[network]
generateHosts = true
generateResolvConf = true
After that all /mnt/c/foo will have different folder permissions (not 777 any more) and you will be able to use chmod.
It requires you to have the latest WSL as far as I know.
среда, 13 ноября 2024 г.
Анало ipconfig registerdns в Linux
воскресенье, 24 марта 2024 г.
pxe boot grub efi legacy bios
grub-mkimage -d /usr/lib/grub/x86_64-efi/ -O x86_64-efi -o ./bootx64.efi -p '(tftp)/grub' efinet tftp
cp -r /usr/lib/grub/x86_64-efi
and after '/usr/lib/grub/x86_64-efi'
ion.
cp -r /usr/lib/grub/x86_64-efi ./
cp -r /usr/lib/grub/i386-pc ./
kickstart для минимальной установки redos для шаблона proxmox
Посмотреть список адресов в табличном виде powershell
VYOS 1.5 qcow2
https://github.com/vyos/vyos-rolling-nightly-builds/releases/download/1.5-rolling-202312191154/vyos-1.5-rolling-202312191154-amd64.iso
sudo ansible-playbook qemu.yml \
-e disk_size=10 \
-e cloud_init=true \
-e cloud_init_ds=NoCloud,ConfigDrive,None \
-e guest_agent=qemu \
-e keep_user=false \
-e enable_ssh=true \
-e iso_local=/home/appc/vyos-1.5-rolling-202312191154-amd64.iso
вторник, 30 января 2024 г.
SSTP + DST NAT NGINX APACHE share tcp 443
# добавим в список sstp-conn пакеты пришедшие на порт 443 для tls-host
address-list-timeout=5s \
dst-address-type=local \
/ip firewall nat add \
dst-port=443 \
to-ports=10443
# правило для публикации веб сервера
dst-port=80,443 \
# чтобы наше правило в таблице mangle работало каждый раз, надо модифицировать fasttrack
# или будем fasttrack только те соединения которые уже набрали хотя бы 10 килобайт, тогда надо заменить правло с fasttrack