1080 - Pentesting Socks

1080 - Pentesting Socks

Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Informazioni di base

SOCKS è un protocollo utilizzato per il trasferimento di dati tra un client e un server attraverso un proxy. La quinta versione, SOCKS5, aggiunge una funzionalità di autenticazione opzionale, consentendo solo agli utenti autorizzati di accedere al server. Gestisce principalmente il proxy delle connessioni TCP e l'inoltro dei pacchetti UDP, operando al livello di sessione (Layer 5) del modello OSI.

Porta predefinita: 1080

Enumerazione

Controllo di autenticazione

nmap -p 1080 <ip> --script socks-auth-info

Brute Force

Utilizzo di base

La tecnica di Brute Force consiste nel tentare tutte le possibili combinazioni di password fino a trovare quella corretta. Questo metodo può essere utilizzato per violare la sicurezza di un sistema o di un account.

Per utilizzare il Brute Force, è necessario avere un elenco di password da provare. Questo elenco può essere creato manualmente o utilizzando strumenti appositi come wordlist o generatori di password.

Una volta ottenuto l'elenco delle password, è possibile utilizzare uno script o uno strumento di Brute Force per automatizzare il processo di prova delle password. Lo script o lo strumento proverà una password alla volta fino a trovare quella corretta.

È importante notare che il Brute Force può richiedere molto tempo, specialmente se l'elenco delle password è lungo o se il sistema ha delle misure di sicurezza che limitano il numero di tentativi consentiti. Inoltre, l'utilizzo del Brute Force può essere considerato illegale e può comportare conseguenze legali.

Esempio di utilizzo

Di seguito è riportato un esempio di utilizzo del Brute Force con uno script Python:

import requests

url = "http://example.com/login"
username = "admin"
wordlist = ["password1", "password2", "password3"]

for password in wordlist:
    data = {"username": username, "password": password}
    response = requests.post(url, data=data)
    
    if response.status_code == 200:
        print("Password trovata:", password)
        break

In questo esempio, lo script prova una password alla volta dal wordlist fornito. Se la password è corretta, lo script stampa "Password trovata" e termina l'esecuzione.

nmap --script socks-brute -p 1080 <ip>

Utilizzo avanzato

Socks Proxy

A Socks proxy is a protocol that allows a client to establish a connection through a firewall by using a proxy server. It can be used to bypass network restrictions and access resources that are otherwise blocked.

To use a Socks proxy, you need to configure your client to connect to the proxy server and specify the desired destination address and port. The proxy server then establishes a connection on behalf of the client and forwards the data between the client and the destination.

Proxychains

Proxychains is a tool that allows you to run any program through a Socks or HTTP proxy. It intercepts the network traffic generated by the program and redirects it through the specified proxy server.

To use Proxychains, you need to configure the proxy server settings in the proxychains.conf file. You can specify multiple proxy servers and set different proxy types for each server.

Once configured, you can run any program with Proxychains by prefixing the command with proxychains. For example, to run nmap through a Socks proxy, you would use the command proxychains nmap <options>.

Proxychains-ng

Proxychains-ng is an updated version of Proxychains that supports multiple proxy types, including Socks4, Socks5, and HTTP. It also includes additional features such as DNS resolution through the proxy and support for dynamic library injection.

To use Proxychains-ng, you need to configure the proxy server settings in the proxychains.conf file, similar to Proxychains. You can specify multiple proxy servers and set different proxy types for each server.

Once configured, you can run any program with Proxychains-ng by prefixing the command with proxychains4 or proxychains5, depending on the desired proxy type. For example, to run nmap through a Socks5 proxy, you would use the command proxychains5 nmap <options>.

nmap  --script socks-brute --script-args userdb=users.txt,passdb=rockyou.txt,unpwdb.timelimit=30m -p 1080 <ip>

Pentesting SOCKS

Introduction

SOCKS (Socket Secure) is a protocol that allows a client to establish a connection through a proxy server. It is commonly used for bypassing network restrictions and anonymizing internet traffic. In this section, we will explore various techniques for pentesting SOCKS servers.

Enumeration

Version Detection

To determine the version of the SOCKS server, we can send a SOCKS5 handshake request and analyze the response. The server will reply with its supported version and authentication methods.

$ echo -ne '\x05\x01\x00' | nc -v -n -w1 <target_ip> <target_port>

