pentesting 0.24.2 → 0.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,89 +1,313 @@
1
- # Forensics & Steganography Techniques
1
+ # Forensics & Steganography — Comprehensive CTF Guide
2
+
3
+ > **Cross-ref**: file-attacks.md (file operations), pwn.md (binary analysis)
4
+
5
+ ## Phase 0: File Analysis — Universal First Steps
2
6
 
3
- ## File Analysis
4
7
  ```
5
- First steps with any file:
6
- ├── file <file> → identify type
8
+ With ANY unknown file:
9
+ ├── file <file> → identify type (NEVER trust extension alone!)
7
10
  ├── strings <file> → extract readable strings
8
- ├── strings -el <file> → UTF-16 strings (Windows)
9
- ├── xxd <file> | head → hex dump
11
+ ├── strings -el <file> → UTF-16 strings (Windows executables)
12
+ ├── xxd <file> | head → hex dump first bytes (check magic bytes)
10
13
  ├── exiftool <file> → metadata (GPS, creator, timestamps, hidden fields)
11
14
  ├── binwalk <file> → embedded files/filesystems
12
15
  │ └── binwalk -e <file> → extract embedded files
13
- └── foremost <file> → file carving
16
+ ├── foremost <file> → file carving (alternative to binwalk)
17
+ └── entropy analysis:
18
+ binwalk -E <file> → high entropy = encrypted/compressed
19
+
20
+ Magic bytes quick reference:
21
+ ├── 89 50 4E 47 → PNG
22
+ ├── FF D8 FF → JPEG
23
+ ├── 47 49 46 38 → GIF
24
+ ├── 50 4B 03 04 → ZIP (also DOCX, XLSX, APK, JAR)
25
+ ├── 1F 8B → GZIP
26
+ ├── 42 5A 68 → BZIP2
27
+ ├── 7F 45 4C 46 → ELF (Linux binary)
28
+ ├── 4D 5A → PE (Windows executable)
29
+ ├── 25 50 44 46 → PDF
30
+ ├── D0 CF 11 E0 → MS Office (OLE2) — DOC, XLS, PPT
31
+ ├── 52 49 46 46 → RIFF (WAV, AVI, WebP)
32
+ └── 00 00 00 18/20 → MP4 (ftyp)
33
+
34
+ File repair:
35
+ ├── Corrupted header? → fix magic bytes manually with hex editor
36
+ ├── PNG: pngcheck -v <file> → diagnose chunk errors
37
+ │ Fix CRC: python3 script to recalculate chunk CRC
38
+ │ Fix IHDR: width/height may be wrong → brute-force dimensions
39
+ ├── ZIP: zip -FF corrupt.zip --out fixed.zip → repair archive
40
+ └── JPEG: truncated? → might still have flag in extractable data
14
41
  ```
15
42
 
16
43
  ## Steganography
