THC Tips, Tricks, Hacks & Cheat Sheet

repository·master·Indexed 26 days ago

https://github.com/hackerschoice/thc-tips-tricks-hacks-cheat-sheet

A curated collection of technical tips and hacks for Linux/Bash, SSH, Networking, Data Exfiltration, and Reverse Shells. Focused on security research and penetration testing, it includes techniques for process and connection hiding, SSH multiplexing, pivoting via ProxyJump, nmap discovery, and establishing SSL/TCP tunnels.

Tokens
17.4K
Snippets
64
Records
95
Agent score
37%

What's inside thc-tips-tricks-hacks-cheat-sheet

  1. Transfer files using WebDAV

    master

    Use WebDAV to manage files remotely, including directory creation and parallel uploads.

    Setup (Receiver):

    1. Start a Cloudflare Tunnel: cloudflared tunnel --url localhost:8080 &.
    2. Start WebDAV: wsgidav --port=8080 --root=. --auth=anonymous.

    Operations (Sender):

    • Upload file: curl -T file.dat <URL>
    • Create directory: curl -X MKCOL <URL>/sources
    • Parallel upload: find . -name '*.c' | xargs -P10 -I{} curl -T{} <URL>/sources/{}
  2. Use SSH SOCKS4/5 dynamic forwarding

    master

    Use OpenSSH dynamic forwarding to turn your SSH connection into a SOCKS proxy.

    Local SOCKS Proxy

    Tunnel all your local browser traffic through the remote server: ssh -D 1080 user@server.org (Configure browser to use 127.0.0.1:1080).

    Remote SOCKS Proxy

    Allow others to use your computer as a SOCKS proxy to access your local network: ssh -g -R 1080 user@server.org

  3. Find public IP and geolocation info

    master

    Commands to identify your public IP, ASN, and geolocation.

    • Public IP: curl ifconfig.me or curl -s wtfismyip.com/json | jq
    • Geolocation: curl https://ipinfo.io/8.8.8.8 | jq
    • ASN Lookup: Use the asn() function to query whois.cymru.com via netcat.
    curl -s wtfismyip.com/json | jq
    curl ifconfig.me
    dig +short myip.opendns.com @resolver1.opendns.com
    host myip.opendns.com resolver1.opendns.com
    
    curl https://ipinfo.io/8.8.8.8 | jq
    curl http://ip-api.com/8.8.8.8
    
    asn() {
      [[ -n $1 ]] && { echo -e "begin\nverbose\n${1}\nend"|netcat whois.cymru.com 43| tail -n +2; return; }
      (echo -e 'begin\nverbose';cat -;echo end)|netcat whois.cymru.com 43|tail -n +2
    }
    asn 1.1.1.1
  4. Encode files to ASCII for manual transfer

    master

    When a target has no internet access, convert binary files to ASCII text (base64) to allow for copy-pasting. You can use base64, uuencode, openssl, or xxd to perform the encoding.

    ## base64 encode/decode
    ```shell
    base64 -w0 </etc/issue.net 
    base64 -d >issue.net-COPY

    uuencode/uudecode

    uuencode /etc/issue.net issue.net-COPY
    uudecode

    Openssl encode/decode

    openssl base64 </etc/issue.net 
    openssl base64 -d >issue.net-COPY

    xxd encode/decode

    xxd -p </etc/issue.net
    xxd -p -r >issue.net-COPY
  5. Bounce traffic with iptables

    master

    Use a custom iptables setup to bounce traffic through a host/router without a userland proxy.

    1. Initialize: Run bounceinit to enable IP forwarding and set up mangle/nat rules. You can restrict bouncing to specific source IPs by calling bounceinit "<source_ip>/".
    2. Set Forwards: Use the bounce function to map a local port to a destination. bounce <local_port> <destination_ip> <destination_port>
    bounceinit() {
        echo 1 >/proc/sys/net/ipv4/ip_forward
        echo 1 >/proc/sys/net/ipv4/conf/all/route_localnet
        [ $# -le 0 ] && set -- "0.0.0.0/0"
        while [ $# -gt 0 ]; do
            iptables -t mangle -I PREROUTING -s "${1}" -p tcp -m addrtype --dst-type LOCAL -m conntrack ! --ctstate ESTABLISHED -j MARK --set-mark 1188 
            shift 1
        done
        iptables -t mangle -D PREROUTING -j CONNMARK --restore-mark >/dev/null 2>/dev/null
        iptables -t mangle -I PREROUTING -j CONNMARK --restore-mark
        iptables -I FORWARD -m mark --mark 1188 -j ACCEPT
        iptables -t nat -I POSTROUTING -m mark --mark 1188 -j MASQUERADE
        iptables -t nat -I POSTROUTING -j CONNMARK --save-mark
    }
    bounce() {
        iptables -t nat -A PREROUTING -p tcp --dport "${1:?}" -m mark --mark 1188 -j DNAT --to ${2:?}:${3:?}
    }
    bounceinit                             # Allow EVERY IP to bounce
    # bounceinit "1.2.3.4/16" "6.6.0.0/16" # Only allow these SOURCE IP's to bounce
    
    bounce 31337 144.76.220.20 22 # Bounce 31337 to segfault's ssh port.
    bounce 31338 127.0.0.1 8080   # Bounce 31338 to the server's 8080 (localhost)
    bounce 53 213.171.212.212 443 # Bounce 53 to gsrn-relay on port 443