需要 sql 注入方面的帮助

发布于 2024-12-09 19:23:04 字数 875 浏览 1 评论 0原文

首先,我并不想进行黑客攻击或做任何非法的事情。我以为我让你们知道了。我有一个客户希望我对他的系统进行一些修改,当我查看它时,我注意到没有任何内容被逃脱。我不是在开玩笑,没有什么可以逃脱。我向他解释说,拥有这样的系统是不安全的。然后他继续告诉我,他这样的系统已经使用了几年,但什么也没发生。我需要向他表明他的系统不安全,但我真的不知道执行sql注入。以下是一些使用 $_GET 并且未转义的查询。

SELECT *,DATE_FORMAT(joined,'%M %d, %Y') as \"Joined\" FROM `members` WHERE `name` LIKE '".$ltr."%' ORDER BY points DESC LIMIT $page,50

这是另一个:

SELECT * FROM groups WHERE id=$thisladder[grid]

我看到的唯一“可能”清理 $_GET 的是这个函数:

if (!ini_get('register_globals')) {
   $superglobals = array($_SERVER, $_ENV,
       $_FILES, $_COOKIE, $_POST, $_GET);
   if (isset($_SESSION)) {
       array_unshift($superglobals, $_SESSION);
   }
   foreach ($superglobals as $superglobal) {
       extract($superglobal, EXTR_SKIP);
   }
}

上面的函数可能正在清理变量。是的,系统还使用寄存器全局变量,这也很糟糕。

我还做了备份,以防万一。

First, I'm not trying to hack or do anything illegal. Thought I let you guys know. I have a client that want's me to do some modifications on his system, when I was looking at it I notice that NOTHING was escaped. I'm not joking, nothing is being escaped. I explained to him that it's insecure to have a system like that. He then proceeds to tell me that he's had his system like this for few years and nothing has happened. I need to show him that his system is not safe, but I really don't know to do perform an sql injection. Here's a few queries that use $_GET and are not escaped.

SELECT *,DATE_FORMAT(joined,'%M %d, %Y') as \"Joined\" FROM `members` WHERE `name` LIKE '".$ltr."%' ORDER BY points DESC LIMIT $page,50

Here's another one:

SELECT * FROM groups WHERE id=$thisladder[grid]

The only thing that I see that "might" clean the $_GET is this function:

if (!ini_get('register_globals')) {
   $superglobals = array($_SERVER, $_ENV,
       $_FILES, $_COOKIE, $_POST, $_GET);
   if (isset($_SESSION)) {
       array_unshift($superglobals, $_SESSION);
   }
   foreach ($superglobals as $superglobal) {
       extract($superglobal, EXTR_SKIP);
   }
}

It's possible that the function above may be sanitizing the variables. And yes, the system also uses register globals, which is also bad.

I also made a backup, just in case.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

琉璃梦幻 2024-12-16 19:23:04

没有比 http://xkcd.com/327/ 更好的说法了。

但话又说回来,Marc B 说,忘记 SQL 注入,register_globals 非常多,更糟。从来没想过我真的会看到它模拟,以防万一它关闭了。

Can't say it better than http://xkcd.com/327/.

But then again, as Marc B says, forget SQL injection, register_globals is much, much worse. Never thought I'd actually see it emulated, just in case it's off.

弥枳 2024-12-16 19:23:04

一些有趣的事情可以向你的“朋友”展示他的代码有多么愚蠢:

http://example.com/badscript.php?_GET[]=ha+ha+I+pwned+your+GET+superglobal
http://example.com/badscript.php?_SESSION[issuperuser]=1

这种事情完全就是为什么 register_globals 是一个彻头彻尾的白痴想法,并且(在太长时间之后)终于被设为默认关闭。

忘记 SQL 注入 - 那段愚蠢的代码允许远程 PHP 变量注入。

Some fun things to show your 'friend' how stupid his code is:

http://example.com/badscript.php?_GET[]=ha+ha+I+pwned+your+GET+superglobal
http://example.com/badscript.php?_SESSION[issuperuser]=1

This sort of thing is EXACTLY why register_globals is such an outright F'ingly moronic idea, and (after FAR too long) has finally been made to default to OFF.

Forgot SQL injection - that idiotic piece of code is allowing remote PHP variable injection.

べ映画 2024-12-16 19:23:04

如果登录代码看起来像这样:

$query = 'SELECT id FROM users WHERE username=\''.$_POST['username'].'\' AND password=\''.$_POST[password].'\'';
$result = mysql_query($query);
etc, etc...

尝试在登录字段中输入此内容

username = "whatever"
password = "' OR 1"

是否有意义?

if login code looked something like this:

$query = 'SELECT id FROM users WHERE username=\''.$_POST['username'].'\' AND password=\''.$_POST[password].'\'';
$result = mysql_query($query);
etc, etc...

try typing this into the login fields

username = "whatever"
password = "' OR 1"

make sense?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文