44
+
17
45
  ```
18
- Image stego:
46
+ ═══════════════════════════════════════
47
+ Image Steganography:
48
+ ═══════════════════════════════════════
49
+
50
+ JPEG:
19
51
  ├── steghide extract -sf <image.jpg> -p "" → try empty password first
20
52
  ├── steghide extract -sf <image.jpg> -p <pw> → with password
21
- ├── stegseek <image.jpg> /usr/share/wordlists/rockyou.txt → brute force
22
- ├── zsteg <image.png> PNG/BMP LSB analysis
23
- ├── pngcheck <image.png> PNG structure validation
24
- ├── Compare file size to expected hidden data after IEND (PNG) or EOI (JPEG)
25
- └── CyberChef: Extract LSB, XOR, decompress
26
-
27
- Audio stego:
28
- ├── Audacity: spectrogram view (View Spectrogram)
29
- ├── sonic-visualiser: layer analysis
30
- ├── DTMF decoder: for phone tones
31
- ├── morse-decoder: for morse code audio
32
- └── Look for hidden images in spectrograms
33
-
34
- Text stego:
53
+ ├── stegseek <image.jpg> rockyou.txt → brute force steghide password
54
+ ├── stegcracker <image.jpg> rockyou.txt alternative brute force
55
+ ├── jsteg reveal <image.jpg> jsteg extraction
56
+ └── outguess -r <image.jpg> output.txt outguess extraction
57
+
58
+ PNG / BMP:
59
+ ├── zsteg <image.png> → LSB analysis (multiple channels, orders)
60
+ ├── zsteg -a <image.png> → try ALL extraction methods
61
+ ├── pngcheck -v <image.png> → PNG structure validation
62
+ ├── IDAT chunks: hidden data after IEND marker
63
+ │ python3 -c "data=open('img.png','rb').read(); print(data[data.index(b'IEND')+8:])"
64
+ ├── LSB manual extraction:
65
+ │ from PIL import Image
66
+ │ img = Image.open('img.png')
67
+ │ bits = ''.join(str(px & 1) for px in img.getdata() for _ in [px] if isinstance(px, int))
68
+ │ # or for RGB: iterate R,G,B channels separately
69
+ └── Compare two similar images:
70
+ compare <img1> <img2> diff.png (ImageMagick)
71
+ → pixel differences often reveal hidden data
72
+
73
+ GIF:
74
+ ├── Multiple frames may hide data across frames
75
+ ├── identify -verbose <file.gif> → frame count
76
+ ├── convert <file.gif> frame_%d.png → extract all frames
77
+ └── Hidden frame with very short display time
78
+
79
+ General image:
80
+ ├── StegSolve.jar → visual analysis (bit plane viewer, color channels)
81
+ ├── CyberChef: Extract LSB
82
+ ├── Compare file size to expected → hidden data appended
83
+ └── Check alpha channel (transparency) for hidden data
84
+ from PIL import Image
85
+ img = Image.open('img.png').split()[-1] # alpha channel
86
+
87
+ ═══════════════════════════════════════
88
+ Audio Steganography:
89
+ ═══════════════════════════════════════
90
+ ├── Audacity → spectrogram view (Analyze → Plot Spectrum or View → Spectrogram)
91
+ │ Hidden images/text visible in frequency domain
92
+ ├── sonic-visualiser → detailed spectrogram layers
93
+ ├── DTMF decoder → phone dial tones (multimon-ng)
94
+ ├── morse-decoder → morse code in audio
95
+ ├── wav hidden data:
96
+ │ python3 → read raw samples → LSB extraction
97
+ │ stegolsb wavsteg -r -i audio.wav -o output.txt
98
+ ├── SSTV (Slow-Scan Television):
99
+ │ qsstv or RX-SSTV → decode image from audio signal
100
+ │ Common in space/radio-themed CTFs
101
+ └── mp3stego → MP3-specific steganography
102
+
103
+ ═══════════════════════════════════════
104
+ Text / Document Steganography:
105
+ ═══════════════════════════════════════
35
106
  ├── Whitespace stego: stegsnow -C <file>
36
- ├── Zero-width characters: Unicode U+200B, U+200C, U+200D
37
- └── Line-ending manipulation: CRLF vs LF patterns
107
+ │ Tabs and spaces encode binary data at end of lines
108
+ ├── Zero-width characters: Unicode U+200B, U+200C, U+200D, U+FEFF
109
+ │ cat -v <file> | grep -o '\xE2\x80[\x8B-\x8F]' → detect
110
+ ├── Homoglyph attacks: visually identical but different Unicode chars
111
+ │ 'а' (Cyrillic) vs 'a' (Latin) → different bytes
112
+ ├── Line-ending manipulation: CRLF vs LF patterns encode bits
113
+ ├── PDF steganography:
114
+ │ ├── pdf-parser.py <file.pdf> → analyze objects
115
+ │ ├── Hidden JavaScript: /JavaScript, /JS keys
116
+ │ ├── Embedded files in PDF streams
117
+ │ ├── Invisible text (white on white)
118
+ │ └── pdftotext <file.pdf> → extract all text
119
+ └── Office documents (DOCX/XLSX):
120
+ ├── unzip <file.docx> → extract XML contents
121
+ ├── Hidden text (white font, tiny size)
122
+ ├── Document properties / custom metadata
123
+ └── Embedded OLE objects / macros
38
124
  ```
