Skip to content
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

Adding escaped hex output format to shellcraft -f option #765

Merged
merged 5 commits into from
Oct 14, 2016
Merged

Adding escaped hex output format to shellcraft -f option #765

merged 5 commits into from
Oct 14, 2016

Conversation

bstub
Copy link
Contributor

@bstub bstub commented Oct 12, 2016

While using shellcraft as a stand-alone utility to generate shellcode for PoC's, I found the python hex notation very useful.

Maybe someone else can use it too?

@zachriggle
Copy link
Member

I like the idea, but the implementation could be much simpler. Calling
print(repr(list)) does this simpler and more compatibly.

If it helps any, there is already a "string" option.

If you can switch from the manual hex escape to repr/list I can merge this.
On Wed, Oct 12, 2016 at 1:54 PM bstub notifications@github.com wrote:

While using shellcraft as a stand-alone utility to generate shellcode for
PoC's, I found the python hex notation very useful.

Maybe someone else can use it too?

You can view, comment on, or merge this pull request online at:

#765
Commit Summary

  • adding output format for python hex-notation

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#765, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAG0GI4Txrmo9Uc_NdngS37FIW1iH0haks5qzUkMgaJpZM4KVNaB
.

@br0ns
Copy link
Contributor

br0ns commented Oct 13, 2016

Also, this notation is not really Python specific. What about {e}scaped?

@bstub
Copy link
Contributor Author

bstub commented Oct 13, 2016

{e} is currently used by elf.

esc{a}ped --escaped ?

@br0ns
Copy link
Contributor

br0ns commented Oct 13, 2016

Right. I missed ELF since it not in the help text. Could you add it?

Also, I'm a little out of touch with Pwntools so I'll let @zachriggle or @idolf merge the PR.

@zachriggle
Copy link
Member

zachriggle commented Oct 13, 2016

Looks like it's still using '\\x%02x' instead of repr()

@bstub
Copy link
Contributor Author

bstub commented Oct 13, 2016

@br0ns - Sure, just added it.
@zachriggle - Yeah i know, just seemed less weird since _string already use the same syntax.

@tmfink
Copy link

tmfink commented Oct 13, 2016

A possible downside of using repr() is that printable characters will not
be slash X encoded. Depending on your preference, it may look strange to
have a mix of byte representations.

On Oct 13, 2016 1:03 PM, "Zach Riggle" notifications@github.com wrote:

Looks like it's still using '\x%02x' instead of repr()


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#765 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFBYuIYfr2mExjHcFSJpAvDqsLbBRZ22ks5qzo6CgaJpZM4KVNaB
.

@bstub
Copy link
Contributor Author

bstub commented Oct 13, 2016

@tmfink yes, {s}tring already does this.

@bstub bstub changed the title Adding output format for python hex-notation to shellcraft -f option Adding escaped hex output format to shellcraft -f option Oct 13, 2016
@zachriggle
Copy link
Member

Technically the s / string does not. It creates a C or PHP-compatible string.

@bstub
Copy link
Contributor Author

bstub commented Oct 13, 2016

C or PHP-compatible, it's still mixed.

I have nothing further to add.

@TethysSvensson
Copy link
Contributor

TethysSvensson commented Oct 13, 2016

@zachriggle: The current -f s is not c-compatible.

dev:~/git/pwntools> shellcraft -fs thumb.push 48
"O\xf00\x07\x80\xb4"

dev:~/git/pwntools> echo 'int main() { puts("O\xf00\x07\x80\xb4"); }' | gcc -x c -
<stdin>: In function ‘main’:
<stdin>:1:14: warning: implicit declaration of function ‘puts’ [-Wimplicit-function-declaration]
<stdin>:1:19: warning: hex escape sequence out of range
dev:~/git/pwntools> ./a.out | xxd
00000000: 4f0a                                     O.

C parses hex escapes in a strange way. I do not think repr is the way to go.

@zachriggle
Copy link
Member

@idolf it looks like I remembered incorrectly, -fs is for echo -e shell compatibility per the comments on #451

@TethysSvensson
Copy link
Contributor

I say we accept this in some form -- either by replacing the current -f s or by accepting this as it is.

@zachriggle zachriggle merged commit db03e7d into Gallopsled:dev Oct 14, 2016
@TethysSvensson TethysSvensson added this to the 3.3.0 milestone Nov 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants