Skip to content

Commit 87e37ee

Browse files
authored
setresuid: generic implementation for all arches (#2093)
* setresuid: generic implementation for all arches Closes #1324 * Update changelog
1 parent e53c7f7 commit 87e37ee

File tree

7 files changed

+110
-0
lines changed

7 files changed

+110
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ The table below shows which release corresponds to each branch, and what date th
6868

6969
- [#2062][2062] make pwn cyclic -l work with entry larger than 4 bytes
7070
- [#2092][2092] shellcraft: dup() is now called dupio() consistently across all supported arches
71+
- [#2093][2093] setresuid() in shellcraft uses current euid by default
7172

7273
[2062]: https://github.com/Gallopsled/pwntools/pull/2062
7374
[2092]: https://github.com/Gallopsled/pwntools/pull/2092
75+
[2093]: https://github.com/Gallopsled/pwntools/pull/2093
7476

7577
## 4.9.0 (`beta`)
7678

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% from pwnlib.shellcraft import common %>
2+
<% from pwnlib.shellcraft.aarch64 import mov, linux %>
3+
<%page args="ruid=None, euid=None, suid=None"/>
4+
<%docstring>
5+
Args: [ruid = geteuid(), euid = ruid, suid = ruid]
6+
Sets real, effective and saved user ids to given values
7+
</%docstring>
8+
9+
%if ruid is None:
10+
${linux.geteuid()}
11+
<% ruid = 'x0' %>
12+
%endif
13+
<%
14+
if euid is None: euid = ruid
15+
if suid is None: suid = ruid
16+
%>
17+
18+
${linux.syscalls.setresuid(ruid, euid, suid)}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% from pwnlib.shellcraft import common %>
2+
<% from pwnlib.shellcraft.amd64 import mov, linux %>
3+
<%page args="ruid=None, euid=None, suid=None"/>
4+
<%docstring>
5+
Args: [ruid = geteuid(), euid = ruid, suid = ruid]
6+
Sets real, effective and saved user ids to given values
7+
</%docstring>
8+
9+
%if ruid is None:
10+
${linux.geteuid()}
11+
<% ruid = 'eax' %>
12+
%endif
13+
<%
14+
if euid is None: euid = ruid
15+
if suid is None: suid = ruid
16+
%>
17+
18+
${linux.syscalls.setresuid(ruid, euid, suid)}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% from pwnlib.shellcraft import common %>
2+
<% from pwnlib.shellcraft.arm import mov, linux %>
3+
<%page args="ruid=None, euid=None, suid=None"/>
4+
<%docstring>
5+
Args: [ruid = geteuid(), euid = ruid, suid = ruid]
6+
Sets real, effective and saved user ids to given values
7+
</%docstring>
8+
9+
%if ruid is None:
10+
${linux.geteuid()}
11+
<% ruid = 'r0' %>
12+
%endif
13+
<%
14+
if euid is None: euid = ruid
15+
if suid is None: suid = ruid
16+
%>
17+
18+
${linux.syscalls.setresuid(ruid, euid, suid)}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% from pwnlib.shellcraft import common %>
2+
<% from pwnlib.shellcraft.i386 import mov, linux %>
3+
<%page args="ruid=None, euid=None, suid=None"/>
4+
<%docstring>
5+
Args: [ruid = geteuid(), euid = ruid, suid = ruid]
6+
Sets real, effective and saved user ids to given values
7+
</%docstring>
8+
9+
%if ruid is None:
10+
${linux.geteuid()}
11+
<% ruid = 'eax' %>
12+
%endif
13+
<%
14+
if euid is None: euid = ruid
15+
if suid is None: suid = ruid
16+
%>
17+
18+
${linux.syscalls.setresuid(ruid, euid, suid)}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% from pwnlib.shellcraft import common %>
2+
<% from pwnlib.shellcraft.mips import mov, linux %>
3+
<%page args="ruid=None, euid=None, suid=None"/>
4+
<%docstring>
5+
Args: [ruid = geteuid(), euid = ruid, suid = ruid]
6+
Sets real, effective and saved user ids to given values
7+
</%docstring>
8+
9+
%if ruid is None:
10+
${linux.geteuid()}
11+
<% ruid = '$v0' %>
12+
%endif
13+
<%
14+
if euid is None: euid = ruid
15+
if suid is None: suid = ruid
16+
%>
17+
18+
${linux.syscalls.setresuid(ruid, euid, suid)}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% from pwnlib.shellcraft import common %>
2+
<% from pwnlib.shellcraft.thumb import mov, linux %>
3+
<%page args="ruid=None, euid=None, suid=None"/>
4+
<%docstring>
5+
Args: [ruid = geteuid(), euid = ruid, suid = ruid]
6+
Sets real, effective and saved user ids to given values
7+
</%docstring>
8+
9+
%if ruid is None:
10+
${linux.geteuid()}
11+
<% ruid = 'r0' %>
12+
%endif
13+
<%
14+
if euid is None: euid = ruid
15+
if suid is None: suid = ruid
16+
%>
17+
18+
${linux.syscalls.setresuid(ruid, euid, suid)}

0 commit comments

Comments
 (0)