sábado, julio 21, 2007

Problemas con apache y php

Tal y como conté en mi post anterior tenía previsto publicar un post sobre shells php, que son script php pensados para ser ejecutados en un servidor remoto mediante una vulnerabilidad RFI (Remote File Inclusion). Pero bueno eso os lo explicare todo mas despacio en el futuro post quiero publicar, ahora voy a contaros los problemas que tengo para preparar mi demostración.

Yo desde tiempos inmemoriales tengo instalado en mi servidor apache con soporte para php (desde que puse el server a funcionar) y iba bastante bien, en su día cuando hice algunos experimentos con php salió todo bien, y como servidor web para tener algunas cosillas accesibles desde cualquier pc de mi red también funcionaba bien. Y ahí estuvo el servidor web funcionando mucho tiempo, sin embargo la ley de Murphy actuó, justo el día que yo quería volver a utilizar el soporte para php no funcionaba, lo primero que quise hacer fue ejecutar directamente una de las shells de las que dispongo, así que la envío al server mediante netcat y luego la pongo en el directorio adecuado (/var/www/shells/) y pruebo a ejecutarla, pero no se ejecuto el codigo php en el servidor, lo que hizo fue ofrecerme descargar el archivo. Yo me quedé un poco desconcertado, no sabía que pasaba, porque el php había dejado de funcionar de repente? porque el servidor funcionaba, las páginas html las mostraba perfectamente. Reviso que sigo teniendo perfectamente instalado el apache y el php, a primera vista todo era correcto, los paquetes estaban instalados y yo no había cambiado los ficheros de configuración de apache. Pues nada tocaba agudizar el ingenio e intentar averiguar que pasaba, aunque realmente de ingenio poco, porque la solución era sencillísima y el problema era bastante fácil de descubrir, sin embargo yo me fui por el camino mas complejo... pero bueno no os adelante hechos, sigamos por orden.

Ejecuto ps axu | grep apache para ver si se estaba ejecutando el apache y no, no estaba, así que arranco el servicio: /etc/init.d/apache2 start, acto seguido pruebo a ver una página php que tenía en /var/www, info.php cuyo ćódigo podéis ver aquí: http://neobiusnet.googlepages.com/info.txt

Que lo que hace es simplemente mostrar una pagina con información sobre php, versión instalada, servidor web que corre... en fin información sobre la implementación. Bueno el caso es que puse esa página: http/debian/info.php (nota: debian es el nombre de mi server, y así esta definido en /etc/hosts). Yo ya un poco harto del tema y sin saber muy bien que hacer pruebo la solución clásica de windows, reinstalar, así que nada apt-get install -reinstall apache2, no valió para nada, así que pruebo desinstalando y eliminando los archivos de configuración a mano, tanto de apache como de php, así que apt-get remove --purge apache2 php5. Bueno tras eliminarlo todo pensé que lo mejor era instalar de nuevo siguiendo algún tutorial, google apache php debian etch, si, yo a los buscadores suelo hablarles en indio, total, si luego van a pasar de las preposiciones y demás pues para eso yo me lo ahorro directamente, además de todos es sabido que lo adecuado es poner las palabras claves. Bueno encontré algo y reinstalo todo (apache+php) edito los archivos de configuración para que apache soporte php. Hecho, reinicio apache y... tampoco interpretaba código php, WTF!! Probé borrándolo una vez mas y probando un tutorial diferente, tampoco funcionó.

Entonces recordé un detalle, hace poco, como mes y medio, instale un nuevo servidor web, thttpd, que se trata de un sencillo servidor web, que no necesita archivo de configuración, las opciones se le ponen como parámetros, al que le interesen mas detalles que lea esto. El caso es que el servidor es muy cómodo, os cuento para que lo uso, yo todas las descargas que hago en el server con mldonkey van a /media/hde/mldonkey/incoming y otras descargas las tengo en /media/hde/series... en fin que de /media/hde cuelgan muchas cosas que me interesan y a las que me gustaría tener acceso sencillo, antes usaba netcat (y para casos concretos sigo usándolo), pero es muy cómodo moverte al directorio que te interese y poner thttpd -p 88 -d /media/hde y tener un servidor web en el puerto 88 con los /media/hde como directorio raiz y poder hacer streaming fácilmente, o descargar varios archivos del servidor... en fin menos trabajoso que netcat e infinitamente mas útil y cómodo (ojo me refiero a esta tarea, netcat sigue siendo utilísimo, sin embargo para esta necesidad creo que esta opción es mejor). O a lo mejor me interesan varios archivos del disco duro externo montado en /mnt, pues pongo otro server en el puerto 89 y con ese directorio como raíz, es una solución muy flexible.

Y la historia de thttpd a que viene? pues muy sencillo resulta que este servidor web "suplantó" a apache y se ejecutaba en el puerto 80, y este servidor no tiene soporte para php. Esto lo descubrí de una forma muy sencilla, puse en firefox http://debian y me mostró un listado de los archivos de /var/www (no hay index.*) en una página html con el formato por defecto de thttpd, así que lo reconocí al instante. Para solucionar el problema y comprobar que efectivamente el servicio corría y en ese puerto ejecuté: lsof -i TCP:80, vi el pid del proceso y lo maté, rearranqué apache probé el archivo info.php y se ejecutó! también lo hizo una shell que probé. Así que nada problema solucionado, simplemente pasaba que thttpd corría en lugar de apache.

Bueno realmente la historia no ha acabado, eso han sido los problemas para conseguir ejecutar páginas en php, pero todavía me queda otra cosa, yo había preparado una página vulnerable a RFI para hacer una demostración sobre como usar las shells php. El código que puse para el archivo que llame php.php podéis verlo aquí: http://neobiusnet.googlepages.com/php.txt

Con intención de pasarle luego luego como parámetro la shell (típico ataque rfi). Sin embargo por alguna razón que no entiendo (no sé php) me muestra esto al ejecutarlo:

Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/shells/php.php on line 5

RFI


Y el rfi no me funciona, alguien que sepa de php en la sala?

Nada mas, os seguiré contando mas cosas según vayan pasando.

PD: Vaya mierda blogger, no puedo poner código html, blogger lo interpreta y el código php lo ha transformado como ha querido. Así que lo he tenido que subir en txt a google pages.

8 comentarios:

Anónimo dijo...

[u][b]Xrumer[/b][/u]

[b]Xrumer SEO Professionals

As Xrumer experts, we possess been using [url=http://www.xrumer-seo.com]Xrumer[/url] quest of a sustained leisure things being what they are and know how to harness the colossal power of Xrumer and go off it into a Cash machine.

We also yield the cheapest prices on the market. Numberless competitors will charge 2x or consistent 3x and a destiny of the opportunity 5x what we responsibility you. But we feel in providing enormous mending at a debilitated affordable rate. The unbroken point of purchasing Xrumer blasts is because it is a cheaper variant to buying Xrumer. So we plan to stifle that thought in mind and yield you with the cheapest grade possible.

Not just do we be suffering with the most successfully prices but our turnaround heyday after your Xrumer posting is wonderful fast. We intention have your posting done in the forefront you know it.

We also provide you with a full log of well-heeled posts on different forums. So that you can see also in behalf of yourself the power of Xrumer and how we get harnessed it to emoluments your site.[/b]


[b]Search Engine Optimization

Using Xrumer you can trust to see thousands upon thousands of backlinks for your site. Tons of the forums that your Install you will be posted on bear great PageRank. Having your tie-in on these sites can deep down mitigate build up some top-grade grade help links and as a matter of fact boost your Alexa Rating and Google PageRank rating utterly the roof.

This is making your instal more and more popular. And with this better in celebrity as grammatically as PageRank you can expect to lead your site really downright high-pitched in those Search Locomotive Results.
Conveyance

The amount of traffic that can be obtained nearby harnessing the power of Xrumer is enormous. You are publishing your locality to tens of thousands of forums. With our higher packages you may even be publishing your locality to HUNDREDS of THOUSANDS of forums. Imagine 1 brief on a popular forum disposition usually rig out 1000 or so views, with say 100 of those people visiting your site. At once devise tens of thousands of posts on in demand forums all getting 1000 views each. Your see trade liking function through the roof.

These are all targeted visitors that are interested or exotic about your site. Envision how assorted sales or leads you can achieve with this titanic number of targeted visitors. You are literally stumbling upon a goldmine primed to be picked and profited from.

Retain, Traffic is Money.
[/b]

BECOME ENTHUSIASTIC ABOUT YOUR CHEAPLY BLAST TODAY:


http://www.xrumer-seo.com

Anónimo dijo...

[B]NZBsRus.com[/B]
Lose Crawling Downloads Using NZB Downloads You Can Easily Search HD Movies, PC Games, Music, Applications and Download Them @ Maxed Out Speeds

[URL=http://www.nzbsrus.com][B]NZB Search[/B][/URL]

Anónimo dijo...

Predilection casinos? probe this unversed [url=http://www.realcazinoz.com]casino[/url] advisor and toady to online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also into our up to the coup d'oeil [url=http://freecasinogames2010.webs.com]casino[/url] contribute something at http://freecasinogames2010.webs.com and bring yon concrete substitute !
another unsurpassed [url=http://www.ttittancasino.com]casino spiele[/url] in the sector of is www.ttittancasino.com , equitably than of german gamblers, sip upon erstwhile mark online casino bonus.

Anónimo dijo...

Someone deleted several links from gotupload and rapidshare servers.

From now, we will use www.tinyurlalternative.com as our main [url=http://www.tinyurlalternative.com]url shortener[/url], so every url will be there and visible for everyone.

You can choose from several great [url=http://kfc.ms]short url[/url] names like:

kfc.ms easysharelink.info jumpme.info megauploadlink.info megavideolink.info mygamelink.info myrapidsharelink.info mytorrentlink.info myurlshortener.com mywarezlink.info urlredirect.info urlshrinker.info weblinkshortener.com youtubelink.info and many others.

They have above 60 other ready domains and the [url=http://myurlshortener.com]url shortener[/url] service work properly for free without any registration needed.

So we assume it is good idea and propose you to use [url=http://urlredirect.info]url redirect[/url] service too!

Thank you.

Anónimo dijo...

It isn't hard at all to start making money online in the underground world of [URL=http://www.www.blackhatmoneymaker.com]blackhat internet marketing[/URL], Don’t feel silly if you don't know what blackhat is. Blackhat marketing uses not-so-popular or misunderstood ways to build an income online.

Anónimo dijo...

http://www.pornvideoonline.info

www.pornvideodownload.info

http://www.pornvideotorrent.info/

www.gaypornonline.info

http://www.teenpornonline.info/

http://www.freepornvideosonline.info

http://www.bestpornvideo.info

[url=http://www.pornvideoonline.info]Porn video online[/url]
[url=http://www.pornvideodownload.info]Porn video download[/url]
[url=http://www.pornvideotorrent.info]Porn video torrent[/url]
[url=http://www.gaypornonline.info]Gay porn online[/url]
[url=http://www.teenpornonline.info]Teen porn online[/url]
[url=http://www.freepornvideosonline.info]Free porn videos online[/url]
[url=http://www.bestpornvideo.info]Best porn video[/url]

Anónimo dijo...

making money online http://www.333eur.com

Anónimo dijo...

site to [b]software downloads[/b] is available here:

Windows YouTube downloader
[url=http://www.1800soft.com]Windows YouTube downloader[/url]

betting software
[url=http://www.betextremesoft.com]betting software[/url]

buy software for windows
[url=http://www.buysoftwareforwindows.com]buy software for windows[/url]

download software for windows
[url=http://www.downloadsoftwareforwindows.com]download software for windows[/url]

Download Youtube Videos
[url=http://www.downloadyoutubevideos.co.uk]Download Youtube Videos[/url]

FLV to AVI converter
[url=http://www.flvtoavi.co.uk]FLV to AVI[/url]

DVD ripper
[url=http://www.flvtodvd.com]DVD ripper[/url]

Video converter
[url=http://www.hollydollyvideo.com]Video converter[/url]

Home video converter software
[url=http://www.homevideopage.com]Home video software[/url]

Poker software
[url=http://www.pokerwinningvideo.com]Poker video software[/url]

Shark Video Downloader
[url=http://www.sharkvideopage.com]Shark Video Downloader software[/url]

Simplest YouTube Internet Video Downloader
[url=http://www.simplestutils.com]Watermark Software[/url]

Popular screensavers
[url=http://www.popularscreensaverpage.com]Popular Screensaver[/url]

Hyper YouTube Magic Tool XXX
[url=http://www.andromedaapps.com]Hyper YouTube Magic Tool XXX[/url]

Free FLV converter
[url=http://www.cassiopeiasoft.com]Free FLV converter[/url]

Working YouTube downloader
[url=http://www.pegasusapps.com]Working YouTube downloader[/url]