Skip to content

Instantly share code, notes, and snippets.

@raresteak
raresteak / uptime.ps1
Created November 12, 2024 14:48
Uptime command similiar to Unix uptime
# Similiar to unix command uptime
$bootTime = Get-CimInstance -ClassName win32_operatingsystem | Select-Object -ExpandProperty LastBootUpTime
$currentTime = Get-Date
$uptime = $currentTime - $bootTime
$days = $uptime.Days
$hours = $uptime.Hours
$minutes = $uptime.Minutes
$users = (quser).Count-1
if ( $users -lt 0 ) {
$users = 0
@raresteak
raresteak / Enable-PSWA.ps1
Last active November 12, 2024 13:41
Install and configure PowerShell Web Access
install-windowsfeature -name WindowsPowerShellWebAccess -computername server1 -includemanagementtools -restart
install-pswawebapplication -usetestcertificate
add-pswaauthorizationrule -username * -computername * -configurationname *
set-item wsman:\localhost\Client\TrustedHosts -Value 'localhost,server1,10.10.10.1' -force
enable-psremoting -force
# Goto URL https://localhost/pswa
# Login username format
# localhost\theuser
@raresteak
raresteak / myservice.service
Last active September 24, 2024 12:51
Example systemd service file
# myservice.service
[Unit]
Description=Python HTTP server /tmp port 4848
Documentation=man systemd.service
After=network.target #myservice.service requires networking be up first
[Service]
User=sam
ExecStartPre=sh -c 'echo TRUE > /tmp/TRUE'#not required, just an example
ExecStart=/usr/bin/python3 -m http.server -d /tmp 4848
@raresteak
raresteak / windows-ip-cmdline.md
Created August 22, 2024 12:01
Manually setting IP information in Windows

Get name of adapter

netsh interface ipv4 show config

Set static IP

Change name= to name of interface found above

netsh interface ipv4 set address name=Ethernet static 10.10.10.10 255.0.0.0 [optional IP of default gateway]
netsh interface ipv4 show config
@raresteak
raresteak / bluetooth.md
Last active August 12, 2024 12:56
Bluetooth Classic at Linux command line

List devices

hciconfig
hciconfig hci0 version

Bring interface up | down

sudo hciconfig hci0 up
@raresteak
raresteak / CVE-2013-3900.yml
Created June 27, 2024 13:35
Ansible playbook to remedidate CVE-2013-3900
---
# Remediate WinVerifyTrust Signature Validation Vulnerability
# URL https://msrc.microsoft.com/update-guide/vulnerability/CVE-2013-3900
- hosts: win
tasks:
- name: Create registry path Wintrust
ansible.windows.win_regedit:
path: HKLM:\Software\Microsoft\Cryptography\Wintrust\
- name: Create registry path Config
@raresteak
raresteak / smb.conf
Last active June 18, 2024 13:57
Simple Samba configuration with Guest/Anonymous share access
# smb.conf
# Fix seLinux perms
# semanage fcontext -a -t samba_share_t '/etc/samba/smb.conf'
# restorecon -v '/etc/samba/smb.conf'
[global]
workgroup = SAMBA
server role = standalone server
restrict anonymous = 0
guest account = ftp # map guest access to a low privileged user
@raresteak
raresteak / grep.py
Created August 28, 2023 01:12
Mimic nix grep with Python3
import re
import argparse
parser = argparse.ArgumentParser(description='Mimic Linux grep command for Python')
parser.add_argument('pattern', type=str, help='The pattern to search for')
parser.add_argument('file', type=str, help='The file to search in')
parser.add_argument('-i', '--ignore-case', action='store_true', help='Perform case-insensitive search')
args = parser.parse_args()
@raresteak
raresteak / cs.txt
Created August 18, 2023 13:15
CyberChef Recipe for two base64 decodes with xor bit manipulation
From_Base64('A-Za-z0-9+/=',true,false)
Decode_text('UTF-16LE (1200)')
Regular_expression('User defined','[a-zA-Z0-9/+=]{30,}',true,true,false,false,false,false,'List matches')
From_Base64('A-Za-z0-9+/=',true,false)
Gunzip()
Regular_expression('User defined','[a-zA-Z0-9/+=]{30,}',true,true,false,false,false,false,'List matches')
From_Base64('A-Za-z0-9+/=',true,false)
XOR({'option':'Decimal','string':'35'},'Standard',false)
@raresteak
raresteak / tree.py
Last active August 17, 2023 15:21
Python3 implementation of Unix tree command. Runs on Windows and Nix
import os
# mimic Unix tree command in python
# runs on Windows and Nix
# run from current directory for tree output
def tree(cwd):
print(f"+ {cwd}")
for root, dirs, files in os.walk(cwd):
level = root.replace(cwd, '').count(os.sep)
indent = ' ' * 4 * (level)
print(f"{indent}+ {os.path.basename(root)}/")