-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve pwnup template, gdbserver detection #1148
Changes from 3 commits
27e6d37
256a0a6
2e90a2f
c689358
649db23
9c41c76
1b91904
662e351
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -131,10 +131,9 @@ def start(argv=[], *a, **kw): | |||||||||||||||
%endif | ||||||||||||||||
gdbscript = ''' | ||||||||||||||||
%if ctx.binary: | ||||||||||||||||
set sysroot | ||||||||||||||||
%if 'main' in ctx.binary.symbols: | ||||||||||||||||
break *0x{exe.symbols.main:x} | ||||||||||||||||
%else: | ||||||||||||||||
break *0x{exe.entry:x} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to remain. In the event symbols are unavailable, In the event that the binary is PIE (and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting an invalid breakpoint in the gdbscript appears to be an error:
I still end up in
|
||||||||||||||||
tbreak main | ||||||||||||||||
%endif | ||||||||||||||||
%endif | ||||||||||||||||
continue | ||||||||||||||||
|
@@ -161,6 +160,8 @@ continue | |||||||||||||||
|
||||||||||||||||
io = start() | ||||||||||||||||
|
||||||||||||||||
if args.GDB: | ||||||||||||||||
log.info(io.recvline()) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be added in Lines 782 to 783 in 20cb049
The issue is that doesn't actually happen all of the time -- only for certain (newer?) versions of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try adding it after that if statement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see there's already been done some handling for this in Lines 465 to 469 in 20cb049
When running locally There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When running locally, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. I've adjusted the code in |
||||||||||||||||
%if not quiet: | ||||||||||||||||
# shellcode = asm(shellcraft.sh()) | ||||||||||||||||
# payload = fit({ | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC,
set sysroot
with no arguments is a no-op. Update: Nope, it's worse.set sysroot /
(which I think you meant?) is incorrect for SSH-forwarded GDB sessions and Android devices.set sysroot
will also break for foreign-architecture binaries which are emulated under QEMU:pwntools/pwnlib/gdb.py
Lines 424 to 430 in 20cb049
Finally, you don't want to set the sysroot in your GDB script. Pass the
sysroot=
argument into thegdb.debug()
orgdb.attach()
call, that's what it's there for. (Side bar, we don't actually invokeset sysroot
for native-arch binaries, even if it's provided. This is a small bug.)You might want to expose a
--sysroot
argument topwn template
to do this conditionally.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I don't use
set sysroot
I get the following error:The right side is with
set sysroot
, the left without, both includetbreak main
andcontinue
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you run your script with
DEBUG
to see the actualgdbscript
being executed? (i.e.python foo.py LOCAL GDB DEBUG
).Can you also provide the first line of
gdb --version
and all ofgdb --configuration
?EDIT: And
gdbserver --version
.Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the output of
./exploit.py GDB LOCAL DEBUG