User Enumeration

Some SOCKS servers may require authentication. We can attempt to enumerate valid usernames by sending a SOCKS5 handshake request with different usernames and analyzing the response.

$ echo -ne '\x05\x01\x00' | nc -v -n -w1 -p <source_port> -s <source_ip> <target_ip> <target_port>

Exploitation

Proxy Chaining

We can chain multiple SOCKS proxies together to hide our identity and bypass network restrictions. This can be achieved by configuring each proxy to use the previous proxy as its upstream SOCKS server.

$ ssh -D <local_port> -p <ssh_port> <ssh_username>@<ssh_server>

Traffic Analysis

By intercepting and analyzing the traffic between the client and the SOCKS server, we can gain valuable information such as usernames, passwords, and sensitive data. Tools like Wireshark can be used for this purpose.

Conclusion

Pentesting SOCKS servers involves enumerating the server version, enumerating valid usernames, exploiting proxy chaining, and analyzing network traffic. These techniques can help identify vulnerabilities and improve the security of SOCKS implementations.

PORT     STATE SERVICE
1080/tcp open  socks
| socks-brute:
|   Accounts
|     patrik:12345 - Valid credentials
|   Statistics
|_    Performed 1921 guesses in 6 seconds, average tps: 320

Tunneling e Port Forwarding

Utilizzo di base di proxychains

Configurare proxychains per utilizzare un proxy socks

nano /etc/proxychains4.conf

Modifica il seguente testo aggiungendo il tuo proxy:

# Pentesting SOCKS

## Introduction

SOCKS (Socket Secure) è un protocollo di rete che permette ai client di instradare le loro richieste di connessione attraverso un server proxy. Questo protocollo è utilizzato principalmente per bypassare le restrizioni di rete e garantire la privacy dell'utente.

## Pentesting SOCKS

Durante un test di penetrazione su un server SOCKS, è possibile eseguire diverse attività per identificare eventuali vulnerabilità o configurazioni errate. Alcuni dei punti chiave da considerare includono:

- **Scansione delle porte**: identificare le porte aperte sul server SOCKS per determinare quali servizi sono disponibili.
- **Verifica delle credenziali**: tentare di accedere al server SOCKS utilizzando credenziali predefinite o debolezze nelle autenticazioni.
- **Attacchi di forza bruta**: eseguire attacchi di forza bruta per cercare di indovinare le credenziali di accesso al server SOCKS.
- **Iniezione di comandi**: sfruttare eventuali vulnerabilità di iniezione di comandi per eseguire codice arbitrario sul server SOCKS.
- **Esecuzione di comandi remoti**: utilizzare il server SOCKS come punto di partenza per eseguire comandi remoti su altri sistemi nella rete.
- **Analisi del traffico**: monitorare il traffico di rete per identificare eventuali informazioni sensibili che potrebbero essere trasmesse in chiaro.

## Utilizzo di un proxy

Durante un test di penetrazione su un server SOCKS, è possibile utilizzare un proxy per nascondere la propria identità e rendere più difficile il tracciamento delle attività. Per utilizzare un proxy, è necessario configurare il proprio software di test per instradare il traffico attraverso il proxy.

Ecco un esempio di configurazione per utilizzare un proxy SOCKS:

export http_proxy=http://your-proxy-ip:your-proxy-port export https_proxy=http://your-proxy-ip:your-proxy-port


Assicurati di sostituire `your-proxy-ip` con l'indirizzo IP del tuo proxy e `your-proxy-port` con la porta corrispondente.

## Conclusioni

Il pentesting di server SOCKS è un'attività importante per identificare e risolvere eventuali vulnerabilità di sicurezza. Utilizzando le tecniche descritte in questo documento, è possibile eseguire un test completo e accurato per garantire la sicurezza del server SOCKS.

Aggiungi il tuo proxy:

export http_proxy=http://your-proxy-ip:your-proxy-port
export https_proxy=http://your-proxy-ip:your-proxy-port

Assicurati di sostituire your-proxy-ip con l'indirizzo IP del tuo proxy e your-proxy-port con la porta corrispondente.

socks5 10.10.10.10 1080

Con autenticazione

socks5 10.10.10.10 1080 username password

Ulteriori informazioni: Tunneling e Port Forwarding

Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Last updated