39
125
 
40
126
  ## Network Forensics (PCAP)
127
+
41
128
  ```
129
+ ═══════════════════════════════════════
42
130
  Wireshark / tshark analysis:
131
+ ═══════════════════════════════════════
43
132
  ├── tshark -r file.pcap -T fields -e data → raw data extraction
44
133
  ├── tshark -r file.pcap -Y "http" -T fields -e http.request.uri
45
134
  ├── tshark -r file.pcap -Y "ftp" -T fields -e ftp.request.arg
46
135
  ├── Follow TCP stream: tcp.stream eq <N>
47
136
  ├── Export HTTP objects: File → Export Objects → HTTP
48
- ├── DNS exfiltration: Check TXT records for base64 data
49
- ├── ICMP tunneling: Check data field in ICMP packets
50
- └── Extract files: binwalk, foremost on raw TCP stream data
137
+ └── Statistics Protocol Hierarchy see what protocols are used
51
138
 
52
- Key filters:
139
+ ═══════════════════════════════════════
140
+ Common PCAP patterns in CTF:
141
+ ═══════════════════════════════════════
142
+ ├── HTTP: credentials in POST, file downloads, flag in response
143
+ ├── FTP: RETR/STOR commands → extract transferred files
144
+ │ tshark -r file.pcap -Y "ftp-data" -T fields -e data | xxd -r -p > extracted
145
+ ├── DNS exfiltration:
146
+ │ ├── Subdomain encoding: base64/hex data in query names
147
+ │ ├── TXT records containing hidden data
148
+ │ └── tshark -r file.pcap -Y "dns.qry.type==16" -T fields -e dns.txt
149
+ ├── ICMP tunneling:
150
+ │ ├── Data hidden in ICMP payload (ping data section)
151
+ │ └── tshark -r file.pcap -Y "icmp" -T fields -e data
152
+ ├── TLS/SSL:
153
+ │ ├── If RSA private key available: edit → preferences → TLS → RSA keys
154
+ │ ├── If SSLKEYLOGFILE available: set in TLS preferences → pre-master secret log
155
+ │ └── Check for self-signed certs, weak ciphers, heartbleed
156
+ ├── USB keyboard capture:
157
+ │ ├── tshark -r file.pcap -Y "usb.transfer_type==0x01" -T fields -e usbhid.data
158
+ │ └── Map HID keycodes to characters (0x04=a, 0x05=b, ...)
159
+ ├── WiFi (802.11):
160
+ │ ├── aircrack-ng file.pcap -w rockyou.txt → crack WPA
161
+ │ └── airdecap-ng -p <password> file.pcap → decrypt traffic
162
+ └── Custom protocols:
163
+ ├── Unknown ports → analyze payload patterns manually
164
+ └── Scapy: rdpcap('file.pcap') → programmatic analysis
165
+
166
+ ═══════════════════════════════════════
167
+ Key Wireshark filters:
168
+ ═══════════════════════════════════════
53
169
  ├── http.request.method == "POST" → credential submissions
54
170
  ├── ftp.request.command == "PASS" → FTP passwords
55
171
  ├── smtp contains "AUTH" → email credentials
56
172
  ├── tcp.flags.syn == 1 → connection attempts
57
- └── frame contains "flag" → direct flag search
173
+ ├── frame contains "flag" → direct flag search
174
+ ├── !(arp || dns || mdns) → filter noise
175
+ ├── ip.addr == 10.0.0.1 → specific host traffic
176
+ └── tcp.port == 4444 → specific port (reverse shell?)
58
177
  ```
59
178
 
60
179
  ## Memory Forensics
180
+
61
181
  ```
182
+ ═══════════════════════════════════════
62
183
  Volatility 3 (preferred):
63
- ├── vol3 -f memory.dmp windows.info
184
+ ═══════════════════════════════════════
185
+ Profile detection:
186
+ ├── vol3 -f memory.dmp banners.Banners → detect OS
187
+ ├── vol3 -f memory.dmp windows.info → Windows version info
188
+ └── vol3 -f memory.dmp linux.bash → Linux bash history
189
+
190
+ Key plugins — Windows:
64
191
  ├── vol3 -f memory.dmp windows.pslist → process list
65
- ├── vol3 -f memory.dmp windows.filescan file handles
192
+ ├── vol3 -f memory.dmp windows.pstree process tree
66
193
  ├── vol3 -f memory.dmp windows.cmdline → command history
67
- ├── vol3 -f memory.dmp windows.hashdumppassword hashes
68
- ├── vol3 -f memory.dmp windows.netscan → network connections
194
+ ├── vol3 -f memory.dmp windows.filescanfile handles in memory
69
195
  ├── vol3 -f memory.dmp windows.dumpfiles → extract files
70
- └── strings memory.dmp | grep -i "flag\|password\|secret"
196
+ │ --pid <PID> filter by process
197
+ ├── vol3 -f memory.dmp windows.hashdump → SAM password hashes → crack with hashcat!
198
+ ├── vol3 -f memory.dmp windows.netscan → network connections
199
+ ├── vol3 -f memory.dmp windows.registry.hivelist → registry hives
200
+ ├── vol3 -f memory.dmp windows.registry.printkey → dump registry key
201
+ ├── vol3 -f memory.dmp windows.malfind → detect injected code
202
+ ├── vol3 -f memory.dmp windows.envars → environment variables (FLAG!)
203
+ └── vol3 -f memory.dmp windows.clipboard → clipboard content
71
204
 
205
+ Key plugins — Linux:
206
+ ├── vol3 -f memory.dmp linux.pslist → processes
207
+ ├── vol3 -f memory.dmp linux.bash → bash history (FLAG!)
208
+ ├── vol3 -f memory.dmp linux.check_syscall → rootkit detection
209
+ ├── vol3 -f memory.dmp linux.proc.Maps → memory maps
210
+ └── strings memory.dmp | grep -i "flag\|password\|secret\|key"
211
+
212
+ ═══════════════════════════════════════
72
213
  Volatility 2 (legacy):
73
- ├── vol.py -f memory.dmp imageinfo
74
- ├── vol.py -f memory.dmp --profile=<profile> pslist
75
- └── vol.py -f memory.dmp --profile=<profile> hashdump
214
+ ═══════════════════════════════════════
215
+ ├── vol.py -f memory.dmp imageinfo → determine profile
216
+ ├── vol.py -f memory.dmp --profile=<P> pslist
217
+ ├── vol.py -f memory.dmp --profile=<P> hashdump
218
+ ├── vol.py -f memory.dmp --profile=<P> mimikatz → credential extraction
219
+ ├── vol.py -f memory.dmp --profile=<P> memdump -p <PID> -D output/
220
+ └── vol.py -f memory.dmp --profile=<P> timeliner → timeline analysis
221
+
222
+ ═══════════════════════════════════════
223
+ Quick wins in memory forensics:
224
+ ═══════════════════════════════════════
225
+ ├── 1. strings + grep for flag patterns FIRST (fastest!)
226
+ ├── 2. Process list → suspicious process? → dump its memory
227
+ ├── 3. Command history (cmdline/bash) → look for flag manipulation
228
+ ├── 4. Environment variables → flag stored in env
229
+ ├── 5. Network connections → hidden services, exfiltration
230
+ ├── 6. File scan → find flag.txt, secret.txt in memory
231
+ ├── 7. Registry → passwords, recent documents, USB history
232
+ └── 8. Clipboard → copied passwords/flags
76
233
  ```
77
234
 
78
235
  ## Disk Forensics
