Nmap mmouse-exec NSE Script


This page contains detailed information about how to use the mmouse-exec NSE script. For list of all NSE scripts, visit the Nmap NSE Library.

Select:
Overview
Error Messages

Script Overview


Script source code: https://github.com/nmap/nmap/tree/master/scripts/mmouse-exec.nse
Script categories: intrusive
Target service / protocol: mmouse, tcp
Target network port(s): 51010
List of CVEs: -

Script Description


The mmouse-exec.nse script connects to an RPA Tech Mobile Mouse server, starts an application and sends a sequence of keys to it. Any application that the user has access to can be started and the key sequence is sent to the application after it has been started.

The Mobile Mouse server runs on OS X, Windows and Linux and enables remote control of the keyboard and mouse from an iOS device. For more information:

The script has only been tested against OS X and will detect the remote OS and abort unless the OS is detected as Mac.

Mmouse-exec NSE Script Arguments


This is a full list of arguments supported by the mmouse-exec.nse script:

mmouse-exec.application

The application which is to be started at the server

mmouse-exec.delay

Delay in seconds to wait before sending the key sequence. (default: 3 seconds)

mmouse-exec.keys

The key sequence to send to the started application

mmouse-exec.password

The password needed to connect to the mobile mouse server

creds.global

Credentials to be returned by Credentials.getCredentials regardless of the service.

creds.[service]

Credentials to be returned by Credentials.getCredentials for [service]. E.g. creds.http=admin:password

- - -
To use these script arguments, add them to the Nmap command line using the --script-args arg1=value,[arg2=value,..] syntax. For example:

nmap --script=mmouse-exec --script-args mmouse-exec.application=value,mmouse-exec.delay=value <target>

Mmouse-exec NSE Script Example Usage


Here's an example of how to use the mmouse-exec.nse script:

nmap -p 51010 <host> --script mmouse-exec \
--script-args application='/bin/sh',keys='ping -c 5 127.0.0.1'

Mmouse-exec NSE Script Example Output


Here's a sample output from the mmouse-exec.nse script:

PORT      STATE SERVICE REASON
51010/tcp open  unknown syn-ack
| mmouse-exec:
|_  Attempted to start application "/bin/sh" and sent "ping -c 5 127.0.0.1"

Mmouse-exec NSE Script Example XML Output


There is no sample XML output for this module. However, by providing the -oX <file> option, Nmap will produce a XML output and save it in the file.xml file.

Author


  • Patrik Karlsson

References


See Also


Related NSE scripts to the mmouse-exec.nse script:

Visit Nmap NSE Library for more scripts.

The mmouse-exec.nse script may fail with the following error messages. Check for the possible causes by using the code snippets highlighted below found in the script source code. This can often times help in identifying the root cause of the problem.

Failed to receive data from server


Here is a relevant code snippet related to the "Failed to receive data from server" error message:

53:	local function receiveData(socket, cmd)
54:	  local status, data = ""
55:	  repeat
56:	    status, data = socket:receive_buf(match.pattern_limit("\04", 2048), true)
57:	    if ( not(status) ) then
58:	      return false, "Failed to receive data from server"
59:	    end
60:	  until( cmd == nil or data:match("^" .. cmd) )
61:	  return true, data
62:	end
63:	

Failed to send data to server


Here is a relevant code snippet related to the "Failed to send data to server" error message:

67:	  local suffix = "2".."\30".."2".."\04"
68:	  local auth = ("CONNECT\30%s\30%s\30%s\30%s"):format(password, devid, devname, suffix)
69:	
70:	  local status = socket:send(auth)
71:	  if ( not(status) ) then
72:	    return false, "Failed to send data to server"
73:	  end
74:	
75:	  local status, data = receiveData(socket)
76:	  if ( not(status) ) then
77:	    return false, "Failed to receive data from server"

Failed to receive data from server


Here is a relevant code snippet related to the "Failed to receive data from server" error message:

72:	    return false, "Failed to send data to server"
73:	  end
74:	
75:	  local status, data = receiveData(socket)
76:	  if ( not(status) ) then
77:	    return false, "Failed to receive data from server"
78:	  end
79:	
80:	  local success, os = data:match("^CONNECTED\30([^\30]*)\30([^\30]*)")
81:	
82:	  if ( success == "YES" ) then

