Skip to content

Commit 03020fd

Browse files
author
Ekultek
committed
fixes issue #1210
1 parent 9b1b1cb commit 03020fd

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/exploitation/exploiter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def start_exploit(self, sep="*" * 10):
137137
)
138138

139139
cmd_template = (
140-
"sudo {use_ruby} {msf_path} -r {rc_script_path} -q"
140+
"{use_sudo} {use_ruby} {msf_path} -r {rc_script_path} -q"
141141
)
142142

143143
use_ruby = "ruby" if self.ruby_exec else ""
@@ -162,6 +162,7 @@ def start_exploit(self, sep="*" * 10):
162162
lhost = self.configuration[1]
163163
lport = self.configuration[2]
164164
rhost = host.strip()
165+
is_docker = "sudo" if lib.settings.we_dockered() else ""
165166

166167
current_rc_script_path = path.join(current_host_path, mod.replace("/", '-').strip())
167168
with open(current_rc_script_path, 'w') as f:
@@ -172,7 +173,8 @@ def start_exploit(self, sep="*" * 10):
172173
lhost=lhost,
173174
lport=lport,
174175
rhost=rhost,
175-
rhosts=rhost
176+
rhosts=rhost,
177+
use_sudo=is_docker
176178
))
177179

178180
with open(report_path, 'a') as f:

lib/settings.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,17 @@ def find_similar(command, internal, external):
491491
if exter.startswith(first_char):
492492
retval.append(exter)
493493
return retval
494+
495+
496+
def we_dockered():
497+
"""
498+
determine if we are inside a docker container or not
499+
"""
500+
try:
501+
with open("/proc/1/cgroup") as cgroup:
502+
searcher = re.compile("docker", re.I)
503+
if searcher.search(cgroup.read()) is not None:
504+
return True
505+
return False
506+
except Exception:
507+
return False

0 commit comments

Comments
 (0)