IndexScript Forum  

Go Back   IndexScript Forum > IndexScript > IndexScript - Directory Script
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 07-26-2007, 02:49 PM
hakon hakon is offline
Administrator
 
Join Date: Jan 2006
Posts: 1,683
Default indexscript sql injection hole fix

following from this thread: http://www.indexscript.com/forum/showthread.php?t=2260 - i'm posting a consolidated fix in this thread for the sql injection security hole exploited today:


if you are using v2.8 and have not modified your utils.php file found in the include folder:
1. you can simply download the utils.php attached in this post for v2.8 and replace your existing one with it


if you are using v2.7 and have not modified your utils.php file found in the include folder:
1. you can simply download the utils.php attached in this post for v2.7 and replace your existing one with it


if you want to perform a manual replace:
1. open up your utils.php in the include folder
2. look for:
Code:
function fnpreparesql($field) {
  if(!get_magic_quotes_gpc()) {
    return mysql_real_escape_string($field);
  }
  else {
    return $field;
  }
}
and replace with:
Code:
function fnpreparesql($field) {
  if(get_magic_quotes_gpc()) {
    $temp = stripslashes($field);
  }
  else {
    $temp = $field;
  }

  if(stristr($temp, "dir_login")) {
    $temp = "";
  }

  return mysql_real_escape_string($temp);
}
look for all instances of:
Code:
= " . $cat_id
and replace with:
Code:
= " . fnpreparesql($cat_id)
look for all instances of:
Code:
= " . $start_id
and replace with:
Code:
= " . fnpreparesql($start_id)
look for all instances of:
Code:
= " . $row['parent_id']
and replace with:
Code:
= " . fnpreparesql($row['parent_id'])
look for all instances of:
Code:
= " . $row['cat_id']
and replace with:
Code:
= " . fnpreparesql($row['cat_id'])
Attached Files
File Type: zip utils-v2.8.zip (2.6 KB, 42 views)
File Type: zip utils-v2.7.zip (2.2 KB, 14 views)
__________________
Get your IndexScript skins HERE
Some other interesting sites: Pneumococcal Diseases | Learn about Colic | Pregnancy Articles | Humor Portal

Last edited by hakon : 07-26-2007 at 05:38 PM. Reason: consolidate fix into a single thread
Reply With Quote
  #2  
Old 07-26-2007, 06:01 PM
rankappeal rankappeal is offline
Junior Member
 
Join Date: Apr 2007
Posts: 20
Default

Hi hakon, unfortunately this fix did not work for me has it made my sub categories unviewable....invalid fetch array argument in sql...
any suggestions?
Reply With Quote
  #3  
Old 07-26-2007, 07:14 PM
gkd_uk's Avatar
gkd_uk gkd_uk is offline
Moderator
 
Join Date: Mar 2007
Posts: 274
Default

Thanks Hakon. I have not been hacked but have replaced the new util file. and all seems fine

Is there anyway you can check if my directory is ok now

The directory is The Web Directory

Thanks
Reply With Quote
  #4  
Old 07-26-2007, 07:20 PM
kiviniar's Avatar
kiviniar kiviniar is offline
Moderator
 
Join Date: Oct 2006
Posts: 271
Default

Its working for me

Rankappeal, i think that u have a older version of the script running as i have the same problem in one of my indexscript dirs

Upgrading it right away
__________________
blog directory | business directory | free web directory
------------------------------------------------------
~courtesy - IndexScript & IndexScript Support
~ suzuki bikes free online games directory blog
Reply With Quote
  #5  
Old 07-26-2007, 07:43 PM
perform perform is offline
Junior Member
 
Join Date: Jan 2007
Posts: 10
Default

I found some info while searching about this exploit


Quote:
Site: http://indexscript.com
Found By: xssvgamer

Google Dork: allintext: "This site is powered by IndexScript"

exploit:

http://www.example.com/show_cat.php?cat_id=-1 UNION ALL SELECT login,password FROM dir_login /*

Blind SQL injection in indexscript..

Vul Code:
"$sql = "select name, meta_title, meta_description, meta_keywords from dir_cat where " .
"cat_id=" . fnpreparesql($_GET['cat_id']);"

# milw0rm.com [2007-07-25]

It was found on this page
Quote:
ht*tp:/*/ww*w.mi*lw0r*m.co*m/ex*ploi*ts/4*22*5
^^ Ofcourse remove all * from the URL

I hope it could be of some help. I was trying to find "This site is powered by IndexScript" in google and got this.
Reply With Quote
  #6  
Old 07-26-2007, 07:58 PM
Raven's Avatar
Raven Raven is offline
Moderator
 
Join Date: Jan 2007
Location: Oregon, USA
Posts: 155
Default

Mine was hacked too....over 2000 urls gone, and 100+ categories..gone.

--<Hacked by y0n4s >--

Is what it says in the title header

And I couldn't log in.

Thanks for this fix Hakon
Reply With Quote
  #7  
Old 07-26-2007, 08:22 PM
rankappeal rankappeal is offline
Junior Member
 
Join Date: Apr 2007
Posts: 20
Default

kiviniar ,

I am using V2.8 And I Just Got Hacked Again....Good job I Backed Up.. The Sod Made A Right Mess...Lol... I have changed databases and all passwords now
Reply With Quote
  #8  
Old 07-26-2007, 08:26 PM
gkd_uk's Avatar
gkd_uk gkd_uk is offline
Moderator
 
Join Date: Mar 2007
Posts: 274
Default

Quote:
Originally Posted by rankappeal View Post
kiviniar ,

I am using V2.8 And I Just Got Hacked Again....Good job I Backed Up.. The Sod Made A Right Mess...Lol... I have changed databases and all passwords now
Hi

Have you applied the fix?
Reply With Quote
  #9  
Old 07-26-2007, 08:39 PM
xfairguy xfairguy is offline
Junior Member
 
Join Date: Jun 2007
Posts: 13
Default

Just to confirm that fix work I just had two morons trying to hack my dir.
But the question is, is this the only security issue?
I was hacked some time ago and I am not sure if hacker used this issue with sql injections in query strings because I now see in my stats tracker how they try to insert sql but then I did not see that stuff.
Reply With Quote
  #10  
Old 07-26-2007, 08:40 PM
rankappeal rankappeal is offline
Junior Member
 
Join Date: Apr 2007
Posts: 20
Default

Okay I have managed to apply the fix. Thanks Hakon everything seems ok now.... hopefully it will keep the blighter out...
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 02:22 PM.



Same Author: URL Shortening Script ]

Partners: IT Support Blog | Free Games | iWebzen Web Directory | PR Home Pages Web Directory ]





Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.