VoIP and Hacking

Kojoney: un honeypot per attacchi ssh

by admin on May.24, 2009, under Hacking, Linux, Sicurezza, Tools

Kojoney è un honeypot a medio livello di interazione, scritto in Python utilizzando le librerie Twisted e Twisted Conch, in grado di simulare un SSH server.
L’ autore del progetto è lo spagnolo Jose Antonio Coret

Per poterlo eseguire è necessario soddisfare alcuni prerequisiti/dipendenze, elencati di seguito:

OpenSSL
Python

Per una installazione priva di errori è stato necessario installare l’interprete python 2.4 e creare un nuovo link symbolico /usr/bin/python che puntasse a /usr/bin/python2.4 anziché 2.6.

Altro prerequisito opzionale è l’interprete Perl.

Per l’installazione si può utilizzare lo script di nome INSTALL.sh.

# cd /tmp
# wget http://garr.dl.sourceforge.net/sourceforge/kojoney/kojoney-0.0.4.1.tar.gz
# tar -xvzf kojoney-0.0.4.1.tar.gz

Posizionandosi nella directory cojoney appena creata, come utente root:

# chmod u+x INSTALL.sh
# ./INSTALL.sh

Quello che segue è il semplice output di una corretta installazione:

Kojoney Honeypot installer.


Press enter to view the license agreement ...
NOTE: After read the license agreement press 'q' to exit.
Do you accept the ZPL, MIT and GPL license terms (yes/no) ?
yes
All licenses accepted.
******************************************
Kojoney Honeypot Installer version 0.0.3
******************************************


Step 1 - Copia dei files
[...]
Step 2 - Building delle librerie
[+] Building and installing [IP-Country]
[+] Building and installing [Geograpy-Countries]
[+] Building and installing [Zope Interfaces]
[+] Building and installing [Twisted extension]
[+] Building and installing [PyCrypto]

[Sono possibili vari warnings. Si possono ignorare]

[+] Building and installing [Twisted Conch extension]
Step 3 - Installazione della documentazione
[+] Installing man pages
Step 4 - Cambio dei permessi e creazione dei symbolic links
[+] Creating symlinks
Step 5 - Scelte finali

Quando l’ installer domanda se si desidera che il programma venga eseguito automaticamente o no al boot time e si risponde yes, lo script di startup kojoney viene copiato nella directory /etc/init.d.

Do you want to run it automatically at boot time (yes/no)?
yes

Nessun run level viene assegnato. Occorrerà quindi farlo manualmente.

Do you want to run it now (yes/no)?
yes
Starting daemon

Kojoney installation finished.

Per la disinstallazione si usa invece lo script UNINSTALL.sh, distribuito anch’esso col package.

Per avviare kojoney automaticamente in Debian/ubuntu occorre eseguire i seguenti comandi (come root)

# ln -s /etc/init.d/kojoney /etc/rc2.d
# ln -s /etc/init.d/kojoney /etc/rc3.d
# ln -s /etc/init.d/kojoney /etc/rc5.d

mentre in Redhat/Fedora:

# /sbin/chkconfig --level 345 kojoney on

Per convincere un eventuale attaccante di essere riuscito a penetrare nel sistema, cosa che in genere viene tentata tramite un attacco di tipo brute force, il programma utilizza una lista di coppie utente/password autorizzate all’accesso contenuta nel file /etc/cojoney/fake_users:

[...]
root admin
root administrator
root asdfgh
root asdfghjkl
root asus
root attack
root avatar
[...]

In tal modo l’attaccante ottiene facilmente una shell (ovviamente fasulla):

# ssh 88.89.90.91
root@88.89.90.91's password:
Wellcome to Linux webtest 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686 i386 GNU/Linux!


bash-2.0$ ls -l
drwxr-xr-x    2 root root   4096 2005-06-06 07:00 bin
drwxr-xr-x    3 root root   4096 2005-06-25 16:13 boot
drwxr-xr-x   10 root root  14320 2005-07-10 22:19 dev
drwxr-xr-x  100 root root   4096 2005-07-11 20:31 etc
drwxr-xr-x   10 root root   8192 2005-07-10 01:33 lib
drwxr-xr-x    2 root root  49152 2005-05-14 18:47 lost+found
drwxr-xr-x    3 root root   4096 2005-07-06 23:11 opt
drwxr-xr-x    3 root root   4096 2005-07-06 04:30 oracle
drwxr-xr-x    3 root root   4096 2005-07-06 01:51 personal
drwxr-xr-x    3 root root   4096 2005-07-06 22:41 pr0n
drwxr-xr-x    3 root root   4096 2005-07-06 23:44 private
drwxr-xr-x    2 root root   4096 2005-07-10 01:33 sbin
drwxr-xr-x    3 root root   4096 2005-07-06 23:11 secure_firewall_ltd
drwxr-xr-x    2 root root   4096 2005-05-14 18:49 srv
drwxr-xr-x   10 root root      0 2005-07-11 00:08 sys
drwxrwxrwt   11 root root   4096 2005-07-11 21:17 tmp
drwxr-xr-x   14 root root   4096 2005-07-10 15:52 usr
drwxr-xr-x   14 root root   4096 2005-06-06 07:02 var
drwxr-xr-x   14 root root   4096 2005-06-06 07:02 videos
lrwxrwxrwx    1 root root     25 2005-06-25 16:13 vmunix -> boot/vmunix-2.5-172


