0

第一次来这里,遇到问题,如果你们能解决我,我将非常感谢你们所有人。我正在做一个 HIDS 项目并且我遇到了这个问题,当我在 linux ( CENTOS 6.3 ) 上运行我的代码时效果很好,但是当我尝试在带有apache的 web 脚本上运行它时,它就不能很好地工作。我在Python上的代码

def sniffcometome(userbd,passbd):
    db= mysql.connect("localhost",userbd,passbd,"HIDS")
    cursor = db.cursor()
    proc = subprocess.Popen("ps -eo user | grep -v root | grep -v apache",shell=True,executable='/bin/bash',stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    (out,err) = proc.communicate()
    out = out.split()
    n = len(out)
    print "Content-Type: text/html\r\n\r\n"
    for i in range (n):
            sql = "select program from SNIFFER where program = '%s'"%(out[i])
            #print out[i]
            cursor.execute(sql)
            result = cursor.fetchone()
            if result != None:
                    SendMail('ALERT: Sniffer detected!')
                    print "Content-type: text/html\r\n\r\n"
                    print "Success"
    cursor.close()
    db.close()

    print "Content-type: text/html\n\n"
    print "Success"

当我在 Centos 上运行时,输出

['USER', 'rpc', 'dbus', 'avahi', 'avahi', 'rpcuser', 'haldaemon', 'haldaemon', 'mysql', 'postfix', 'postfix', 'tcpdump']

当我在 APACHE 上运行时,只有这个输出

['USER']

多谢你们!祝你有愉快的一天!

4

1 回答 1

0

出于安全原因,您不是在监狱环境中运行 Apache 服务器吗?你确定能ps看到这个环境中的一切吗?

于 2013-07-23T11:56:33.910 回答