offlinemark / poet

[unmaintained] Post-exploitation tool
MIT License
183 stars 55 forks source link

add build system support for optimized bytecode #48

Closed offlinemark closed 9 years ago

offlinemark commented 9 years ago

we can specify -O when running py_compile to generate optimized pyo files that include less debug info (harder to reverse engineer). i was having trouble writing the makefile that would support this with multiple targets though

offlinemark commented 9 years ago

ok, after playing around some more here's what I've learned

http://stackoverflow.com/questions/17475035/what-is-the-difference-between-pyc-and-pyo-files-in-python

testing:

-OO

-rw-r--r--  1 mark  staff  8432 Mar 28 16:11 __main__.pyo
-rw-r--r--  1 mark  staff  5349 Mar 28 16:11 poet-client.zip
-rw-r--r--  1 mark  staff  6384 Mar 28 16:11 poet-server.zip
-rw-r--r--  1 mark  staff  1885 Mar 28 16:11 poetsocket.pyo

-O

-rw-r--r--  1 mark  staff  10139 Mar 28 16:07 __main__.pyo
-rw-r--r--  1 mark  staff   6342 Mar 28 16:07 poet-client.zip
-rw-r--r--  1 mark  staff   7163 Mar 28 16:07 poet-server.zip
-rw-r--r--  1 mark  staff   2308 Mar 28 16:07 poetsocket.pyo

-rw-r--r--  1 mark  staff  10139 Mar 28 16:08 __main__.pyc
-rw-r--r--  1 mark  staff   6342 Mar 28 16:08 poet-client.zip
-rw-r--r--  1 mark  staff   7163 Mar 28 16:08 poet-server.zip
-rw-r--r--  1 mark  staff   2308 Mar 28 16:08 poetsocket.pyc

seems like compiling with and without -O are exactly the same. however -OO introduces differences. also based from debugging, it seems like line numbers are always present (says ipdb), docstrings are gone in -OO

offlinemark commented 9 years ago

d28b092de0e48c58c3c2cce8baf38216d31d5160