Posted by Cristian | Posted in Php | Posted on 17-01-2010
0
Fpdf è una classe PHP gratuita che permette di creare in php files PDF in modo molto semplice e rapido.
Dal sito ufficiale del progetto fpdf è possibile scaricare l’ultima versione di questa libreria.
Una volta caricata la classe sul vostro server potete provare il codice seguente per fare un test.
<?php
require(‘fpdf.php’);
$pdf_doc=new FPDF();
$pdf_doc->AddPage();
$pdf_doc->SetFont(‘Arial’,'B’,24);
$pdf_doc->Cell(60,30,’Ciao mondo!’);
$pdf_doc->Output();
?>
Partendo dalla classe fpdf è stata creata la classe html2fpdf che permette di creare un pdf da una pagina html.
Posted by Cristian | Posted in Php | Posted on 16-01-2010
0
il codice qui sotto restituisce a video la scritta Smemorando.com … il lavoro rende schiavi che è il risultato della conversione della stringa di dati da BASE64 ad ASCII Text
<?php
$str = ‘U21lbW9yYW5kby5jb20gLi4uIGlsIGxhdm9ybyByZW5kZSBzY2hpYXZp‘;
echo base64_decode($str);
?>
il codice qui sotto restituisce a video la scritta U21lbW9yYW5kby5jb20gLi4uIGlsIGxhdm9ybyByZW5kZSBzY2hpYXZp che è il risultato della conversione della stringa di dati da ASCII Text a BASE64
<?php
$str = ‘Smemorando.com … il lavoro rende schiavi‘;
echo base64_encode($str);
?>
Posted by Cristian | Posted in Apache2 | Posted on 10-01-2010
0
Può capitare che dopo aver smanettato troppo sui file di configurazione di apache2 si senta la necessità di ripartire da zero senza reinstallare l’intero sistema si può quindi seguire questa semplice procedura anche a seguito di errori tipo [.: 44: Can't open /etc/apache2/envvars] allo start del servizio apache2.
Dalla shell lancio:
sudo dpkg –get-selections | grep apache
poi in base al risultato lancio il remove con l’opzione purge per cancellare anche tutti i file di configurazione:
sudo apt-get remove –purge apache2 apache2-mpm-worker apache2-threaded-dev apache2-utils apache2.2-common libapache2-mod-python libapache2-mod-python-doc libapache2-mod-wsgi
poi reinstallo il tutto:
sudo apt-get install apache2 libapache2-mod-python libapache2-mod-wsgi libapache2-mod-python-doc
ora se vado in cd /etc/apache2/ trovo nuovamente tutti i file di configurazione aggiunti di default in fase di installazione.
Posted by Cristian | Posted in Apache2 | Posted on 07-01-2010
0
Per risolvere questo warning su apache (apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName)
basta aprire il file di configurazione di Apache che su ubuntu è sotto /etc/apache2/apache2.conf ed aggiungere: ServerName 127.0.0.1
Posted by Cristian | Posted in Apache2, Sicurezza IT | Posted on 12-12-2009
0
Visto che c’è chi ci prova sempre a bucare il nostro website…
[Sun Nov 15 22:39:48 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Sat Nov 21 04:38:59 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Sat Nov 21 05:19:41 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Sat Nov 21 20:49:55 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Wed Nov 25 06:23:15 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Thu Nov 26 04:22:24 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Fri Nov 27 06:23:02 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Fri Nov 27 07:00:35 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Fri Dec 04 08:37:26 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Fri Dec 04 22:20:37 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Tue Dec 08 06:13:16 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Tue Dec 08 11:30:17 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Wed Dec 09 06:32:59 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Fri Dec 11 01:57:56 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Fri Dec 11 05:30:52 2009] [error] [client xxx.xxx.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
con questo script molto semplice e ben fatto (trovato gia pronto su internet) è possibile aggiungere in automatico un drop su iptables per bloccare tutti quegli ip che provano a sfruttare Web Vulnerability Scanner tipo DFind, basta copiare il codice evidenziato qui sotto in un file tipo w00tw00t.sh e farlo girare con il cron.
#!/bin/sh
# add iptables drop for w00tw00t scan
for ip in `cat /var/log/apache2/error_log |grep w00tw00t | awk ‘{print $8}’ | sed ‘s/]//g’ | sort -ug` ; do
countoff=$[$countoff+1]
countwoot=$[$countwoot+1]
iptables -I INPUT -s $ip -j DROP
iptables -I OUTPUT -s $ip -j DROP
Posted by Cristian | Posted in Apache2 | Posted on 12-12-2009
0
Questo PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20060613+lfs/mcrypt.so’ su Ubuntu solitamente è dovuto al fatto che apache2 cerca di caricare il modulo mcrypt che non è stato installato e che quindi non viene trovato, basta quindi lanciare da shell:
apt-get install php5-mcrypt