MCPcopy Create free account
hub / github.com/AutoRecon/AutoRecon / execute

Method execute

autorecon/targets.py:154–225  ·  view source on GitHub ↗
(self, cmd, blocking=True, outfile=None, errfile=None, future_outfile=None)

Source from the content-addressed store, hash-verified

152
153 @final
154 async def execute(self, cmd, blocking=True, outfile=None, errfile=None, future_outfile=None):
155 target = self.target
156
157 # Create variables for command references.
158 address = target.address
159 addressv6 = target.address
160 ipaddress = target.ip
161 ipaddressv6 = target.ip
162 scandir = target.scandir
163 protocol = self.protocol
164 port = self.port
165 name = self.name
166
167 if not config['no_port_dirs']:
168 scandir = os.path.join(scandir, protocol + str(port))
169 os.makedirs(scandir, exist_ok=True)
170 os.makedirs(os.path.join(scandir, 'xml'), exist_ok=True)
171
172 # Special cases for HTTP.
173 http_scheme = 'https' if 'https' in self.name or self.secure is True else 'http'
174
175 nmap_extra = target.autorecon.args.nmap
176 if target.autorecon.args.nmap_append:
177 nmap_extra += ' ' + target.autorecon.args.nmap_append
178
179 if protocol == 'udp':
180 nmap_extra += ' -sU'
181
182 if target.ipversion == 'IPv6':
183 nmap_extra += ' -6'
184 if addressv6 == target.ip:
185 addressv6 = '[' + addressv6 + ']'
186 ipaddressv6 = '[' + ipaddressv6 + ']'
187
188 if config['proxychains'] and protocol == 'tcp':
189 nmap_extra += ' -sT'
190
191 plugin = inspect.currentframe().f_back.f_locals['self']
192 cmd = e(cmd)
193 tag = self.tag() + '/' + plugin.slug
194 plugin_tag = tag
195 if plugin.run_once_boolean:
196 plugin_tag = plugin.slug
197
198 info('Service scan {bblue}' + plugin.name + ' {green}(' + tag + '){rst} is running the following command against {byellow}' + address + '{rst}: ' + cmd, verbosity=2)
199
200 if outfile is not None:
201 outfile = os.path.join(scandir, e(outfile))
202
203 if errfile is not None:
204 errfile = os.path.join(scandir, e(errfile))
205
206 if future_outfile is not None:
207 future_outfile = os.path.join(scandir, e(future_outfile))
208
209 target.scans['services'][self][plugin_tag]['commands'].append([cmd, outfile if outfile is not None else future_outfile, errfile])
210
211 async with target.lock:

Callers

nothing calls this directly

Calls 4

tagMethod · 0.95
eFunction · 0.90
infoFunction · 0.90
executeMethod · 0.45

Tested by

no test coverage detected