Non MAC platform detected, script has only been tested on MAC


Here is a relevant code snippet related to the "Non MAC platform detected, script has only been tested on MAC" error message:

79:	
80:	  local success, os = data:match("^CONNECTED\30([^\30]*)\30([^\30]*)")
81:	
82:	  if ( success == "YES" ) then
83:	    if ( os ~= 'MAC' ) then
84:	      return false, "Non MAC platform detected, script has only been tested on MAC"
85:	    end
86:	    if ( not(socket:send("SETOPTION\30PRESENTATION\30".."1\04")) ) then
87:	      return false, "Failed to send request to server"
88:	    end
89:	    if ( not(socket:send("SETOPTION\30CLIPBOARDSYNC\30".."1\04")) ) then

Failed to send request to server


Here is a relevant code snippet related to the "Failed to send request to server" error message:

82:	  if ( success == "YES" ) then
83:	    if ( os ~= 'MAC' ) then
84:	      return false, "Non MAC platform detected, script has only been tested on MAC"
85:	    end
86:	    if ( not(socket:send("SETOPTION\30PRESENTATION\30".."1\04")) ) then
87:	      return false, "Failed to send request to server"
88:	    end
89:	    if ( not(socket:send("SETOPTION\30CLIPBOARDSYNC\30".."1\04")) ) then
90:	      return false, "Failed to send request to server"
91:	    end
92:	    return true

Failed to send request to server


Here is a relevant code snippet related to the "Failed to send request to server" error message:

85:	    end
86:	    if ( not(socket:send("SETOPTION\30PRESENTATION\30".."1\04")) ) then
87:	      return false, "Failed to send request to server"
88:	    end
89:	    if ( not(socket:send("SETOPTION\30CLIPBOARDSYNC\30".."1\04")) ) then
90:	      return false, "Failed to send request to server"
91:	    end
92:	    return true
93:	  end
94:	  return false, "Authentication failed"
95:	end

Authentication failed


Here is a relevant code snippet related to the "Authentication failed" error message:

89:	    if ( not(socket:send("SETOPTION\30CLIPBOARDSYNC\30".."1\04")) ) then
90:	      return false, "Failed to send request to server"
91:	    end
92:	    return true
93:	  end
94:	  return false, "Authentication failed"
95:	end
96:	
97:	local function processSwitchMode(socket, swmode)
98:	  local m, o, a1, a2, p = swmode:match("^(.-)\30(.-)\30(.-)\30(.-)\30(.-)\04$")
99:	  if ( m ~= "SWITCHMODE") then

Failed to parse SWITCHMODE


Here is a relevant code snippet related to the "Failed to parse SWITCHMODE" error message:

96:	
97:	local function processSwitchMode(socket, swmode)
98:	  local m, o, a1, a2, p = swmode:match("^(.-)\30(.-)\30(.-)\30(.-)\30(.-)\04$")
99:	  if ( m ~= "SWITCHMODE") then
100:	    stdnse.debug1("Unknown SWITCHMODE: %s %s", m, o)
101:	    return false, "Failed to parse SWITCHMODE"
102:	  end
103:	
104:	  local str = ("SWITCHED\30%s\30%s\30%s\04"):format(o, a1, a2)
105:	  local status = socket:send(str)
106:	  if ( not(status) ) then

Failed to send data to server


Here is a relevant code snippet related to the "Failed to send data to server" error message:

102:	  end
103:	
104:	  local str = ("SWITCHED\30%s\30%s\30%s\04"):format(o, a1, a2)
105:	  local status = socket:send(str)
106:	  if ( not(status) ) then
107:	    return false, "Failed to send data to server"
108:	  end
109:	  return true
110:	end
111:	
112:	local function executeCmd(socket, app, keys)

Failed to send data to server


Here is a relevant code snippet related to the "Failed to send data to server" error message:

111:	
112:	local function executeCmd(socket, app, keys)
113:	  local exec = ("SENDPROGRAMACTION\30RUN\30%s\04"):format(app)
114:	  local status = socket:send(exec)
115:	  if ( not(status) ) then
116:	    return false, "Failed to send data to server"
117:	  end
118:	
119:	  local status, data = receiveData(socket)
120:	  if ( not(status) ) then
121:	    return false, "Failed to receive data from server"

