# 03 - Обфускация IP

Для обфускации IP-адреса придумано не мало методов, чаще всего на глаза попадается base64, но это не всегда удобно в виду того что например в cisco нет утилиты base64. Зато все компьютерные процессоры понимают двоичные\десятичные\шестнадцатеричные системы счисления, этим и воспользуемся. (автор помнит время когда HEX пролетал фильтры iptables, было смешно)

```bash
// Я написал простой BASH скрипт для конвертации IPv4 в Hex (hexadecimal)
#!/bin/bash

read -p "IP address to obfuscate (IPv4 only): " ip

if ! echo "$ip" | grep -Pq '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'; then
    echo "Invalid IP address: $ip"
    exit 1
fi

IFS='.' read -ra ipmod <<< "$ip"
first=${ipmod[0]}
hex=$(printf '%x' $first)

decimal=0
for ((i=1; i<4; i++)); do
    decimal=$((decimal + ipmod[$i] * 256 ** (3 - $i) ))
done

final="0x$hex.$decimal"

echo -e "\nYour obfuscated IP address:"
echo -e "\033[1;33m$final\033[0m"

```

Создайте файл,  скопируйте в него скрипт и дайте скрипту права на исполнение.

```bash
// Создаем файл
touch hex_ip.sh
// Копируем в него скрипт и даем права на исполнение
chmod +x hex_ip.sh
// запускаем
./hex_ip.sh
```

<figure><img src="/files/BE9sAwB2iwKTX2Nv5YX1" alt=""><figcaption><p>Пример работы скрипта</p></figcaption></figure>


---

# 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://reeves0x0.gitbook.io/linux-under-attack/scan/03-obfuskaciya-ip.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.
