diff --git a/docs/scripting.xml b/docs/scripting.xml
index d5250a36a..ef3ca2be6 100644
--- a/docs/scripting.xml
+++ b/docs/scripting.xml
@@ -1912,6 +1912,17 @@ host.os = {
+
+
+
+
+ If OS detection was performed, this is a string containing the OS
+ fingerprint for the host. The format is described in
+ .
+
+
+
+
diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc
index a9669962c..451f00983 100644
--- a/nse_nmaplib.cc
+++ b/nse_nmaplib.cc
@@ -220,19 +220,25 @@ void set_hostinfo(lua_State *L, Target *currenths) {
* result, we will use it in the scripts
* matches which aren't perfect are not needed in the scripts
*/
- if (currenths->osscanPerformed() && FPR != NULL &&
- FPR->overall_results == OSSCAN_SUCCESS && FPR->num_perfect_matches > 0 &&
- FPR->num_perfect_matches <= 8 )
- {
- int i;
- const OS_Classification_Results *OSR = FPR->getOSClassification();
+ if (currenths->osscanPerformed() && FPR != NULL) {
+ /* Set os_fp to the raw fingerprint. isGoodFP = false because we don't want
+ * submissions this way, but we could change this in the future (if we want
+ * submissions directly from NSE scripts, for instance)
+ */
+ nseU_setsfield(L, -1, "os_fp", (const char *) FPR->merge_fpr(currenths, false, false));
+ if (FPR->overall_results == OSSCAN_SUCCESS && FPR->num_perfect_matches > 0 &&
+ FPR->num_perfect_matches <= 8 )
+ {
+ int i;
+ const OS_Classification_Results *OSR = FPR->getOSClassification();
- lua_newtable(L);
- for (i = 0; i < FPR->num_perfect_matches; i++) {
- push_osmatch_table(L, FPR->matches[i], OSR);
- lua_rawseti(L, -2, i + 1);
+ lua_newtable(L);
+ for (i = 0; i < FPR->num_perfect_matches; i++) {
+ push_osmatch_table(L, FPR->matches[i], OSR);
+ lua_rawseti(L, -2, i + 1);
+ }
+ lua_setfield(L, -2, "os");
}
- lua_setfield(L, -2, "os");
}
}