Skip to content

Instantly share code, notes, and snippets.

View samaritan0's full-sized avatar

Alessandro Di Carlo samaritan0

View GitHub Profile
-- Find ssh sessions that are hiding from 'w'/'who'
SELECT * FROM (
SELECT p.pid,p.name,p.cmdline,GROUP_CONCAT(DISTINCT pof.path) AS open_files
FROM processes p
LEFT JOIN process_open_files pof ON p.pid = pof.pid
WHERE p.name = "sshd"
GROUP BY p.pid
)
WHERE cmdline LIKE "%@notty%"
OR
@ricardojba
ricardojba / windows_hardening.cmd
Last active May 4, 2024 21:26
A Windows hardening script
::##########################################################################################################################
::
:: This script can ruin your day, if you run it without fully understanding what it does, you don't know what you are doing,
::
:: OR BOTH!!!
::
:: YOU HAVE BEEN WARNED!!!!!!!!!!
::
:: This script is provided "AS IS" with no warranties, and confers no rights.
:: Feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section,
@mackwage
mackwage / windows_hardening.cmd
Last active April 28, 2024 20:54
Script to perform some hardening of Windows OS
:: Windows 10 Hardening Script
:: This is based mostly on my own personal research and testing. My objective is to secure/harden Windows 10 as much as possible while not impacting usability at all. (Think being able to run on this computer's of family members so secure them but not increase the chances of them having to call you to troubleshoot something related to it later on). References for virtually all settings can be found at the bottom. Just before the references section, you will always find several security settings commented out as they could lead to compatibility issues in common consumer setups but they're worth considering.
:: Obligatory 'views are my own'. :)
:: Thank you @jaredhaight for the Win Firewall config recommendations!
:: Thank you @ricardojba for the DLL Safe Order Search reg key!
:: Thank you @jessicaknotts for the help on testing Exploit Guard configs and checking privacy settings!
:: Best script I've found for Debloating Windows 10: https://github.com/Sycnex/Windows10Debloater
:
@ewjoachim
ewjoachim / stop-old-containers.sh
Created June 1, 2017 13:27
Stop docker containers older than 1 day old
#!/bin/bash -eux
yesterday=$(date -d yesterday +%s)
# dnsdock should not be stopped : we limit to the containers created after it
docker ps --filter since=dnsdock -q --format "{{.ID}} {{.CreatedAt}}" | while read line
do
# line looks like:
# 123456789abcdef 2017-01-01 00:00:00 +02:00 CEST
set $line
id=$1
@urjitbhatia
urjitbhatia / docker_killer.py
Last active May 13, 2019 21:16
Python script to force kill docker containers older than a certain number of minutes
#!/usr/bin/python
# Quick and dirty script to kill containers older than some number of minutes
# Kills all containers older than 60 minutes by default!
import sys
import subprocess
from sets import Set
CMD_DOCKER_CONTAINERS_WITH_AGE = 'docker ps -a --format "{{.ID}} {{.Status}}"'