mirror of
https://github.com/nmap/nmap.git
synced 2026-01-17 20:09:02 +00:00
merge soc07 r4804 - misc. NSE improvements
This commit is contained in:
@@ -99,6 +99,8 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include <string>
|
||||
|
||||
class NmapOps {
|
||||
public:
|
||||
NmapOps();
|
||||
|
||||
7
Target.h
7
Target.h
@@ -105,7 +105,11 @@
|
||||
|
||||
#include "nmap.h"
|
||||
#include "FingerPrintResults.h"
|
||||
|
||||
#ifndef NOLUA
|
||||
#include "nse_main.h"
|
||||
#endif
|
||||
|
||||
#include "reason.h"
|
||||
|
||||
#ifndef INET6_ADDRSTRLEN
|
||||
@@ -240,7 +244,10 @@ class Target {
|
||||
struct timeout_info to;
|
||||
char *hostname; // Null if unable to resolve or unset
|
||||
|
||||
#ifndef NOLUA
|
||||
ScriptResults scriptResults;
|
||||
#endif
|
||||
|
||||
state_reason_t reason;
|
||||
|
||||
private:
|
||||
|
||||
4
nmap.cc
4
nmap.cc
@@ -110,7 +110,11 @@
|
||||
#include "traceroute.h"
|
||||
#include "nmap_tty.h"
|
||||
#include "nmap_dns.h"
|
||||
|
||||
#ifndef NOLUA
|
||||
#include "nse_main.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include "winfix.h"
|
||||
#endif
|
||||
|
||||
19
output.cc
19
output.cc
@@ -680,8 +680,12 @@ void printportoutput(Target *currenths, PortList *plist) {
|
||||
for( ssr_iter = current->scriptResults.begin();
|
||||
ssr_iter != current->scriptResults.end();
|
||||
ssr_iter++) {
|
||||
char* xml_id= xml_convert((*ssr_iter).id);
|
||||
char* xml_scriptoutput= xml_convert((*ssr_iter).output);
|
||||
log_write(LOG_XML, "<script id=\"%s\" output=\"%s\" />",
|
||||
(*ssr_iter).id, (*ssr_iter).output);
|
||||
xml_id, xml_scriptoutput);
|
||||
free(xml_id);
|
||||
free(xml_scriptoutput);
|
||||
|
||||
char* script_output = formatScriptOutput((*ssr_iter));
|
||||
Tbl->addItem(rowno, 0, true, true, script_output);
|
||||
@@ -719,6 +723,7 @@ log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "%d service%s unrecognized despite ret
|
||||
log_flush_all();
|
||||
}
|
||||
|
||||
#ifndef NOLUA
|
||||
char* formatScriptOutput(struct script_scan_result ssr) {
|
||||
char* c_result;
|
||||
std::string result = std::string();
|
||||
@@ -756,6 +761,7 @@ char* formatScriptOutput(struct script_scan_result ssr) {
|
||||
|
||||
return c_result;
|
||||
}
|
||||
#endif /* NOLUA */
|
||||
|
||||
char* xml_convert (const char* str) {
|
||||
char *temp, ch=0, prevch = 0, *p;
|
||||
@@ -1693,22 +1699,29 @@ void printserviceinfooutput(Target *currenths) {
|
||||
log_flush_all();
|
||||
}
|
||||
|
||||
#ifndef NOLUA
|
||||
void printhostscriptresults(Target *currenths) {
|
||||
ScriptResults::iterator iter;
|
||||
char* script_output;
|
||||
char* script_output, *xml_id, *xml_scriptoutput;
|
||||
|
||||
if(currenths->scriptResults.size() > 0) {
|
||||
log_write(LOG_XML, "<hostscript>");
|
||||
log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "\nHost script results:\n");
|
||||
for(iter = currenths->scriptResults.begin(); iter != currenths->scriptResults.end(); iter++) {
|
||||
xml_id = xml_convert((*iter).id);
|
||||
xml_scriptoutput= xml_convert((*iter).output);
|
||||
log_write(LOG_XML, "<script id=\"%s\" output=\"%s\" />",
|
||||
(*iter).id, (*iter).output);
|
||||
xml_id, xml_scriptoutput);
|
||||
script_output = formatScriptOutput((*iter));
|
||||
log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "%s\n", script_output);
|
||||
free(script_output);
|
||||
free(xml_id);
|
||||
free(xml_scriptoutput);
|
||||
}
|
||||
log_write(LOG_XML, "</hostscript>");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Prints a status message while the program is running */
|
||||
void printStatusMessage() {
|
||||
|
||||
@@ -103,7 +103,10 @@
|
||||
|
||||
#include <map>
|
||||
#include "nbase.h"
|
||||
#ifndef NOLUA
|
||||
#include "nse_main.h"
|
||||
#endif
|
||||
|
||||
#include "reason.h"
|
||||
|
||||
/* port states */
|
||||
@@ -224,7 +227,9 @@ class Port {
|
||||
int confidence; /* How sure are we about the state? */
|
||||
state_reason_t reason;
|
||||
|
||||
#ifndef NOLUA
|
||||
ScriptResults scriptResults;
|
||||
#endif
|
||||
|
||||
private:
|
||||
int rpc_status; /* RPC_STATUS_UNTESTED means we haven't checked
|
||||
|
||||
@@ -56,6 +56,10 @@ action = function(host, port)
|
||||
|
||||
if title ~= nil then
|
||||
result = string.gsub(title , "[\n\r\t]", "")
|
||||
if string.len(title) > 50 then
|
||||
nmap.print_debug_unformatted("showHTMLTitle.nse: title was truncated!");
|
||||
result = string.sub(result, 1, 62) .. "..."
|
||||
end
|
||||
else
|
||||
result = "Site doesn't have a title."
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user