Hi, these are the notes I took while watching the “Modern Pentest Tricks For Faster, Wider, Greater Engagements” talk given by Thomas Debize on both Area 41 & HITB 2018 conferences.
With third-party platforms doing it for you, sometimes for free: Shodan, ZoomEye (the chinese Shodan, less restriction free, good data quality), Scans.io, Censys.io
Extracting the results of a tool output on multiple targets
Launching the same bruteforce on multiple targets
Parallel execution is crucial to scale on wide scopes
GNU Parallel is a Perl script to parallelize any command and maximize I/O & CPU usage
Useful options:
| — | — |
| --progress | a percentage of done/to be done |
| --bar | a nice progress bar |
| --joblog | a log of executed tasks, allows resuming |
| -- resume | resume to your current execution status |
| --sshlogin | distribute the tasks on remote computers through SSH |
Dig with GNU Parallel (cheap method) vs Gobuster (proper & optimized tool) #
Gobuster: Directory/file & DNS busting tool written in Go
$ git clone https://github.com/OJ/gobuster.git && cd gobuster
$ time go run main.go -u google.com -w ~/subdomains.txt -m dns -q -o google.com_subdomains_by_gobuster.txt
=> ~22s
Dig: Native tool for DNS enumeration
$time parallel -a ~/subdomains.txt "dig +noall +answer {}.google.com | tee -a google.com_subdomains_by_parallel.txt"
=> ~27s
Dig with GNU Parallel is almost as perfomant as Gobuster
Very useful when you cannot install any tool on your attack machine (for example if provided by the client). You only have to install GNU Parallels
High-level scripting languages for easier static & dynamic analysis: Jython & Frida #
Pentest sometimes involves reversing “custom-wtf” obfuscation or encryption
Usually during Android applications & Java thick clients engagements
Why use a high-level scripting language for instrumentation?
If you don’t want to go down the rabbit hole to figure out how it works
If you can’t replicate/rip the code into your favourite language
E.g.: Oracle WebLogic Server encrypts local passwords with a cryptosystem that’s not implemented in any Python module
Use Jython for static analysis of Android & Java apps
Writing Java code in Python… that can use Java classes… and Python libraries in the same snippet
Use Frida for everything else
Writing Python or JS or QML or Swift or .NET… injecting C++ scripted in JS (Google v8)… to instrument ASM, Objective-C or Dalvik… on Windows, Mac, Linux, Android, iOS
Pentest sometimes involves the need to have compiled version of tools
Because:
The target you are onto does not have the proper execution environment (dependencies, interpreter) & you can’t install it (no root, no outgoing connection, laziness…)
You can’t just have a proper reverse shell or Meterpreter
You need to evade antivirus
Compile Python tools with PyInstall
PyInstaller bundles a Python script with a Python interpreter
This dependency is already satistied if you have Visual Studio installed
You can also cross-compile for Windows from Linux with wine (Tutorial)
Useful options:
--onefile: creates a standalone executable file which is a self-extracting zip payload
--onedir: creates a single directory with everything inside if you don’t want a standalone executable file, as large standalones (> 18 MB) take time to unzip before execution
--key <key>: a specific key to encrypt the zip payload, of course included in the executable (Tutorial)
Encrypt the payload & include the key in the executable (no obfuscation used), useful for anti-virus bypass
--icon <icon_file>: for visual fanciness
Examples of Python scripts compiled with PyInstaller #
High-value utilities in the Impacket tool suite: mimikatz.exe, ntlmrelay.exe, psexec.exe, samrdump.exe, secretsdump.exe, smbexec.exe, smbrelay.exe, ticketer.exe, wmiexec.exe, wmipersist.exe, wmiquery.exe
Real-life tricks
Impacket tools are gaining popularity and getting flagged by AV. Just use the --key option to bypass them!
If you cannot grab the Ntds database (Ntds.dit) of a domain because of the network connection or not enough space on your computer, just take the secretsdump.exe executable & put it on the target or on the domain controller wherever you want & you’ll be able to process the Ntds file remotely & grab password hashes from it