📄 html_output.c
字号:
else if(result == WARNING_PRESENT)
fprintf(file, "\t<td class=default width=\"40%%\">Security warning(s) found</td></tr>\n");
else if(result == NOTE_PRESENT)
fprintf(file, "\t<td class=default width=\"40%%\">Security note(s) found</td></tr>\n");
else fprintf(file, "\t<td class=default width=\"40%%\">No noticeable information found</td></tr>\n");
efree(&href);
h = h->next;
}
fprintf(file, "</tbody></table></td></tr></tbody></table>\n\n");
/* Finish printing Host list */
/* Enter crazy loop for hosts and specific issues */
while(hosts && hosts->next)
{
char * hostname;
char * port;
char * desc;
struct arglist * ports;
char * href;
char * name;
hostname = hosts->name;
href = portname_to_ahref(NULL, hostname);
fprintf(file, "<a name=\"%s\"></a>\n", href);
efree(&href);
name = portname_to_ahref("toc", hostname);
fprintf(file, "<a name=\"%s\"></a>\n", name);
efree(&name);
fprintf(file, "<div align=\"left\"><font size=-2><a href=\"#toc\">[ return to top ]</a></font></div><br><br>\n");
fprintf(file, "<table bgcolor=\"#a1a1a1\" border=0 cellpadding=0 cellspacing=0 width=\"60%%\">\n");
fprintf(file, "<tbody><tr><td>\n <table cellpadding=2 cellspacing=1 border=0 width=\"100%%\">\n");
fprintf(file, " <tbody>\n <tr>\n\t<td class=title colspan=3>Analysis of Host</td></tr>\n");
fprintf(file, " <tr>\n\t<td class=sub width=\"20%%\">Address of Host</td>\n");
fprintf(file, "\t<td class=sub width=\"30%%\">Port/Service</td>\n");
fprintf(file, "\t<td class=sub width=\"30%%\">Issue regarding Port</td></tr>\n");
ports = arg_get_value(hosts->value, "PORTS");
if(ports)
{
struct arglist * open = ports;
if(open->next)
{
while(open && open->next){
name = portname_to_ahref(open->name, hostname);
if(name)
{
if(arg_get_value(open->value, "REPORT") ||
arg_get_value(open->value, "INFO") ||
arg_get_value(open->value, "NOTE"))
{
fprintf(file, " <tr>\n\t<td class=default width=\"20%%\">%s</td>\n", hostname);
fprintf(file, "\t<td class=default width=\"30%%\"><a href=\"#%s\">%s</a></td>\n",
name, open->name);
if(arg_get_value(open->value, "REPORT")) fprintf(file, "\t<td class=default width=\"30%%\"><font color=red>Security hole found</font></td></tr>\n");
else if(arg_get_value(open->value, "INFO")) fprintf(file, "\t<td class=default width=\"30%%\">Security warning(s) found</td></tr>\n");
else fprintf(file, "\t<td class=default width=\"30%%\">Security notes found</td></tr>\n");
}
else {
fprintf(file, " <tr>\n\t<td class=default width=\"20%%\">%s</td>\n", hostname);
fprintf(file, "\t<td class=default width=\"30%%\">%s</td>\n\t<td class=default width=\"30%%\">No Information</td></tr>\n", open->name);
}
efree(&name);
}
else {
fprintf(file, " <tr>\n\t<td class=default width=\"20%%\">%s</td>\n", hostname);
fprintf(file, "\t<td class=default width=\"30%%\">%s</td>\n\t<td class=default width=\"30%%\">No Information</td></tr>\n", open->name);
}
open = open->next;
}
fprintf(file, "</tbody></table></td></tr></tbody></table><br><br>\n");
}
fprintf(file, "<table bgcolor=\"#a1a1a1\" cellpadding=0 cellspacing=0 border=0 width=\"75%%\">\n");
fprintf(file, "<tbody><tr><td>\n");
fprintf(file, "\t<table cellpadding=2 cellspacing=1 border=0 width=\"100%%\">\n");
fprintf(file, "\t\t<td class=title colspan=3>Security Issues and Fixes: %s</td></tr>\n", hostname);
fprintf(file, "\t\t<tr>\n\t<td class=sub width=\"10%%\">Type</td>\n");
fprintf(file, "\t\t<td class=sub width=\"10%%\">Port</td>\n");
fprintf(file, "\t\t<td class=sub width=\"80%%\">Issue and Fix</td></tr>\n");
/*
* Write the summary of the open ports here
*/
while(ports && ports->next)
{
struct arglist * report;
struct arglist * info;
struct arglist * note;
port = ports->name;
report = arg_get_value(ports->value, "REPORT");
if(report)while(report && report->next)
{
if(strlen(report->value))
{
/*
* Convert the \n to <p>
*/
desc = convert_cr_to_html(report->value);
name = portname_to_ahref("toc", hostname);
efree(&name);
fprintf(file, "\t\t<tr>\n\t<td valign=top class=default width=\"10%%\"><font color=red>Vulnerability</font></td>\n");
name = portname_to_ahref(ports->name, hostname);
fprintf(file, "\t\t<td valign=top class=default width=\"10%%\"><a name=\"%s\"></a>%s</td>\n", name, port);
efree(&name);
fprintf(file, "\t\t<td class=default width=\"80%%\">");
print_data_with_links(file, desc, report->name);
fprintf(file, "\t</td></tr>\n");
efree(&desc);
}
report = report->next;
}
info = arg_get_value(ports->value, "INFO");
if(info)while(info && info->next)
{
if(strlen(info->value))
{
/*
* Convert the \n to <p>
*/
desc = convert_cr_to_html(info->value);
name = portname_to_ahref("toc", hostname);
efree(&name);
fprintf(file, " <tr>\t\n<td valign=top class=default width=\"10%%\">Warning</td>\n");
name = portname_to_ahref(ports->name, hostname);
fprintf(file, "\t<td valign=top class=default width=\"10%%\"><a name=\"%s\"></a>%s</td>\n", name, port);
efree(&name);
fprintf(file, "\t<td class=default width=\"80%%\">");
print_data_with_links(file, desc, info->name);
fprintf(file, "</td></tr>\n");
efree(&desc);
}
info = info->next;
}
note = arg_get_value(ports->value, "NOTE");
if(note)while(note->next)
{
if(strlen(note->value))
{
char * name;
desc = emalloc(strlen(note->value)+1);
strncpy(desc, note->value, strlen(note->value));
/*
* Convert the \n to <p>
*/
desc = convert_cr_to_html(note->value);
name = portname_to_ahref("toc", hostname);
efree(&name);
fprintf(file, " <tr>\n\t<td valign=top class=default width=\"10%%\">Informational</td>\n");
name = portname_to_ahref(ports->name, hostname);
fprintf(file, "\t<td valign=top class=default width=\"10%%\"><a name=\"%s\"></a>%s</td>\n", name, port);
efree(&name);
fprintf(file, "\t<td class=default width=\"80%%\">");
print_data_with_links(file, desc, note->name);
fprintf(file, "</td></tr>\n");
efree(&desc);
}
note = note->next;
}
ports = ports->next;
}
}
fprintf(file, "</td></tr></tbody></table></td></tr></tbody></table>\n");
hosts = hosts->next;
}
fprintf(file, "<hr>\n");
fprintf(file, "<i>This file was generated by <a href=\"http://www.xfocus.org\">");
fprintf(file, "Nasl For Windows</a>, the open-sourced security scanner.</i>\n");
fprintf(file, "</BODY>\n");
fprintf(file, "</HTML>\n");
fclose(file);
return(0);
}
void summary_to_file(FILE *file, struct arglist *hosts)
{
fprintf(file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
fprintf(file, "<HTML>\n");
fprintf(file, " <HEAD>\n");
fprintf(file, " <TITLE>Nasl For Windows Scan Report</TITLE>\n");
fprintf(file, " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"iso-8859-1\">\n");
fprintf(file, " <style type=\"text/css\">\n");
fprintf(file, " <!--\n");
fprintf(file, " BODY {\n\tBACKGROUND-COLOR: #ffffff\n }\n");
fprintf(file, " A {\tTEXT-DECORATION: none }\n");
fprintf(file, " A:visited {\tCOLOR: #0000cf; TEXT-DECORATION: none }\n");
fprintf(file, " A:link {\tCOLOR: #0000cf; TEXT-DECORATION: none }\n");
fprintf(file, " A:active {\tCOLOR: #0000cf; TEXT-DECORATION: underline }\n");
fprintf(file, " A:hover {\tCOLOR: #0000cf; TEXT-DECORATION: underline }\n");
fprintf(file, " OL {\tCOLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }\n");
fprintf(file, " UL {\tCOLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }\n");
fprintf(file, " P {\tCOLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }\n");
fprintf(file, " BODY {\tCOLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }\n");
fprintf(file, " TD {\tCOLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }\n");
fprintf(file, " TR {\tCOLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }\n");
fprintf(file, " TH {\tCOLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }\n");
fprintf(file, " FONT.title {\tBACKGROUND-COLOR: white; COLOR: #363636; FONT-FAMILY: \
tahoma,helvetica,verdana,lucida console,utopia; FONT-SIZE: 10pt; FONT-WEIGHT: bold }\n");
fprintf(file, " FONT.sub {\tBACKGROUND-COLOR: white; COLOR: #000000; FONT-FAMILY: \
tahoma,helvetica,verdana,lucida console,utopia; FONT-SIZE: 10pt }\n");
fprintf(file, " FONT.layer {\tCOLOR: #ff0000; FONT-FAMILY: courrier,sans-serif,arial,helvetica; FONT-SIZE: 8pt; TEXT-ALIGN: left }\n");
fprintf(file, " TD.title {\tBACKGROUND-COLOR: #A2B5CD; COLOR: #555555; FONT-FAMILY: \
tahoma,helvetica,verdana,lucida console,utopia; FONT-SIZE: 10pt; FONT-WEIGHT: bold; HEIGHT: 20px; TEXT-ALIGN: right }\n");
fprintf(file, " TD.sub {\tBACKGROUND-COLOR: #DCDCDC; COLOR: #555555; FONT-FAMILY: \
tahoma,helvetica,verdana,lucida console,utopia; FONT-SIZE: 10pt; FONT-WEIGHT: bold; HEIGHT: 18px; TEXT-ALIGN: left }\n");
fprintf(file, " TD.content {\tBACKGROUND-COLOR: white; COLOR: #000000; FONT-FAMILY: \
tahoma,arial,helvetica,verdana,lucida console,utopia; FONT-SIZE: 8pt; TEXT-ALIGN: left; VERTICAL-ALIGN: middle }\n");
fprintf(file, " TD.default {\tBACKGROUND-COLOR: WHITE; COLOR: #000000; FONT-FAMILY: \
tahoma,arial,helvetica,verdana,lucida console,utopia; FONT-SIZE: 8pt; }\n");
fprintf(file, " TD.border {\tBACKGROUND-COLOR: #cccccc; COLOR: black; FONT-FAMILY: \
tahoma,helvetica,verdana,lucida console,utopia; FONT-SIZE: 10pt; HEIGHT: 25px }\n");
fprintf(file, " TD.border-HILIGHT {\tBACKGROUND-COLOR: #ffffcc; COLOR: black; FONT-FAMILY: \
verdana,arial,helvetica,lucida console,utopia; FONT-SIZE: 10pt; HEIGHT: 25px }\n");
fprintf(file, "-->\n</style>\n");
fprintf(file, "</HEAD>\n");
fprintf(file, "<BODY>\n");
fprintf(file, "<table bgcolor=\"#a1a1a1\" border=0 cellpadding=0 cellspacing=0 width=\"95%%\">\n");
fprintf(file, "<tbody>\n\t<tr><td>\n<table border=0 cellpadding=2 cellspacing=1 width=\"100%%\">\n");
fprintf(file, "\t<tbody>\n <tr>\n");
fprintf(file, "\t<td class=title>Nasl For Windows Scan Report</td></tr>\n");
fprintf(file, " <tr>\n\t<td class=content>This report gives details on hosts that were tested\n");
fprintf(file, "\t\tand issues that were found. Please follow the recommended\n");
fprintf(file, "\t\tsteps and procedures to eradicate these threats.\n");
fprintf(file, "</td></tr></tbody></table></td></tr></tbody></table><br>\n");
fprintf(file, "\n");
/*
* Write a (small) summary Hosts that are up, holes/warnings ect.
*/
fprintf(file, "<table bgcolor=\"#a1a1a1\" border=0 cellpadding=0 cellspacing=0 width=\"60%%\">\n");
fprintf(file, "<tbody><tr><td>\n");
fprintf(file, " <table border=0 cellpadding=2 cellspacing=1 width=\"100%%\">\n <tbody>\n");
fprintf(file, " <tr>\n\t<td class=title colspan=2>Scan Details</td></tr>\n");
fprintf(file, " <tr>\n\t<td class=default width=\"60%%\">Hosts which were alive and responding during test</td>\n");
fprintf(file, "\t<td class=default width=\"30%%\">%d</td></tr>\n",
arglist_length(hosts));
fprintf(file, " <tr>\n\t<td class=default width=\"60%%\">Number of security holes found</td>\n");
fprintf(file, "\t<td class=default width=\"30%%\">%d</td></tr>\n",
number_of_holes(hosts));
fprintf(file, " <tr>\n\t<td class=default width=\"60%%\">Number of security warnings found</td>\n");
fprintf(file, "\t<td class=default width=\"30%%\">%d</td></tr>\n",
number_of_warnings(hosts));
fprintf(file, "</tbody></table></td></tr></tbody></table><br><br>\n");
fprintf(file, "<a name=\"toc\"></a>");
fprintf(file, "<table bgcolor=\"#a1a1a1\" border=0 cellpadding=0 cellspacing=0 width=\"60%%\">\n");
fprintf(file, "<tbody><tr><td>\n <table border=0 cellpadding=2 cellspacing=1 width=\"100%%\">\n");
fprintf(file, " <tbody>\n <tr>\n\t<td class=title colspan=2>Host List</td></tr>\n");
fprintf(file, " <tr>\n\t<td class=sub width=\"60%%\">Host(s)</td>\n");
fprintf(file, "\t<td class=sub width=\"40%%\">Possible Issue</td></tr>\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -