IzeBerg 128 Posted August 16, 2013 (edited) Собственно вопрос припёк меня давно. Есть-ли какие-то утилиты/способы декомпилировать и компилировать *.pyc файлы? P.s. Гугл не помог, кидал в какие-то онлайн-декомпиляторы, но там ограничение 10кб. Edited August 16, 2013 by IzeBerg Quote Share this post Link to post Short link Share on other sites
Mr A 750 #89959 Posted August 16, 2013 Гугл помог, первая и вторая ссылка у меня, например. 7 6 Quote Share this post Link to post Short link Share on other sites
IzeBerg 128 #89967 Posted August 16, 2013 (edited) Гугл помог, первая и вторая ссылка у меня, например. А ссылки эти можно? Просто я уже не первый день ищу. depython.net не катит, там ограничение Edited August 16, 2013 by IzeBerg Quote Share this post Link to post Short link Share on other sites
Mr A 750 #89975 Posted August 16, 2013 https://www.google.ru/search?ie=UTF-8&hl=ru&q=%D0%B4%D0%B5%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%82%D0%BE%D1%80%20python Quote Share this post Link to post Short link Share on other sites
coJlHe4Hblu_noH4uk 141 #90301 Posted August 18, 2013 Гугл помог, первая и вторая ссылка у меня, например. Так если вы авторизованы в гугле, результаты поиска строятся по вашим увлечениям, могло и не выдать человеку) Quote Share this post Link to post Short link Share on other sites
IzeBerg 128 #92600 Posted August 28, 2013 https://www.google.ru/search?ie=UTF-8&hl=ru&q=%D0%B4%D0%B5%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%82%D0%BE%D1%80%20python Неа не помогло. Нашел какие-то декомпиляторы, но никакой инструкции к ним нет, через коммандную строку рыл их ихние команды, ничего про декомпиляцию не сказано. Quote Share this post Link to post Short link Share on other sites
Yupi 505 #92984 Posted August 30, 2013 Где-то уже была тема по декомпиляторам питона в разделе, но не могу найти) Вот декомпиляторы Python которые удалось вспомнить. https://github.com/Mysterie/uncompyle2 https://code.google.com/p/unpyc3/ https://github.com/gstarnberger/uncompyle https://code.google.com/p/unpyc/ http://sourceforge.net/projects/easypythondecompiler/ 1 Quote Share this post Link to post Short link Share on other sites
Slava7572 1,685 #93040 Posted August 30, 2013 А есть где нибудь гайдик как ими пользоваться? Quote Share this post Link to post Short link Share on other sites
Yupi 505 #93063 Posted August 30, 2013 А есть где нибудь гайдик как ими пользоваться? Там с сорцами есть сопутствующая дока. Вот например для uncompyle2: https://github.com/Mysterie/uncompyle2/blob/master/README.rst uncompyle2 ========== A Python 2.5, 2.6, 2.7 byte-code decompiler, written in Python 2.7 Introduction ------------ 'uncompyle2' converts Python byte-code back into equivalent Python source code. It accepts byte-code from Python version 2.5 to 2.7. Additionally, it will only run on Python 2.7. The generated source is very readable: docstrings, lists, tuples and hashes get pretty-printed. 'uncompyle2' is based on John Aycock's generic small languages compiler 'spark' (http://www.csr.uvic.ca/~aycock/python/) and his prior work on a tool called 'decompyle'. This tool has been vastly improved by Hartmut Goebel `http://www.crazy-compilers.com/`_ # Additional note (3 July 2004, Ben Burton): This software is no longer available from the original website. It has now become a commercial decompilation service, with no software available for download. Any developers seeking to make alterations or enhancements to this code should therefore consider these debian packages an appropriate starting point. # Additional note (5 June 2012): The decompilation of python bytecode 2.5 & 2.6 is based on the work of Eloi Vanderbeken. bytecode is translated to a pseudo 2.7 python bytecode and then decompiled. Features -------- - decompiles Python byte-code into equivalent Python source - decompiles byte-code from Python version 2.5, 2.6, 2.7 - pretty-prints docstrings, hashes, lists and tuples - reads directly from .pyc/.pyo files, bulk-decompile whole directories - output may be written to file, a directory or to stdout - option for including byte-code disassembly into generated source For a list of changes please refer to the 'CHANGES' file. Requirements ------------ uncompyle2 requires Python 2.7 Installation ------------ You may either create a RPM and install this, or install directly from the source distribution. Creating RPMS: python setup.py bdist_rpm If you need to force the python interpreter to eg. pyton2: python2 setup.py bdist_rpm --python=python2 ### Installation from the source distribution: python setup.py install To install to a user's home-dir: python setup.py install --home=<dir> To install to another prefix (eg. /usr/local) python setup.py install --prefix=/usr/local For more information on 'Installing Python Modules' please refer to http://www.python.org/doc/current/inst/inst.html Usage ----- ./uncompyle2.py -h prints usage ./test_pythonlib.py test files and python library Known Bugs/Restrictions ----------------------- No support for python 3.2 It currently reconstructs most of Python code but probably needs to be tested more thoroughly. All feedback welcome Quote Share this post Link to post Short link Share on other sites
betatest 2 #112217 Posted October 10, 2013 А как компилировать обратно декомпилиованные файлы для WoT? Использую py_compile/compileall в Python 2.7, но на полученные файлы WoT ругается. Что не так? ImportError: scripts/client/[файл].pyc is not a valid Python compiled module file Quote Share this post Link to post Short link Share on other sites
MakcT40 331 #112285 Posted October 10, 2013 Что не так?Для компиляции используйте версию 2.6. 2 Quote Share this post Link to post Short link Share on other sites
Art_NRG 503 #112459 Posted October 11, 2013 Знающие, напишите небольшой гайдик по компиляции-декомпиляции, я вот ну никак к этому питону подкопаться не могу, а так бы начал хотя бы по аналогии делать. Quote Share this post Link to post Short link Share on other sites
Slava7572 1,685 #112475 Posted October 11, 2013 Знающие, напишите небольшой гайдик по компиляции-декомпиляции, я вот ну никак к этому питону подкопаться не могу, а так бы начал хотя бы по аналогии делать. Присоединяюсь к просьбе. Quote Share this post Link to post Short link Share on other sites
Mr A 750 #112489 Posted October 11, 2013 Будет с переходом боя на AS3 1 1 Quote Share this post Link to post Short link Share on other sites
jeroohn 285 #112679 Posted October 11, 2013 (edited) Знающие, напишите небольшой гайдик по компиляции-декомпиляции, я вот ну никак к этому питону подкопаться не могу, а так бы начал хотя бы по аналогии делать. 1. Скачиваешь питон 2.7.http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi 2. Устанавливаешь питон в папку скажем C:\Python27 3. Добавляешь папку с питоном в переменную среды Path 4. Скачиваешь uncompyle2 https://github.com/Mysterie/uncompyle2/archive/master.zip 5. Распаковываешь ее в скажем c:\uncompyle2 6. Открываешь командную строку и переходишь в папку с uncompyle2 cd c:\uncompyle2 7. устанавливаем утилиту выполнив в командной строке python setup.py install 8. если все ок у нас должны появится папки build и в ней папка scripts-2.7 в которой лежит собственно сама утилита файл uncompyle2 9. берем интересующий нас скрипт например cameranode.pyc и кладем его в папку c:\uncompyle2\build\scripts-2.7\ 10. открываем командную строку и переходим в ней в папку со скриптом cd c:\uncompyle2\build\scripts-2.7\ 11. переводим скрипт из бинарика в исходный вид: python uncompyle2 -o cameranode.py cameranode.pyc Вот собственно и вся декомпиляция слог у меня чугунный но вроде достаточно понятно изложил.... Теперь немного по поводу компиляции скриптов. В клиенте использована более ранняя версия 2.6 поэтому компилировать будем в нем, ранее установленная версия для этого не подойдет. 1. Скачиваем Python 2.6 http://www.python.org/download/releases/2.6/ 2. Устанавливаем его в папку C:\Python26\ 3.Выбираем скрипт который мы будем редактировать 4. Убеждаемся что скрипт открылся именно в версии 2.6 5. Вносим необходимые изменения в скрипт и пытаемся выполнить 6. Попадаем в окно интерпретатора, который должен жаловатся на отсутсвие модуля BigWorld других ошибок быть НЕ ДОЛЖНО иначе правим свой скрипт 7. В папке с исходным скриптом который мы редактировали должен появится компилированный скрипт с расширением pyc его можно закидывать в клиент Edited October 12, 2013 by jeroohn 15 Quote Share this post Link to post Short link Share on other sites
jeroohn 285 #112888 Posted October 12, 2013 Ах да, забыл сказать что uncompyle2 прекрасно разбирает все оригинальные скрипты, но не всегда справляется с модифицированными файлами, для их разборки есть другая утилита pycdc Quote Share this post Link to post Short link Share on other sites
abdullah 1 #113046 Posted October 13, 2013 у меня uncompyle2 обломался на arcadecamera.pyc и strategiccamera.pyc из версии 0.8.8 Quote Share this post Link to post Short link Share on other sites
jeroohn 285 #113050 Posted October 13, 2013 (edited) у меня uncompyle2 обломался на arcadecamera.pyc и strategiccamera.pyc из версии 0.8.8 Действительно обламывается pycdc разобрал напутав с цифрами... Edited October 13, 2013 by jeroohn 1 Quote Share this post Link to post Short link Share on other sites
BossBox 14 #113791 Posted October 14, 2013 (edited) Подскажите, не пойму как установить pycdc? Edited October 14, 2013 by BossBox Quote Share this post Link to post Short link Share on other sites
Axon555 3 #113860 Posted October 14, 2013 (edited) 6. Попадаем в окно интерпретатора, который должен жаловатся на отсутсвие модуля BigWorld других ошибок быть НЕ ДОЛЖНО иначе правим свой скрипт Неверно. Питон - интерпретируемый язык, поэтому если даже дальше в коде есть ошибки, все равно это не отобразится. Edited October 14, 2013 by Axon555 1 Quote Share this post Link to post Short link Share on other sites