Skip to content

Instantly share code, notes, and snippets.

View scmanjarrez's full-sized avatar
🧠
hungry mind

Sergio C scmanjarrez

🧠
hungry mind
  • Spanish National Research Council (CSIC)
  • Madrid
View GitHub Profile
@scmanjarrez
scmanjarrez / port.py
Created March 14, 2025 13:10
Small script to discover output ports open in a fw
import subprocess
from concurrent.futures import ThreadPoolExecutor
from concurrent.futures import wait
def tcp_scan(host):
ports = []
def check_port(port):
proc = subprocess.run(
@scmanjarrez
scmanjarrez / domain.py
Created February 21, 2025 22:11
Small patch for bloodhound-python ce to test resolved IP before choosing blindly
import ldap3
# Convert the hostname to an IP, this prevents ldap3 from doing it
# which doesn't use our custom nameservers
q = self.ad.dnsresolver.query(self.hostname, tcp=self.ad.dns_tcp)
for r in q:
try:
logging.info('Testing resolved hostname connectivity %s' % r.address)
_tmp_serv = ldap3.Server(r.address, connect_timeout=5)
_conn = ldap3.Connection(_tmp_serv)
@scmanjarrez
scmanjarrez / kali_as_router.sh
Last active September 2, 2024 21:31
Script to convert kali into a router for HTB.
#!/bin/env bash
# Route openvpn traffic. Thanks @ippsec!
# 192.168.15.0/24 is the subnet shared betwen my kali and windows box, modify accordingly.
sudo iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
sudo iptables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -t nat -A POSTROUTING -s 192.168.15.0/24 -o tun0 -j MASQUERADE
# windows
# 192.168.15.134 is the IP of my kali box
@scmanjarrez
scmanjarrez / nmap.sh
Last active August 20, 2024 19:15
Small to script do a first -sS scan and then a version scan based on the results
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Missing IP. Usage: $0 <IP>"
exit
fi
out=$(sudo nmap -sS -Pn -n -T4 --min-parallelism 1000 --min-rate 5000 -p- $1)
syn=$(echo "$out" | awk '/PORT.*STATE.*SERVICE/,/Read data files/' | grep -v 'Read data files')
echo -e "Syn scan:\n$syn"
@scmanjarrez
scmanjarrez / kali_dark_xfce4.theme
Last active August 20, 2024 19:13
Kali-dark theme ported from qterminal
[Scheme]
Name=Kali
ColorForeground=#FFFFFF
ColorBackground=#23252E
ColorCursor=#FFFFFF # or any other preferred color
TabActivityColor=#EC0101 # you can choose a bright color
ColorPalette=#1F2229;#D41919;#5EBDAB;#FEA44C;#367BF0;#9755B3;#49AEE6;#E6E6E6;#198388;#EC0101;#47D4B9;#FF8A18;#277FFF;#962AC3;#05A1F7;#FFFFFF
ColorBold=#FFFFFF
ColorBoldUseDefault=FALSE
@scmanjarrez
scmanjarrez / kali_dark.yaml
Created June 16, 2024 19:13
Kali-dark theme ported from qterminal to Alacritty (yaml)
# 0x From the Kali-dark Qterminal color palette
colors:
# 0x Default colors
primary:
background: '0x23252e' # Converted from Background Color 35,37,46
foreground: '0xffffff' # Converted from Foreground Color 255,255,255
# 0x Colors the cursor will use if `custom_cursor_colors` is true
cursor:
text: '0xbbbbbb' # Assuming the same as given
@scmanjarrez
scmanjarrez / nmapBasic2Full.sh
Last active March 28, 2024 16:26
Small script to generate a list of ports to be scanned from the port detected by nmap
#!/bin/bash
declare -a tcp=()
declare -a udp=()
while IFS= read -r line; do
port=$(echo $line | awk '{print $4}')
[[ "$port" =~ "tcp" ]] && tcp+=("${port%%/*}") || udp+=("${port%%/*}")
done < "${1:-/dev/stdin}"
IFS=,
echo -n "-sS -p "
echo "${tcp[*]}"
@scmanjarrez
scmanjarrez / HowToOTGFast.md
Created February 1, 2024 13:36 — forked from gbaman/HowToOTGFast.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@scmanjarrez
scmanjarrez / install.sh
Created January 25, 2024 10:19
Install microsoft propietary fonts in linux (calibri, cambria, corbel, etc)
#!/bin/bash
TMPDIR=/tmp/msfonts
mkdir -p $TMPDIR
cd $TMPDIR
wget https://sourceforge.net/projects/mscorefonts2/files/cabs/PowerPointViewer.exe
cabextract -L -F ppviewer.cab -d . PowerPointViewer.exe
cabextract -L -F '*.TT[FC]' -d . ppviewer.cab
@scmanjarrez
scmanjarrez / fix.md
Last active February 3, 2024 11:24
Backup on how to ignore waiting for interfaces with optional: true in netplan (bug)