bash-2.0$ cat /etc/passwd
bash-2.0cat: Permission denied
bash-2.0$ who
admin

Limitando /etc/cojoney/fake_users e intervenendo in  /usr/share/kojoney/coret_fake.py è possibile abilitare un (altrettanto fasullo) account di tipo root, in modo da dare la possibilità all’intruso di impartire comandi amministrativi, che vengono registrati, come del resto viene fatto per tutta l’attività del daemon kojoney, sul file /var/log/honeypot.log:

[...]
2009/05/24 22:24 CEST [SSHService ssh-userauth on SSHServerTransport,2,127.0.0.1] root trying auth none
2009/05/24 22:24 CEST [SSHService ssh-userauth on SSHServerTransport,2,127.0.0.1] root trying auth password
2009/05/24 22:24 CEST [SSHService ssh-userauth on SSHServerTransport,2,127.0.0.1] root authenticated with password
2009/05/24 22:24 CEST [SSHService ssh-userauth on SSHServerTransport,2,127.0.0.1] starting service ssh-connection
[...]

Per esaminarne comodamente il contenuto ottenendone dei reports si possono utilizzare i comandi ‘kojreport’ e ‘kojreport-filter’ come qui:

# kojreport /var/log/honeypot.log 0 0 1
Kojoney Honeypot Report
-----------------------
Date: Sun 24 May 2009 01:52:27 PM CEST
Log lines: 217
Log size: 16K /var/log/honeypot.log


Authenticated users. Successfull logons
---------------------------------------
Total 0


Unauthenticated users. Failed logons
------------------------------------
9 root
6 shell
3 silversurfer
3 casimiro


Total 21


Users successfully authenticateds with publickey
------------------------------------------------
Total 0


Users unsuccessfully authenticateds with publickey
--------------------------------------------------
Total 0


Logons with null passwords
--------------------------
3 root
2 shell
1 silversurfer
1 casimiro


Total 7


Logons with or without password
-------------------------------
12 root
8 shell
4 silversurfer
4 casimiro


Total 28


Number of times a remote shell was opened
-----------------------------------------
Total 0


X11 forward requests
--------------------
Total 0


Executed different commands
---------------------------
Total 0


Number of times the intruder tries to change the terminal window size
---------------------------------------------------------------------
Total 0


IP Addresses
------------
1    192.168.1.3 - 3 conexion(es)
2    127.0.0.1 - 4 conexion(es)
3    89.118.167.202 - 1 conexion(es)


Total 3


IP Addresses and Countries
--------------------------
1    192.168.1.3 - **, Intranet address
2    127.0.0.1 - **, Intranet address
3    89.118.167.202 - EU, Unknown


Total 3


Sessions opened by humans
-------------------------
0 human session(s) total


Humans detecteds by IP
----------------------
0 human(s) total


Internal Honeypot Errors
------------------------
Total 1

Volendosi limitare a generare un report relativo ad un unico indirizzo IP o ad una specifica data si può usare il comando ‘kojreport-filter’ come di seguito:

# kojreport-filter /var/log/honeypot.log '<ip address o data>' 0 0 1

Gli ultimi tre parametri presenti nei comandi appena visti rappresentano l’attivazione (1) o la disattivazione di altrettante funzioni aggiuntive, le quali sono traceroute, nmap e kip2country, un tool per la geolocalizzazione.

Ad esempio:

# kojreport-filter /var/log/honeypot.log ’^2008/07/17’ 0 0 1

genera un normale report senza utilizzare traceroute ed nmap ma tentando la geolocalizzazione dei records presenti in /var/log/honeypot generati in data 2008/07/17, mentre:

# kojreport-filter /var/log/honeypot.log ’61.75.4.142’ 0 0 0

Genera un normale report senza utilizzare nè traceroute nè nmap nè geolocalizzazione dei records presenti in /var/log/honeypot che si riferiscono all’indirizzo ip specificato.

Un ultimo tool, kojhumans genera un rapporto sulla natura dell’attaccante (umano o bot)

Send post as PDF to PDF | PDF Creator | PDF Converter
:, , , ,

Comments are closed.

Cerchi qualcosa in particolare?

Usa il form qui sotto per cercare nel sito:

Blogroll!

Alcuni links...

Archives

Tutte le entries, in ordine cronologio...