如何将Python打包后的exe还原成.py?

python打包py文件生成exe,以及运行exe产生的问题 python打包py文件生成exe,以及运行exe产生的问题 1 安装pyinstaller pip install pyinstaller 我这里已经安装过了,就不再多说啦! 2 用pyinstaller进行打包 (1)选项: -F:表示生成单一的exe文件 -w:表示执行exe文件时去除背后的dos窗口 ps:建议最初试验时保留dos,可以查看是否有错误发生 -p:有些需要手动添加包的位置... 阅读详情
AI摘要

本文详细介绍了如何使用pyinstxtractor.py和uncompyle6工具对Python的exe文件进行解包和反编译,恢复pyc文件的头信息,并最终逆向成.py源码。通过010Editor查看和修改文件内容,展示了Python程序逆向的基本步骤。

来源:https://www.jianshu.com/p/5871c3dd633b

用到的工具

  1. pyinstxtractor.py 拆包(解压)工具,将exe文件解压成一个文件夹

  2. uncompyle6 pyc反编译工具

  3. 010EditorEditor 或者其他二进制查看与修改工具,我这里用的010Editor

安装方法

pip install uncompyle6
第一步:解包
python3 pyinstxtractor.py ***.exe   #  这里替换成你要反编译的exe文件

#  会生成一个以 exe文件名+_extracted 的文件夹,这个就是解包后的数据
2f754270f76d3783907ae4e8a5da6b1f.png
第二步:添加头信息

PyInstaller打包后,pyc文件的前8个字节会被抹掉,所以最后要自己添加回去。前四个字节为python编译的版本,后四个字节为时间戳。想要获得编译版本可以查看打包文件里struct的信息

1). 进入文件夹,找到以exe文件名命名的文件(没有后缀),这个就是目的文件c6705a37d2d675c99f2f5995625bb60f.png

2). 用 010Editor 打开 struct,前八位就是我们想要的信息,将其复制

a1af002075204821b1271940394dba4e.png

3). 用 010Editor 打开目的文件我这里是 abc_text,将上一步复制的信息插入到开头

修改前:

6d542232af16b4264a1ffdafcfd488ca.png

修改后:

b7ea6e9629450068976da11e6c49d1e3.png

4). 将目的文件我这里是 abc_text,添加pyc的后缀

第三步:逆向目的文件.pyc

1). 其实这里已经可以使用了。了解python的都知道pyc是py文件编译后的二进制文件,因此如果想要分析源码还得继续逆向成.py文件03673de68c97b7f6e379b28956e537c2.png

2). uncompyle6逆向pyc文件

uncompyle6 abc_text.pyc > abc_text.py
a32aa26669545aa561f02c737e3e6619.png


ce099e3f10c696d9e8835d03a8d3b715.png

e30511ea471cda60271bb575e0b007de.png

推荐阅读:
入门: 最全的零基础学Python的问题  | 零基础学了8个月的Python  | 实战项目 |学Python就是这条捷径
干货:爬取豆瓣短评,电影《后来的我们》 | 38年NBA最佳球员分析 |   从万众期待到口碑扑街!唐探3令人失望  | 笑看新倚天屠龙记 | 灯谜答题王 |用Python做个海量小姐姐素描图 |碟中谍这么火,我用机器学习做个迷你推荐系统电影
趣味:弹球游戏  | 九宫格  | 漂亮的花 | 两百行Python《天天酷跑》游戏!
AI: 会做诗的机器人 | 给图片上色 | 预测收入 | 碟中谍这么火,我用机器学习做个迷你推荐系统电影
小工具: Pdf转Word,轻松搞定表格和水印! | 一键把html网页保存为pdf!|  再见PDF提取收费! | 用90行代码打造最强PDF转换器,word、PPT、excel、markdown、html一键转换 | 制作一款钉钉低价机票提示器! |60行代码做了一个语音壁纸切换器天天看小姐姐!|

年度爆款文案

点击阅读原文,教你搭建博客!

