0
내 portscanner 프로그램에서 스캔 한 포트 번호의 출력과 서비스 이름을 성공적으로 쓰고 싶습니다. 각 포트 번호, scannedby 및 서비스 이름에 대해 아래의 parseall 루틴을 호출합니다.xml 구문 분석 오류 속성 이름이 다시 정의되었습니다.
void parseall(int pid, char *scannedby, char *service){ // routine to add port, scannedby and service to xmlfile
xmlDocPtr doc; // pointer to parse xml Document
xmlNodePtr cur = NULL;// node pointer. It interacts with individual node
xmlAttrPtr attr; char portid[10];
sprintf (portid,"%d",pid); // converted int to string
doc = xmlParseFile(xmlFileName); //parse filename
cur = xmlDocGetRootElement(doc); // get rootnode
addnewportinfotag(cur,doc); // this routine adds new portid, scannedby and servicename tags to the xmlfile created
cur = cur->xmlChildrenNode; //get pointer
parseport(doc, cur, portid); // routine to add port to xmlfile
while(cur!=NULL){
if ((!xmlStrcmp(cur->name, (const xmlChar *)"ports"))){
parsehost(doc, cur, scannedby); // routine to add scanned by to xmlfile
parseservice(doc, cur, service); //routine to add servicename to xmlfile
}
cur = cur->next;
}
xmlSaveFormatFile (xmlFileName, doc, 1);
return;
xmlFreeDoc(doc);
}
코드가 성공적으로 컴파일하지만 난 더 이상의 포트를 검색 할 때, 그것은 아래의 "XML 구문 분석 오류가 재정의 이름 속성"제공합니다 : 그것은 잘 작동 하나의 포트에 대한
[ Port ] [ Scanned by] [ Status ] [Service]
79/tcp osus Open finger
80/tcp bt Open www
111/tcp osus Open sunrpc
xmloutput.xml:5: parser error : Attribute portid redefined
<ports protocol="tcp" portid="79" portid="80"><state state="open" reason="vanill
^
xmloutput.xml:5: parser error : Attribute scannedby redefined
e state="open" reason="vanilla-scan"/><scannedby scannedby="osus" scannedby="bt"
^
xmloutput.xml:5: parser error : Attribute name redefined
"/><scannedby scannedby="osus" scannedby="bt"/><service name="finger" name="www"
^
Segmentation fault
을 주는 :
<ports protocol="tcp" portid="22"><state state="open" reason="vanilla-scan"/><scannedby scannedby="bt"/><service name="ftp"/></ports></DPScanner>
안녕하세요, 빠른 반응에 감사드립니다. 문제는 새로운 태그를 작성하고 포트 정보를 채우는 대신 함수의 어딘가에 다음 포트 정보를 다음 포트에 추가하는 것입니다. pls 어떤 도움을 주실 것입니다 – Fahad
그건 잘못이야. 같은'ports' 태그에'port = "..."'속성을 가질 필요는 없습니다. 포트 번호가 속성이 아닌 하위 요소가되도록 XML 파일의 구조를 변경해야합니다. – Mat