# IPsec IKE | 500, 4500

*

```bash
## ------------------| Basic scan
sudo ike-scan -M $IP

## ------------------| Aggressive scan
sudo ike-scan -A -M $IP

## ------------------| Custom Transform Enumeration
# Manually define encryption, hash, auth, and group (e.g., AES-256, SHA1, PSK, DH Group 2)
sudo ike-scan -M --trans=7/256,2,1,2 $IP

## ------------------| Username Enumeration (Cisco/Nortel)
# Some gateways reveal if a group ID/username is valid in Aggressive Mode
sudo ike-scan -A -M --id=vpnuser $IP

## ------------------| PSK Hash Capture
sudo ike-scan -A -M --pskcrack=psk_hash.txt $IP
sudo ike-scan -A -P $IP

## ------------------| PSK Cracking (Dictionary Attack)
psk-crack -d /usr/share/wordlists/rockyou.txt psk_hash.txt
hashcat psk_hash.txt /usr/share/wordlists/rockyou.txt

## ------------------| PSK Cracking (Brute Force)
psk-crack -b 5 psk_hash.txt

## ------------------| NAT-T (Port 4500) Scanning
# Scans for IKE on the NAT Traversal port
sudo ike-scan -M --port=4500 $IP
```

* IPsec Tunneling/Transport

```bash
## ------------------| Install StrongsWan
apt-get install strongswan

## ------------------| Edit the /etc/ipsec.secrets (strongSwan IPsec secrets) file
<AttackersIP> %any : PSK "v+NkxY9LL..<ReplaceThiskey>"

## ------------------| Edit the /etc/ipsec.conf file
conn ConfigNameHere
    type=transport
    keyexchange=<ReplaceIKEVersion>
    authby=psk
    right=<AttackerIP>
    rightprotoport=tcp # if you want tcp,if not remove this
    leftprotoport=tcp # if you want tcp,if not remove this
    esp=3des-sha1 # we can get this from ike-scan -M AttackerIP | grep 'SA' | awk -F= '{print $3}'   
    ike=3des-sha1-modp1024 #we can get this from ike-scan -M AttackerIP | grep 'SA' | awk -F= '{print $5}'
    auto=start

## ------------------| Start service
ipsec start --nofork
```

* [Troubleshooting IPsec VPNs](https://docs.netgate.com/pfsense/en/latest/troubleshooting/ipsec.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.h4rithd.com/udp/500-4500-ipsec-ike.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
