コード例 #1
0
ファイル: msgs.c プロジェクト: KMNR/mod_auth_kerb
void MSG_Error_SystemError(char *when)
{
	MSG_Header("CGIWrap Error", "System Error");
	printf("CGIWrap encountered a system error.\n");

	if ( ! MSG_QuietErrors )
	{
	if ( MSG_HTMLMessages )
	{
		printf("<DL>\n");
		printf("<DT>When: %s\n", HTMLEncode(when));
#if defined(HAS_STRERROR)
		printf("<DT>Error Message: %s\n", strerror(errno));
#elif defined(HAS_PERROR)
		perror("<DT>Error Message");
#endif
		printf("<DT>Error Number: %d\n", errno);
		printf("</DL>\n");
	}
	else
	{
		printf("\tWhen: %s\n", when);
#if defined(HAS_STRERROR)
		printf("\tError Message: %s\n", strerror(errno));
#elif defined(HAS_PERROR)
		perror("\tError Message");
#endif
		printf("\tError Number: %d\n\n", errno);
	}
	}
	
	MSG_Footer();
	exit(1);
}
コード例 #2
0
ファイル: msgs.c プロジェクト: KMNR/mod_auth_kerb
void MSG_Error_ExecutionNotPermitted(char *path, char *reason)
{
	MSG_Header("CGIWrap Error", "Execution of this script not permitted");

	if ( MSG_QuietErrors )
	{
		MSG_Error_RequestError();
	}
	else
	{
		if ( path )
		{
			printf("Execution of (%s) is not permitted\n",HTMLEncode(path));
		}
		else
		{
			printf("Execution of that script is not permitted\n");
		}
		printf("for the following reason:\n\n");

		if ( MSG_HTMLMessages )
		{
			printf("<P><DL><DT>%s</DL>\n", reason);
		}
		else
		{
			printf("\t%s\n", reason);
		}
	}

	MSG_Footer();
	exit(1);
}
コード例 #3
0
ファイル: msgs.c プロジェクト: KMNR/mod_auth_kerb
void MSG_Error_AccessControl(char *why, char *allowfile, char *denyfile)
{

	if ( MSG_QuietErrors )
	{
		MSG_Error_RequestError();
	}
	else
	{
		MSG_Header("CGIWrap Error", "Access Control");
		printf("CGIWrap access control mechanism denied execution of this\n");
		printf("script for the following reason:\n\n");

		if ( MSG_HTMLMessages )
		{
			printf("<P>\n");
		}
		printf("\t%s\n", why);	

		if ( allowfile || denyfile )
		{
			if ( MSG_HTMLMessages )
			{
				printf("<P>\n");
			}
			if ( allowfile )
			{
				printf("\tAccess Control Allow File: %s\n", HTMLEncode(allowfile));
			}
			if ( denyfile )
			{
				printf("\tAccess Control Deny File: %s\n", HTMLEncode(denyfile));
			}
		}
		MSG_Footer();
	}
	exit(1);
}
コード例 #4
0
////////////////////////////////////////////////////////////////
///Function to send sniffed file list to the client
void Executive::listReply(struct mg_connection *conn, const struct mg_request_info *request_info)
{
	try{
	int is_jsonp;
	char text[100];
	const char * json;
	std::stringstream ss;
	std::string msg;
	mg_printf(conn, "%s\r\n", json_reply_start);	//prints the json message starting headers
	const char * clength;
	char h1[] = "Content-Length";
	clength = mg_get_header(conn,h1);	//get the length of post data
	int clen = atoi(clength);
	char *pdata = (char *)malloc(clen+clen/8+1);
	int datalen = mg_read(conn,pdata,clen);	//read post data
	pdata[clen] = '\0';
	mg_get_var(pdata, strlen(pdata == NULL ? "" : pdata), "text", text, sizeof(text));
	std::string path(text);
	is_jsonp = handle_jsonp(pdata,conn, request_info);	//find the callback function
	srand((size_t)time(NULL));
	ss<<"[";
	fsniffer2.Clear();
	fsniffer2.sniffFiles(path);
	std::set<std::string> filelist = fsniffer2.getFiles();	//get sniffed files
	for (std::set<std::string>::iterator it=filelist.begin(); it != filelist.end(); it++)
	{
		std::string tempstr = HTMLEncode(*it);	//html encode filepaths
		ss<<"{item: \""<<tempstr<<"\"},";
	}
	ss<<"]";
	msg = ss.str();
	json = msg.c_str();
	mg_printf(conn, "%s", json);	//print json array to the connection

	if (is_jsonp) 	{
		mg_printf(conn, "%s", ")");	//print closing bracket for the function
	}
//	fsniffer2.saveFiles();	//save sniffed files
	}
	catch(std::exception ex){std::cout << "\n  " << ex.what() << "\n\n";}
}
コード例 #5
0
////////////////////////////////////////////////////////////////
///Function to send sniffed process list
void Executive::procReply(struct mg_connection *conn, const struct mg_request_info *request_info)
{
	try{
	int is_jsonp;

	const char * json;
	std::stringstream ss;
	std::string msg;
	mg_printf(conn, "%s\r\n", json_reply_start);	//prints the json message starting headers
	const char * clength;
	char h1[] = "Content-Length";
	clength = mg_get_header(conn,h1);	//get the length of post data
	int clen = atoi(clength);
	char *pdata = (char *)malloc(clen+clen/8+1);
	int datalen = mg_read(conn,pdata,clen);	//read post data
	pdata[clen] = '\0';
	/*mg_get_var(pdata, strlen(pdata == NULL ? "" : pdata), "text", text, sizeof(text));
	std::string path(text);*/
	is_jsonp = handle_jsonp(pdata,conn, request_info);	//find the callback function
	srand((size_t)time(NULL));
	ss<<"[";
	prsniffer.Clear();
	prsniffer.sniffProcesses();
	std::map<std::string,int> filelist = prsniffer.getProcesses();	//get process list
	for (std::map<std::string,int>::iterator it=filelist.begin(); it != filelist.end(); it++)
	{
		std::string tempstr = HTMLEncode((*it).first);
		ss<<"{item: \""<<tempstr<<" ("<<(*it).second<<")\"},";	//store process name and count
	}
	ss<<"]";
	msg = ss.str();
	json = msg.c_str();
	mg_printf(conn, "%s", json);	//print json array to the connection
	if (is_jsonp)
	{
		mg_printf(conn, "%s", ")");	//print closing bracket for the function
	}
	//prsniffer.saveProcesses();
	}catch(std::exception ex){std::cout << "\n  " << ex.what() << "\n\n";}
}
コード例 #6
0
ファイル: msgs.c プロジェクト: KMNR/mod_auth_kerb
void MSG_Error_NoSuchUser(char *user)
{
	if ( MSG_QuietErrors )
	{
		MSG_Error_RequestError();
	}
	else
	{
	MSG_Header("CGIWrap Error", "User not found");

	printf("CGIWrap was unable to find the user '%s' in the\n", 
		HTMLEncode(user));
	printf("password file on this server.\n\n");
	if ( MSG_HTMLMessages )
	{
		printf("<P>\n");
	}
	printf("Check the URL and try again.\n");

	MSG_Footer();
	exit(1);
	}
}
コード例 #7
0
ファイル: msgs.c プロジェクト: KMNR/mod_auth_kerb
void MSG_Info(void)
{
	char *prefix_html = "<DD><B>";
	char *prefix_plain = "\t";
	char *suffix_html = "</B>";
	char *suffix_plain = "";
	char *prefix, *suffix;
	
	/* Handle the prefix and suffix for list items */
	if ( MSG_HTMLMessages )
	{
		prefix = prefix_html;
		suffix = suffix_html;
	}
	else
	{
		prefix = prefix_plain;
		suffix = suffix_plain;
	}


#if defined(CONF_LOCAL_INFO_ENABLED)
	if ( MSG_HTMLMessages )
	{
		printf("<P><HR><P>\n");
		printf("<DL>\n");
		printf("<DT><B>Local Information and Documentation:</B>\n");
		printf("<P>\n");
		printf("</DL>\n");
	}
	else
	{
		printf("\n\n");
		MSG_BoxedText("Local Information and Documentation:");
		printf("\n");
	}
#endif

#if defined(CONF_LOCAL_SITE_URL)
	if ( MSG_HTMLMessages )
	{
		printf("%sWeb Site%s: <A HREF=\"%s\">%s</A>\n", 
			prefix, suffix, CONF_LOCAL_SITE_URL, CONF_LOCAL_SITE_URL);
	}
	else
	{
		printf("%sWeb Site%s: %s\n", 
			prefix, suffix, CONF_LOCAL_SITE_URL);
	}
#endif
#if defined(CONF_LOCAL_DOC_URL)
	if ( MSG_HTMLMessages )
	{
		printf("%sCGIWrap Docs%s: <A HREF=\"%s\">%s</A>\n", 
			prefix, suffix, CONF_LOCAL_DOC_URL, CONF_LOCAL_DOC_URL);
	}
	else
	{
		printf("%sCGIWrap Docs%s: %s\n", 
			prefix, suffix, CONF_LOCAL_DOC_URL);
	}
#endif

#if defined(CONF_LOCAL_CONTACT_NAME)
	printf("%sContact Name%s: %s\n", 
		prefix, suffix, CONF_LOCAL_CONTACT_NAME);
#endif
#if defined(CONF_LOCAL_CONTACT_EMAIL)
	if ( MSG_HTMLMessages )
	{
		printf("%sContact EMail%s: <A HREF=\"mailto:%s\">%s</A>\n", 
			prefix, suffix, CONF_LOCAL_CONTACT_EMAIL, 
			CONF_LOCAL_CONTACT_EMAIL);
	}
	else
	{
		printf("%sContact EMail%s: %s\n", 
			prefix, suffix, CONF_LOCAL_CONTACT_EMAIL);
	}
#endif
#if defined(CONF_LOCAL_CONTACT_PHONE)
	printf("%sContact Phone%s: %s\n", 
		prefix, suffix, CONF_LOCAL_CONTACT_PHONE);
#endif
#if defined(CONF_LOCAL_CONTACT_URL)
	if ( MSG_HTMLMessages )
	{
		printf("%sContact Web Site%s: <A HREF=\"%s\">%s</A>\n", 
			prefix, suffix, CONF_LOCAL_CONTACT_URL, 
			CONF_LOCAL_CONTACT_URL);
	}
	else
	{
		printf("%sContact Web Site%s: %s\n", 
			prefix, suffix, CONF_LOCAL_CONTACT_URL);
	}
#endif


	if ( MSG_HTMLMessages )
	{
		printf("<P>\n");
		printf("<DL>\n");
		printf("<DT><B>Server Data:</B>\n");
		printf("<P>\n");
	}
	else
	{
		printf("\n");
		MSG_BoxedText("Server Data:");
		printf("\n");
	}
	
			
	if ( getenv("SERVER_ADMIN") )
	{
	      printf("%sServer Administrator/Contact%s: %s\n", 
		      prefix, suffix, HTMLEncode(getenv("SERVER_ADMIN")));
	}
	if ( ! MSG_QuietErrors && getenv("SERVER_NAME") )
	{
	      printf("%sServer Name%s: %s\n", 
		      prefix, suffix, HTMLEncode(getenv("SERVER_NAME")));
	}
	if ( ! MSG_QuietErrors && getenv("SERVER_HOST") )
	{
	      printf("%sServer Host%s: %s\n", 
		      prefix, suffix, HTMLEncode(getenv("SERVER_HOST")));
	}
	if ( ! MSG_QuietErrors && getenv("SERVER_PORT") )
	{
	      printf("%sServer Port%s: %s\n", 
		      prefix, suffix, HTMLEncode(getenv("SERVER_PORT")));
	}
	if ( ! MSG_QuietErrors && getenv("SERVER_PROTOCOL") )
	{
	      printf("%sServer Protocol%s: %s\n", 
		      prefix, suffix, HTMLEncode(getenv("SERVER_PROTOCOL")));
	}
	if ( ! MSG_QuietErrors && getenv("HTTP_HOST") )
	{
	      printf("%sVirtual Host%s: %s\n", 
		      prefix, suffix, HTMLEncode(getenv("HTTP_HOST")));
	}
	
	if ( MSG_HTMLMessages )
	{
		printf("</DL>\n");
		printf("<P>\n");
		printf("<DL>\n");
		printf("<DT><B>Request Data:</B>\n");
		printf("<P>\n");
	}
	else
	{
		printf("\n");
		MSG_BoxedText("Request Data:");
		printf("\n");
	}
	
	if ( getenv("HTTP_USER_AGENT") )
	{
		printf("%sUser Agent/Browser%s: %s\n", 
			prefix, suffix, HTMLEncode(getenv("HTTP_USER_AGENT")));
	}
	if ( getenv("REQUEST_METHOD") )
	{
		printf("%sRequest Method%s: %s\n", 
			prefix, suffix, HTMLEncode(getenv("REQUEST_METHOD")));
	}
	if ( getenv("REMOTE_HOST") )
	{
		printf("%sRemote Host%s: %s\n", 
			prefix, suffix, HTMLEncode(getenv("REMOTE_HOST")));
	}
	if ( getenv("REMOTE_ADDR") )
	{
		printf("%sRemote Address%s: %s\n", 
			prefix, suffix, HTMLEncode(getenv("REMOTE_ADDR")));
	}
	if ( getenv("REMOTE_PORT") )
	{
		printf("%sRemote Port%s: %s\n", 
			prefix, suffix, HTMLEncode(getenv("REMOTE_PORT")));
	}
	if ( getenv("REMOTE_USER") )
	{
		printf("%sRemote User%s: %s\n", 
			prefix, suffix, HTMLEncode(getenv("REMOTE_USER")));
	}
	if ( getenv("QUERY_STRING") )
	{
		if ( strlen(getenv("QUERY_STRING")) > 0)
		{	
			printf("%sQuery String%s: %s\n", 
				prefix, suffix, HTMLEncode(getenv("QUERY_STRING")));
		}
	}
	if ( ! MSG_QuietErrors && getenv("PATH_INFO") )
	{
		if ( strlen(getenv("PATH_INFO")) > 0)
		{	
			printf("%sExtra Path Info%s: %s\n", 
				prefix, suffix, HTMLEncode(getenv("PATH_INFO")));
		}
	}
	if ( getenv("HTTP_REFERRER") )
	{
		printf("%sReferring Page%s: %s\n", 
			prefix, suffix, HTMLEncode(getenv("HTTP_REFERRER")));
	}
	if ( getenv("HTTP_REFERER") )
	{
		printf("%sReferring Page%s: %s\n", 
			prefix, suffix, HTMLEncode(getenv("HTTP_REFERER")));
	}


	if ( MSG_HTMLMessages )
	{
		printf("</DL>\n");
	}
}