0

所以我一直在检查我能想到的一切,以确保我的输入字段都不受任何类型的 SQL 注入的影响。好消息是他们很安全。坏消息是有一个标签将表单提交弄乱了,它甚至不应该触及,我一生都无法弄清楚原因。

这是使用的确切 html(它在模板文件中,所以请原谅{$variables}

<div width="100%">
{$content}

{if $show_form != false}
    <table class='Tfs_forum TFS_body ui-corner-all'>
    <thead><tr><th class="TFS_header ui-corner-all">{$table_header}</th></tr></thead>
    <tbody><tr><td class="TFS_userinfo loginlink ui-state-default ui-corner-all">
        BBCode enabled. HTML will be parsed.<br><center>
        <button type="button" onclick="addtoreply('[p]','[/p]')">Paragraph</button>
        <button type="button" onclick="addtoreply('[b]','[/b]')"><b>Bold</b></button>
        <button type="button" onclick="addtoreply('[i]','[/i]')"><i>Italic</i></button>
        <button type="button" onclick="addtoreply('[u]','[/u]')"><u>Underline</u></button>
        <button type="button" onclick="addtoreply('[s]','[/s]')"><s>Strikethrough</s></button>
        <button type="button" onclick="addtoreply('[size=20px]','[/size]')">Font Size</button>
        <button type="button" onclick="addtoreply('[color=red]','[/color]')">Font Color</button>
        <button type="button" onclick="addtoreply('[center]','[/center]')">Center Text</button>
        <button type="button" onclick="addtoreply('[url=]','[/url]')">Link</button>
        <button type="button" onclick="addtoreply('[img]','[/img]')">Image</button>
        <button type="button" onclick="addtoreply('[list]','[/list]')">List</button>
        <button type="button" onclick="addtoreply('[*]','')">List item</button>
    </center></td></tr>
    <form method="post" action="{$submit_url}">
    <tr><td>
        <input type="hidden" name="forum" value="{$forum_id}"><div style="margin-left:10%;"><label>Topic title: <input type="text" name="new_post_title" value="{$title}"></label></div>
    </td></tr>
    <tr><td>
        <label><div style="margin-left:10%; margin-right:10%;">Content:<textarea id="replybox" style="width: 100%; height: 150px;" name="new_post_content">{$formcontent}</textarea></label></div>
    </td></tr>
    <tr><td>
        <div style="display: inline-block; float: right;"><button type="submit" name="new_post_submit"><span class="save"></span>Submit</button></div>
    </td></tr></tbody>
    </form></table>
{/if}       

</div>

好的,这是执行的整个 php 脚本,直到它看到没有发布数据(没有发布任何论坛字段):

<?php
class TForumSystem_NewPost extends PHPDS_controller
{

public function execute()
{
    include("BBCode.class.php");
    include("includes.class.php");
    $this->template->addCSSToHead( Allincludes::css() );
    $this->template->addJsToHead( Allincludes::js() );



    //Main variables here
    $db_category = "***";
    $db_forums = "****";
    $db_posts = "****";
    $db_replies= "****";
    // $db_posts, $db_category, $db_forums, $db_replies;
    //$forum_view_url = $this->navigation->buildURL('forum-view');
    $view = $this->factory('views');
    $maincontent = "";
    $forum_link = ($this->navigation->buildURL('main-forum'));
if(!isset($_POST['forum'])) {
 $this->template->info("Invalid forum, please navigate to the main <a href=\"$forum_link\">forum</a>");
 $view->set('content', "Invalid forum, please navigate to the main <a href=\"$forum_link\">forum</a>"); $view->show();
}

问题是当我在标题字段中使用诸如' or 1='1或之类的东西时' or 1=1--,没有任何数据被发布,我目前正在使用 print_r($_POST) 来查看正在提交的内容,但什么也没有。

不过,它对于任何其他语句都可以完美运行,而且我还应该提到这个脚本在我的本地机器上完美运行,但是在使用我的主机时,我遇到了上述问题。

这是我测试过的所有输入的列表:

' or 1='1
' or 1=1--
'" or 1=1--
' or 0=0 --
' or 'a'='a
4

1 回答 1

0

嗯,我有点想通了。在我在 php 变量中创建论坛然后将其输出到模板之前,我将表单直接放入模板中,它似乎已经工作了,感谢所有帮助!

编辑:没关系,我们有新的证据。它在我的本地机器上运行良好,但它仍然无法在我的主机上运行..我在这里迷路了..

于 2012-10-10T09:01:46.650 回答