Pentest Tips
  • ABOUT
  • Information Shares
  • CTF
    • Stego
    • Memory
  • Blue Team
    • Tools/Resources
    • One Liners
    • Threat Hunting
    • Scripts
    • Intrusion
  • Web
    • Resources
    • General Web
    • Subdomain Discovery
    • Content Discovery
    • MYSQL
    • Burpsuite
  • Network Exploitation
    • Resources
    • Kerberos
    • Network Based
    • Phishing
    • Metasploit
    • Weaponization
    • Password Cracking
    • Shell Upgrades
    • Linux PrivEsc
    • Windows PrivEsc
    • Windows Persistence
    • Exfiltration
  • Windows Internals
    • Kernal
  • Recon
    • Nmap
    • OSINT
    • SMB Enumeration
    • LDAP
    • Physical
  • Malware
    • Obfuscation
  • Scripting
    • Bash Basics
    • Powershell Basics
  • Cloud
    • AWS
  • Game Hacking
    • Resources
Powered by GitBook
On this page
  • Change All Users Passwords:
  • Disable all Users With Shell Access:
  • Get the name:pid of all active TCP/UDP connections:
  • Get all users with shell access:
  • Gets a whole lot of info:
Edit on GitHub
  1. Blue Team

Scripts

PreviousThreat HuntingNextIntrusion

Last updated 3 years ago

All these scripts are hand written by me and can be found on my github:

Change All Users Passwords:

#!/bin/bash

newPassword=$1
mapfile -t usersArray < <(awk -F":" '((($7=="/bin/bash")||($7=="/bin/sh"))&&($1!="root")){print $1}' /etc/passwd)

# shellcheck disable=SC2068
for elm in ${usersArray[@]};
do
	echo "Changed Password for $elm to $newPassword"
	skill -kill -u $elm
	killall -u $elm
	echo -e $newPassword'\n'$newPassword'\n' | passwd $elm;
done

Disable all Users With Shell Access:

#!/bin/bash

currentuser=$(whoami)
mapfile -t usersArray < <(awk -v curuser="$currentuser" -F":" '((($7=="/bin/bash")||($7=="/bin/sh"))&&(($1!="root")&&($1!=curuser))){print $1}' /etc/passwd)
echo "Found Users: " "${usersArray[@]}"

# shellcheck disable=SC2068
for elm in ${usersArray[@]};
do
	echo "Disabling: " "$elm"
	usermod -s /sbin/nologon $elm
	killall -u $elm
	skill -kill -u $elm
done

Get the name:pid of all active TCP/UDP connections:

#!/bin/bash

mapfile -t usersArray < <(ss -tulpn | awk -F"users:" '{print $2}' | awk -F"\"" '{print $2}'| awk '!seen[$0]++')

# shellcheck disable=SC2068
for elm in ${usersArray[@]};
do
	pid=$(ss -tulpn | awk -F"\"$elm\"" '{print $2}' | awk -F"," '{print $2}' | awk -F"=" '{print $2}' | awk '!seen[$0]++')
	echo $pid:$elm
done

Get all users with shell access:

#!/bin/bash

mapfile -t usersArray < <(awk -F":" '($7=="/bin/bash"||$7=="/bin/sh"||$7=="/usr/bin/zsh"){print $1}' /etc/passwd)

echo "${usersArray[@]}"

Gets a whole lot of info:

#!/bin/bash

echo "RUNNING PROCESSES:"
echo "--------------"
ps -aux
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"

echo "RUNNING SERVICES:"
echo "--------------"
systemctl list-units --type=service --state=running
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"

echo "CRONTAB:"
echo "--------------"
crontab -l
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"

echo "ACTIVE TCP CONNECTIONS:"
echo "--------------"
ss -tulpn
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
https://github.com/F1shh-sec/BlueTeamTools/tree/main/scripts