처음으로 문제가 생겼다. 해결할 수 있다면 나는 모두에게 매우 감사 할 것이다. HIDS 프로젝트를하고 있는데 리눅스 (CENTOS 6.3)에서 코드를 실행하면 위와 같은 문제가 발생하지만 아파치 웹 스크립트에서 실행하려고하면이 작동하지 않습니다. 아주 잘. 내 코드에 파이썬아파치가 내 파이썬 코드를 잘 실행하지 않는다.
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']
내가에만이 출력
['USER']
고마워 아파치에서 실행! 그리고 좋은 하루 되세요!
정확히 같은 방식으로 스크립트를 수동으로 실행 하시겠습니까? 예를 들면 : 어떤 사용자가 아파치를 실행하고 있습니까? '누가 누군지 '로 확인할 수 있습니다. 아마도이 사용자는 모든 프로세스를 볼 수 없습니까? – Jensd
나는이 명령을 "python hids_verif.py"라고하며 다른 사용자들도 실행한다. 그리고 나는 실행중인 프로세스 목록을 얻는다. 내 스크립트에서 "whoami"로 확인하고 "apache"라고 말합니다. – luifer99