Failed to receive data from server


Here is a relevant code snippet related to the "Failed to receive data from server" error message:

116:	    return false, "Failed to send data to server"
117:	  end
118:	
119:	  local status, data = receiveData(socket)
120:	  if ( not(status) ) then
121:	    return false, "Failed to receive data from server"
122:	  end
123:	
124:	  if ( arg_delay ) then
125:	    stdnse.sleep(tonumber(arg_delay))
126:	  end

Failed to send data to the server


Here is a relevant code snippet related to the "Failed to send data to the server" error message:

126:	  end
127:	
128:	  if ( keys ) then
129:	    local cmd = ("KEYSTRING\30%s\n\04"):format(keys)
130:	    if ( not(socket:send(cmd)) ) then
131:	      return false, "Failed to send data to the server"
132:	    end
133:	  end
134:	  return true
135:	end
136:	

No application was specified (see %s.application)


Here is a relevant code snippet related to the "No application was specified (see %s.application)" error message:

141:	  local c = creds.Credentials:new(creds.ALL_DATA, host, port)
142:	  local credentials = c:getCredentials(creds.State.VALID + creds.State.PARAM)()
143:	  local password = arg_password or (credentials and credentials.pass) or ""
144:	
145:	  if ( not(arg_app) ) then
146:	    return fail(("No application was specified (see %s.application)"):format(SCRIPT_NAME))
147:	  end
148:	
149:	  if ( not(arg_keys) ) then
150:	    return fail(("No keys were specified (see %s.keys)"):format(SCRIPT_NAME))
151:	  end

No keys were specified (see %s.keys)


Here is a relevant code snippet related to the "No keys were specified (see %s.keys)" error message:

145:	  if ( not(arg_app) ) then
146:	    return fail(("No application was specified (see %s.application)"):format(SCRIPT_NAME))
147:	  end
148:	
149:	  if ( not(arg_keys) ) then
150:	    return fail(("No keys were specified (see %s.keys)"):format(SCRIPT_NAME))
151:	  end
152:	
153:	  local socket = nmap.new_socket()
154:	  socket:set_timeout(10000)
155:	  local status, err = socket:connect(host, port)

Failed to connect to server


Here is a relevant code snippet related to the "Failed to connect to server" error message:

152:	
153:	  local socket = nmap.new_socket()
154:	  socket:set_timeout(10000)
155:	  local status, err = socket:connect(host, port)
156:	  if ( not(status) ) then
157:	    return fail("Failed to connect to server")
158:	  end
159:	
160:	  status, err = authenticate(socket, password)
161:	  if ( not(status) ) then
162:	    return fail(err)

Failed to receive expected response from server


Here is a relevant code snippet related to the "Failed to receive expected response from server" error message:

163:	  end
164:	
165:	  local data
166:	  status, data = receiveData(socket, "SWITCHMODE")
167:	  if ( not(status) ) then
168:	    return fail("Failed to receive expected response from server")
169:	  end
170:	
171:	  if ( not(processSwitchMode(socket, data)) ) then
172:	    return fail("Failed to process SWITCHMODE command")
173:	  end

Failed to process SWITCHMODE command


Here is a relevant code snippet related to the "Failed to process SWITCHMODE command" error message:

167:	  if ( not(status) ) then
168:	    return fail("Failed to receive expected response from server")
169:	  end
170:	
171:	  if ( not(processSwitchMode(socket, data)) ) then
172:	    return fail("Failed to process SWITCHMODE command")
173:	  end
174:	
175:	  if ( not(executeCmd(socket, arg_app, arg_keys)) ) then
176:	    return fail("Failed to execute application")
177:	  end

Failed to execute application


Here is a relevant code snippet related to the "Failed to execute application" error message:

170:	
171:	  if ( not(processSwitchMode(socket, data)) ) then
172:	    return fail("Failed to process SWITCHMODE command")
173:	  end
174:	
175:	  if ( not(executeCmd(socket, arg_app, arg_keys)) ) then
176:	    return fail("Failed to execute application")
177:	  end
178:	
179:	  return ("\n  Attempted to start application "%s" and sent "%s""):format(arg_app, arg_keys)
180:	end

Version


This page has been created based on Nmap version 7.92.

Go back to menu.