将Python打包后的可执行文件还原为.py文件(后端) 将Python打包后的可执行文件还原为.py文件可能是一项复杂的任务,因为反编译的源代码可能与原始代码存在一些差异。然而,通过使用反编译工具和进行代码整理和修复,我们可以尽可能地恢复原始代码的结构和功能。记住,在实际情况下,可能会遇到更复杂的代码和反编译情况,需要更多的手动修复和调整。请注意,反编译的源代码可能与原始.py文件存在一些差异,因为它是从可执行文件还原而来的。请注意,反编译的源代码可能与原始代码存在一些差异,因此你需要仔细检查和修改反编译的代码,以确保其正确性和完整性。 阅读详情

相关推荐

conda环境和python项目一键打包与还原project_packer

这是一个通用的Python项目打包工具,专门用于打包基于conda环境的Python项目。

专注技术分享 573

python之打包、解包

python的打包、解包;python打包解包在函数的运用

github_38539139的博客 1717

SAP-FICO LSMW实战:批量导入财务凭证与固定资产主数据(AS91)的完整指南

本文详细介绍了SAP-FICO中LSMW工具在批量导入财务凭证与固定资产主数据(AS91)的完整流程与实战技巧。从基础概念、环境准备到财务凭证导入全流程,特别针对AS91历史资产导入的日期逻辑和关键字段映射提供了专项指南,并分享了常见错误排查与性能优化建议,帮助用户高效完成SAP数据迁移任务。

weixin_29230649的博客 505

将python打包的.exe文件还原成.py文件

将python打包的.exe文件还原成.py文件 1、下载 pyinstxtractor.py 地址:https://sourceforge.net/projects/pyinstallerextractor/ 2、把pyinstxtractor.py和exe文件放在同个目录下 打开cmd,进入该目录,输入: python2 pyinstxtractor.py xx.exe 运...

tymatlab的专栏 3万+

Cadence IC5141保姆级教程:Bandgap电路四大仿真(稳定性/噪声/启动/PSRR)完整流程与调参心得

本文提供Cadence IC5141中Bandgap电路的四大仿真(稳定性仿真、噪声仿真、启动仿真、PSRR仿真)的完整流程与调参心得。从原理图检查到ADE L配置,详细解析各仿真步骤的关键参数设置与优化策略,帮助工程师高效完成电路设计与性能调优。

weixin_30399821的博客 1651

Windows11上CUDA 12.3配PyTorch踩坑记:一条官网命令救了我的GPU加速

本文详细介绍了在Windows 11上配置CUDA 12.3与PyTorch的完整指南,包括环境准备、安装要点、兼容性解决方案和性能验证。通过官方推荐的conda命令和实用技巧,帮助开发者解决常见问题,实现高效的GPU加速,提升深度学习开发效率。

weixin_42528974的博客 109

将Pyinstaller打包后的exe还原成PYC 反编译到.py的Python源码

将Pyinstaller打包后的exe还原成.py的Python源码 #

1758

Basilisk vs. STK:开源航天仿真工具在Windows上的实战体验与生态对比

本文对比了开源航天仿真工具Basilisk与商业软件STK在Windows平台上的实战体验与生态差异。从技术架构、安装配置、使用成本、功能覆盖、社区生态到适用场景,全面分析了二者的优劣势,为航天工程师和研究人员提供选型参考。Basilisk在性能和扩展性上表现突出,而STK在可视化与专业模块上更具优势。

weixin_30632089的博客 588

python打包的exe反编译_将python打包的.exe文件还原成.py,针对Pyinstaller的exe反编译-exe文件...

将python打包的.exe文件还原成.py文件1、下载 pyinstxtractor.py地址:https://sourceforge.net/projects/pyinstallerextractor/2、把pyinstxtractor.py和exe文件放在同个目录下打开cmd,进入该目录,输入:python2 pyinstxtractor.py xx.exe运行后生成xx.exe_extra...

weixin_39960145的博客 494

从问卷到结论:手把手教你用SPSS 28完成一份完整的社科数据分析报告

本文详细介绍了如何使用SPSS 28完成社会科学研究中的数据分析报告,从问卷数据导入、清洗到描述性和推断性统计分析,再到结果呈现与报告撰写。通过实际案例演示,帮助研究者掌握SPSS 28的核心功能,提升数据分析效率与报告质量。

weixin_28717431的博客 249

解决OpenCASCADE性能瓶颈:显示加速与三角剖分优化全攻略

本文深入探讨OpenCASCADE在工业设计和CAD建模中的性能优化策略,重点解决显示加速与三角剖分等核心瓶颈问题。通过智能刷新控制、显示数据结构优化和动态LOD技术,显著提升渲染效率和交互体验,适用于复杂场景下的三维可视化应用。

weixin_30752699的博客 344

python打包exe命令_python将打包的exe文件还原py文件

原博文2019-08-09 13:26 −1、下载 pyinstxtractor.py 地址:https://sourceforge.net/projects/pyinstallerextractor/ 也可复制下面代码(即pyinstxtractor.py代码) """ PyInstaller Extractor v1.9...相关推荐2019-12-06 01:04 −安装pyinsta...

weixin_39693438的博客 410

大学计算 - 方程求解 实训答案 第3关

【代码】大学计算 - 方程求解 实训答案 第3关。

2403_89314916的博客 107

python 将.py文件打包成.exe文件,将.exe文件还原为.py文件

打包工具:pyinstaller 安装方法: pip install pyinstaller 打包步骤: 1)cd到需要打包的xxx.py目录下; 2)运行如下命令: pyinstaller (-F) xxx.py (--noconsole) 其中: -F:生成一个文件,如果不加则生成一个文件夹; --noconsole:设置是否有展...

Warmer_Sweeter 2958

科研级YOLOv8 Neck革新:BiFPN双向特征金字塔赋能,让多尺度融合更高效的实战指南

在文件夹下新建BiFPN.py,将上述BiFPNLayer和BiFPN类的代码写入其中。这一步是为了让YOLOv8的代码架构能识别我们的自定义Neck模块。

m0_64661770的博客 153

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

python将打包的exe文件还原py文件

1、下载 pyinstxtractor.py 地址:https://sourceforge.net/projects/pyinstallerextractor/ 也可复制下面代码(即pyinstxtractor.py代码) """ PyInstaller Extractor v1.9 (Supports pyinstaller 3.3, 3.2, 3.1, 3.0, 2...

azmvwpksy950249397的博客 1213

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Python的多个py文件打包成exe

Python的多个py文件打包成exe 安装pyinstaller 打开命令行 输入pip install pyinstaller 如遇报错,输入网址https://www.lfd.uci.edu/~gohlke/pythonlibs/ 全局搜索pyinstaller.whl文件,然后下载 输入pip install pyinstaller-xxx-xxx-xxx.whl安装pyinstaller...

27-_-的博客 2万+

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

如何将python3 gui界面(py文件)打包成exe文件

前言:之前博客介绍了使用Pyqt5开发python gui界面,直接这样用的话,每次要通过Python启动。如果要脱离python环境使用,则需要将写好gui的python3的py文件打包成exe程序 网上找到的方法是python有个库,pyinstaller 安装pyinstaller 可以直接在cmd命令行中,输入代码来安装pyinstaller pip install pyinsta...

fff2zrx的博客 3万+

py打包exe,用python做一个图形化界面

py打包exe,用python做一个图形化界面

sraxc的博客 7018

用pyinstaller打包.py成EXE文件

一、python安装pyinstaller方法 使用python编写脚本,需要发给别人使用的时候,总会想到如何打包成exe文件,发给对方。这样的话,对方可以直接使用运行,无需安装python。所以看网上的教程,大多使用pyinstaller。以下介绍下安装方法: 1、在cmd控制台下,先升级pip版本,先执行命: pip install -U pip,若执行失败,控制台会提示新密令,按照提示...

lynjan的博客 9万+

如何将python程序打包成exe文件

首先介绍以下pyinstaller的命令。将py打包为exe文件需要依赖pyinstaller

qq_56418482的博客 3万+
上一篇: 用Python采集了几千条相亲文案,终于发现了告别单身的秘密
下一篇: 每日一练 | 20道常考Python面试题大总结
菜鸟学Python
博客等级 码龄9年 8062粉丝 571原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值