MCPcopy
hub / github.com/dronesploit/dronesploit / run

Method run

dronesploit/_src/commands/wifi.py:120–155  ·  view source on GitHub ↗
(self, interface)

Source from the content-addressed store, hash-verified

118 return self.console.root.interfaces
119
120 def run(self, interface):
121 i = interface
122 if self.console.state['INTERFACES'][i][0]:
123 # turn off monitor mode
124 self.console._jobs.run("sudo airmon-ng stop {}".format(i))
125 self.logger.info("{} set back to managed mode".format(i))
126 else:
127 before = set(self.console.root.interfaces)
128 # turn off the targeted interface
129 self.console._jobs.run("sudo airmon-ng stop {}".format(i))
130 # kill processes using this interface
131 self.console._jobs.run("sudo airmon-ng check kill")
132 # turn on monitor mode ; this will rename the interface
133 out, err = self.console._jobs.run("sudo airmon-ng start {}".format(i), stdin="y\n")
134 new, name = None, None
135 for line in out.split("\n"):
136 if "monitor mode" in line:
137 m = re.search(r"\[([a-z]+\d+)\](\w+)", line)
138 if m is not None:
139 name, new = m.group(1), m.group(2)
140 break
141 if new is None:
142 self.logger.error("Could not set {} to monitor mode".format(i))
143 return
144 after = set(self.console.root.interfaces)
145 new = list(after - before)[0] #FIXME: empty list when problem with interface half-set
146 self.logger.info("{} set to monitor mode on {}".format(i, new))
147 # ensure the interface is not soft-blocked
148 out, _ = self.console._jobs.run("sudo rfkill list")
149 for line in out.splitlines():
150 parts = line.split(":", 2)
151 if parts[1].strip() == name:
152 self.console._jobs.run("sudo rfkill unblock %s" % parts[0])
153 self.console._jobs.run("service network-manager restart")
154 self.console.root.interfaces # this refreshes the state with INTERFACES
155 Entity.check()
156
157 def validate(self, interface):
158 if interface not in self.console.root.interfaces:

Callers

nothing calls this directly

Calls 1

runMethod · 0.45

Tested by

no test coverage detected