Skip to content

Instantly share code, notes, and snippets.

@IAmStoxe
IAmStoxe / Kill-PortProcess.ps1
Created June 3, 2024 19:05
This script finds and terminates the process listening on specified port.
# Find the process ID (PID) listening on port
$port = 3000
$processId = Get-NetTCPConnection -LocalPort $port | Select-Object -ExpandProperty OwningProcess
# Check if processId is found
if ($processId) {
# Kill the process with the found processId
Stop-Process -Id $processId -Force
Write-Output "Process with PID $processId listening on port 3000 has been terminated."
} else {
$KnownFolders = @{}
$KnownFolders.Add("{DE61D971-5EBC-4F02-A3A9-6C82895E5C04}" , "AddNewPrograms")
$KnownFolders.Add("{724EF170-A42D-4FEF-9F26-B60E846FBA4F}" , "AdminTools")
$KnownFolders.Add("{A520A1A4-1780-4FF6-BD18-167343C5AF16}" , "AppDataLow")
$KnownFolders.Add("{A305CE99-F527-492B-8B1A-7E76FA98D6E4}" , "AppUpdates")
$KnownFolders.Add("{9E52AB10-F80D-49DF-ACB8-4330F5687855}" , "CDBurning")
$KnownFolders.Add("{DF7266AC-9274-4867-8D55-3BD661DE872D}" , "ChangeRemovePrograms")
$KnownFolders.Add("{D0384E7D-BAC3-4797-8F14-CBA229B392B5}" , "CommonAdminTools")
$KnownFolders.Add("{C1BAE2D0-10DF-4334-BEDD-7AA20B227A9D}" , "CommonOEMLinks")
$KnownFolders.Add("{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8}" , "CommonPrograms")
@IAmStoxe
IAmStoxe / add_port.sh
Last active October 12, 2023 17:29
Add Inbound IPv4 Ports to iptables Configuration for Oracle Ubuntu (OCI)
#!/bin/bash
# Script to add inbound IPv4 ports to the iptables configuration.
# Ensure the script is being run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
@IAmStoxe
IAmStoxe / falcon180b_dl.sh
Last active September 7, 2023 16:05
This script helps you to automatically download and assemble the split files of the Falcon 180B Chat GGUF dataset from Hugging Face.
#!/bin/bash
# Create a file with the list of URLs to download
echo -e "#\nhttps://huggingface.co/TheBloke/Falcon-180B-Chat-GGUF/resolve/main/falcon-180b-chat.Q4_K_M.gguf-split-a\n out=falcon-180b-chat.Q4_K_M.gguf-split-a\nhttps://huggingface.co/TheBloke/Falcon-180B-Chat-GGUF/resolve/main/falcon-180b-chat.Q4_K_M.gguf-split-b\n out=falcon-180b-chat.Q4_K_M.gguf-split-b\nhttps://huggingface.co/TheBloke/Falcon-180B-Chat-GGUF/resolve/main/falcon-180b-chat.Q4_K_M.gguf-split-c\n out=falcon-180b-chat.Q4_K_M.gguf-split-c" > ~/urls.txt
# Use aria2 to download files in parallel
aria2c -x 6 -i ~/urls.txt -d ~
# Concatenate the downloaded files
cat ~/falcon-180b-chat.Q4_K_M.gguf-split-a ~/falcon-180b-chat.Q4_K_M.gguf-split-b ~/falcon-180b-chat.Q4_K_M.gguf-split-c > ~/falcon-180b-chat.Q4_K_M.gguf
@IAmStoxe
IAmStoxe / Get-GPLink.ps1
Created February 13, 2023 18:42 — forked from jdhitsolutions/Get-GPLink.ps1
A PowerShell function to list Group Policy links
@IAmStoxe
IAmStoxe / ProcessHollow.cs
Created December 30, 2022 19:34 — forked from affix/ProcessHollow.cs
Process Hollowing Technique using C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Text;
using System.Threading.Tasks;
namespace hollow
{
<#
To easily find out why a sign-in failed for a specific user,
you can use the Where-Object cmdlet to filter the sign-in logs
by the user's display name, and then output information
about the failed sign-in attempt.
№ Here's an example of how you might use the Where-Object cmdlet to find out
why a sign-in failed for a specific user:
#>
function NSLookup(type, domain) {
if (typeof type == 'undefined') {
throw new Error('Missing parameter 1 dns type');
}
if (typeof domain == 'undefined') {
throw new Error('Missing parameter 2 domain name');
}
@IAmStoxe
IAmStoxe / gist:7a398f8e8e4adcc62d95bc1e98daa249
Created September 7, 2021 04:55
Delete Azure resource groups asynchronously in bulk
az group list | convertfrom-json | select -expand name | ?{$_ -like "*-rg-*"}| %{az group delete --name=$_ -y & }
@IAmStoxe
IAmStoxe / Ignore-SSLCerts.ps1
Created July 20, 2021 19:07
Ignore Invalid SSL Certificates In PowerShell
<# Ignore SSL Cert Hack #>
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}