236
+
79
237
  ```
238
+ ═══════════════════════════════════════
239
+ Disk / Filesystem Analysis:
240
+ ═══════════════════════════════════════
80
241
  ├── fdisk -l disk.img → partition layout
81
- ├── mount -o loop,ro disk.img /mnt mount read-only
242
+ ├── mmls disk.img partition table (sleuthkit)
243
+ ├── mount -o loop,ro,offset=<N> disk.img /mnt → mount partition
244
+ │ offset = start_sector × 512
82
245
  ├── autopsy → GUI forensic suite
83
- ├── sleuthkit (fls, icat) → file system analysis
84
- │ ├── fls -r disk.img → list all files (including deleted)
85
- └── icat disk.img <inode> → extract file by inode
86
- ├── photorec disk.img recover deleted files
87
- └── Check alternate data streams (Windows NTFS):
88
- └── dir /r lists ADS
246
+ ├── Sleuthkit tools:
247
+ │ ├── fls -r disk.img → list all files (including deleted!)
248
+ ├── icat disk.img <inode> → extract file by inode
249
+ ├── blkcat disk.img <block> read specific block
250
+ └── tsk_recover -e disk.img output/ recover all files
251
+ ├── photorec disk.img recover deleted files (by file signature)
252
+ ├── testdisk disk.img → partition recovery + file undelete
253
+ └── Check slack space:
254
+ blkstat disk.img <block> → check if block is allocated
255
+
256
+ ═══════════════════════════════════════
257
+ Specific filesystem features:
258
+ ═══════════════════════════════════════
259
+ ├── NTFS Alternate Data Streams:
260
+ │ ├── dir /r → list ADS on Windows
261
+ │ ├── getfattr -R -d /mnt/* → list ADS on mounted NTFS
262
+ │ └── cat /mnt/file:hidden_stream → read ADS content
263
+ ├── ext4 extended attributes:
264
+ │ ├── getfattr -d <file> → list xattrs
265
+ │ └── Journal: jls / jcat to read deleted journal entries
266
+ ├── FAT filesystem:
267
+ │ ├── No file permissions → everything is readable
268
+ │ ├── Deleted files: filename starts with 0xE5
269
+ │ └── Volume label may contain clues
270
+ └── Filesystem timeline:
271
+ fls -m "/" -r disk.img | mactime -b - > timeline.csv
272
+ → chronological view of file access/modification/creation
273
+ ```
274
+
275
+ ## Archive Analysis
276
+
277
+ ```
278
+ Archive forensics:
279
+ ├── ZIP:
280
+ │ ├── unzip -l archive.zip → list contents without extracting
281
+ │ ├── zipinfo archive.zip → detailed structure
282
+ │ ├── Known-plaintext attack: pkcrack → crack if partial content known
283
+ │ ├── fcrackzip -b -c 'aA1!' -l 1-8 archive.zip → brute force
284
+ │ ├── john --format=zip hash.txt → John the Ripper (zip2john first)
285
+ │ └── Zip slip: path traversal via ../../ in filenames
286
+ ├── RAR:
287
+ │ ├── rar2john archive.rar > hash.txt → extract hash
288
+ │ └── hashcat -m 13000 hash.txt wordlist → crack
289
+ ├── 7z:
290
+ │ └── 7z l -slt archive.7z → detailed listing
291
+ ├── tar/gz/bz2:
292
+ │ ├── tar tf archive.tar → list contents
293
+ │ └── Check timestamp/permissions for clues
294
+ └── Nested archives:
295
+ Multiple compression layers (zip inside gz inside tar)
296
+ → automate: write script to recursively extract until flag found
297
+ ```
298
+
299
+ ## Firmware Analysis
300
+
301
+ ```
302
+ ├── binwalk -e firmware.bin → extract filesystem
303
+ ├── firmware-mod-kit → unpack/repack firmware
304
+ ├── Common filesystems: squashfs, jffs2, cramfs, yaffs2
305
+ │ unsquashfs extracted/squashfs → mount squashfs
306
+ ├── Look for:
307
+ │ ├── /etc/shadow or /etc/passwd → hardcoded credentials
308
+ │ ├── /etc/config/* → configuration files with secrets
309
+ │ ├── *.key, *.pem → private keys
310
+ │ ├── Web interface source code → vulnerabilities
311
+ │ └── Compiled binaries → reverse engineer
312
+ └── Emulation: qemu or firmadyne → run firmware for dynamic analysis
89
313
  ```