Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shellcraft/*/freebsd: match linux in switching cs (#2232)
* shellcraft/*/freebsd: match linux in switching cs * shellcraft: note trashed registers in switching cs
- Loading branch information
Showing
4 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
pwnlib/shellcraft/templates/amd64/freebsd/amd64_to_i386.asm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%docstring>Returns code to switch from amd64 to i386 mode. Trashes eax, ecx, edx. | ||
|
||
Note that you most surely want to set up some stack (and place this code) | ||
in low address space before (or afterwards).</%docstring> | ||
.code64 | ||
call $+4 | ||
.byte 0xc0 /* inc eax */ | ||
mov byte ptr [rsp+4], 0x33 /* This is the segment we want to go to */ | ||
retfd | ||
.code32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
<% from pwnlib.shellcraft import common %> | ||
<%docstring>Returns code to switch from i386 to amd64 mode.</%docstring> | ||
<% helper, end = common.label("helper"), common.label("end") %> | ||
<%docstring>Returns code to switch from i386 to amd64 mode. Trashes eax.</%docstring> | ||
.code32 | ||
push 0x43 /* This is the segment we want to go to */ | ||
/* "db 0xff; sub al,0x24" is "jmp far [esp]" by chance */ | ||
call $+4 | ||
${helper}: | ||
.byte 0xc0 | ||
add dword ptr [esp], ${end} - ${helper} | ||
jmp far [esp] | ||
${end}: | ||
sub al, 0x24 | ||
.code64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters