Skip to content

Instantly share code, notes, and snippets.

@SCP002
SCP002 / elevate.py
Created September 29, 2025 17:45
Python: Windows privilege elevation utility
"""
Windows Privilege Elevation Utility
This script provides functions to check and elevate process privileges on Windows systems,
ranging from standard user to administrator, SYSTEM, and TrustedInstaller levels. It uses
Windows APIs to trigger UAC prompts and impersonate higher-privilege tokens.
Tested with python 3.13.7
Dependencies:
@SCP002
SCP002 / main.py
Last active October 3, 2025 08:19
Python: Interract with PowerShell in a python-friendly way
import powershell
def main() -> None:
with powershell.PowerShell() as pwsh:
proc = pwsh.execute_command("Get-Process -Name explorer")
id = pwsh.get_str_property(proc, "Id")
print(f"Explorer process ID: {id}")
@SCP002
SCP002 / main.py
Last active October 3, 2025 08:15
Python: Process runner utility for Windows with pseudoterminal support
import process
def main() -> None:
process.start_process(
"python",
["--version"],
raise_on_exitcode=True,
)
@SCP002
SCP002 / main.py
Last active October 3, 2025 08:18
Python: SFTP server with authentication and access restrictions
import asyncio
import sftp
async def main() -> None:
ssh_port = 22
root_dir = r"C:/"
username = "admin"
password = "mypassword"
@SCP002
SCP002 / README.md
Last active November 25, 2024 21:36
Linux: Create a container with GUI, graphics card and audio support using LXC

Configuring LXC (LXD / Incus) container with GUI, graphics card and audio support

Install LXD

sudo snap install lxd

Create network

@SCP002
SCP002 / build.sh
Last active March 17, 2025 17:11
Golang: Shell script to build your project to each OS / Architecture specified.
#!/bin/bash
# Tested with go 1.22.5
project_name="my_project" # Change to your project name
main_file="${project_name}.go" # Or main.go, depends on your project structure
build_path="./build"
# Add values to your liking from "go tool dist list" command
# or https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
@SCP002
SCP002 / minecraft-server-docker-howto.md
Last active July 27, 2024 12:03
Minecraft: Run fabric server with mods in docker container.

Create minecraft/docker-compose.yml:

services:
  minecraft:
    image: itzg/minecraft-server
    container_name: minecraft
    environment:
      TYPE: FABRIC
 SERVER_NAME: Dungeon
@SCP002
SCP002 / process_new_console_example.rs
Created November 29, 2023 18:48
Rust: Start windows process in new console using CREATE_NEW_CONSOLE creation flag.
// Add to your Cargo.toml:
// [dependencies]
// subprocess = { version = "0.2.10", git = "https://github.com/SCP002/rust-subprocess.git" }
use subprocess::Exec;
fn main() {
let exit_status = Exec::cmd("my-executable-name")
.arg("arg1")
.creation_flags(0x00000010) // CREATE_NEW_CONSOLE
@SCP002
SCP002 / setup.sh
Created July 18, 2023 02:08
Example of running two Cesbo Astra instances on two different ports as systemctl services.
# write systemd config for the first instance
sudo tee /lib/systemd/system/astra-8000.service > /dev/null << ENDSEQ
[Unit]
Description=Astra 8000 service (%N)
After=network-online.target
StartLimitBurst=5
StartLimitIntervalSec=10
[Service]
Type=simple
@SCP002
SCP002 / err.go
Last active December 1, 2023 19:56
Golang: Run both HTTP and HTTPS server with dummy TLS certificates for testing. Network error classifier included.
package main
import (
"errors"
"net"
"net/url"
"syscall"
)
// ErrType represents network error type