• Stars
    star
    482
  • Rank 90,688 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🐍 py2sec is a Cross-Platform, Fast and Flexible tool to change the .py to .so(Linux and Mac) or .pyd(Win).

py2sec

English Readme

py2sec 一款轻量的脚本工具,基于 Cython 将 .py 编译成 run-time libraries 文件:.so (Linux && Mac),或 .pyd (Win)。一定程度上实现了“加密”保护源代码的需求。

系统支持

Linux && MacOS && Windows

注意:Windows用户运行时可能会遇到如下错误

error: command 'cl.exe' failed: No such file or directory

请安装对应Win系统版本的Visual C++ Build Tools

py2sec 特性

  1. .so / .pyd 文件可以像 .py 模块一样正常调用。例如:importfrom module import * "
  2. py2sec 可以指定编译单个 .py 文件,也可以指定一个 python 项目目录
  3. py2sec 还可以提升代码运行速度,至多提升30倍
  4. py2sec 自动识别项目中的 .py 文件,且只编译 .py 类型文件
  5. 可以指定不需要编译的文件或子目录
  6. py2sec 不影响源文件,加密后的文件或项目将被存放在 result 文件夹
  7. 兼容多平台:macOS、Linux、Windows、
  8. 兼容 Python 版本:python2 and python3, 可使用 -p(--py) 参数来指定版本
  9. 支持多线程(待改进)

环境配置

pip install requirements.txt

使用说明

使用

请将要加密的目录或文件存放在py2sec根目录下

python py2sec.py [选项] ...

选项

-v,  --version    显示 py2sec 版本
-h,  --help       显示帮助菜单
-p,  --pyth       Python的版本, 默认为 你的 "python" 命令绑定的python版本
                  例: -p 3  (比如你使用python3)
-d,  --directory  Python项目路径 (如果使用-d参数, 将编译整个Python项目)
-f,  --file       Python文件 (如果使用-f, 将编译单个Python文件)
-m,  --maintain   标记你不想编译的文件或文件夹路径
                  注意: 文件夹需要以路径分隔符号(`/`或`\\`,依据系统而定)结尾,并且需要和-d参数一起使用 
                  例: -m setup.py,mod/__init__.py,exclude_dir/
-x  --nthread     编译启用的线程数
-q  --quiet       静默模式,默认False
-r  --release     Release 模式,清除所有中间文件,只保留加密结果文件,默认False
python py2sec.py -f test.py
python py2sec.py -f example/test1.py -r
python py2sec.py -d example/ -m test1.py,bbb/

# 一些操作系统使用 "python3" 命令来执行python3,如Ubuntu,这里可以使用 -p 参数来运行
python3 py2sec.py -p 3 -d example/

项目结构

  • build/ 临时文件夹, .o, .so/.pyd 文件
  • tmp_build/ 临时文件夹, .c 文件
  • result/ 编译最终结果存放目录
  • result/log.txt 编译过程日志
  • py2sec.py 主函数文件
  • py2sec_build.py.template 用于生成 py2sec_build.py 的模板文件
  • requirements.txt 依赖库的清单

协议

本项目遵循MIT协议

示例

整个Python项目编译前:

demo1

py2sec 编译后效果:

demo2

More Repositories

1

vulbase

各大漏洞文库合集
HTML
727
star
2

reapoc

OpenSource Poc && Vulnerable-Target Storage Box.
PHP
666
star
3

JNDI-Injection-Exploit-Plus

80+ Gadgets(30 More than ysoserial). JNDI-Injection-Exploit-Plus is a tool for generating workable JNDI links and provide background services by starting RMI server,LDAP server and HTTP server.
Java
663
star
4

hostscan

自动化Host碰撞工具,帮助红队快速扩展网络边界,获取更多目标点
Go
539
star
5

awesome-gpt-security

A curated list of awesome security tools, experimental case or other interesting things with LLM or GPT.
514
star
6

HackChrome

⛄ Get the User:Password from Chrome(include version < 80 and version > 80)
Go
333
star
7

SuperAdapters

Finetune ALL LLMs with ALL Adapeters on ALL Platforms!
Python
286
star
8

pocsploit

a lightweight, flexible and novel open source poc verification framework
Python
234
star
9

py2so

🐍 py2so is tool to change the .py to .so, you can use it to hide the source code of py [Deprecated]. Please navigate to Py2sec
Python
141
star
10

spring-cloud-function-SpEL-RCE

spring-cloud-function SpEL RCE, Vultarget & Poc
Java
133
star
11

YarnRpcRCE

79
star
12

colorsys-go

🎃 colorsys-go is a go package(or lib) for everyone to transform one color system to another. The transformation is among RGB, YIQ, HLS and HSV.
Go
78
star
13

InformationGather

SRC Assets Information Gather Website(SRC资产信息聚合网站)
Vue
61
star
14

netuser

Add or Delete User via windows api,it can be used when .net is inaccessible.
C++
38
star
15

MosaicImage

自动获取用户指定类别图片,并制作马赛克图片
Go
31
star
16

PocCollect

Poc Collected for study and develop
HTML
31
star
17

CVE-2022-40146_Exploit_Jar

Java
30
star
18

Shyvana

A full vul scanner which contains many aspects (adding)
Go
28
star
19

ICS-Protocal-Detect-Nmap-Script

Some nmap scripts to detetct the infomations of the different ICS Here are 16 main ics protocal scan-scripts include Modbus, S7 and so on.
Lua
28
star
20

gitAutoStar

配合GitStar编写的自动Star工具,稳定快速,跨平台
Go
21
star
21

simHtml

Compare html similarity using structural and style metrics
Go
20
star
22

log4shell_1.x

log4j 1.x RCE Poc -- CVE-2021-4104
Java
20
star
23

Log4j_CVE-2021-45046

Log4j 2.15.0 Privilege Escalation -- CVE-2021-45046
Java
20
star
24

Log4j_dos_CVE-2021-45105

Log4j_dos_CVE-2021-45105
Java
13
star
25

nginx_vultarget

Python
12
star
26

gitAutoStar-py

最新版gitStar自动点赞,使用selenium
Python
11
star
27

HaveIReg

HaveIReg用于查找出特定用户在哪些网站注册过
Python
8
star
28

Interview

面试题整理分享(持续更新ing)
Batchfile
8
star
29

cckuailong.github.io

Writing 1000 Words a Day Changed My Life
HTML
7
star
30

Small_Functions

Some interesting code fragments to please
HTML
6
star
31

awesome-ml-for-cybersecurity-books

PDF books for awesome-ml-for-cybersecurity-books
6
star
32

CS-Fun-500-Questions

计算机科学中有趣的500问
Batchfile
5
star
33

DgaDetect

Use Keras or TFLearn to detetct DGA via LSTM, AMSGrad and NAdam
Python
5
star
34

WebsiteApp

We provide a tiny Anddroid App which collects many website for whoerver wants to get the main information of news in a short time
Java
5
star
35

log4j_RCE_CVE-2021-44832

Java
4
star
36

BGPStream_Operate_Plugin

I write two shell scripts to help people create or delete the bgpcorsaro's plugin with only one shell command.
C
4
star
37

KerGaNs

Various GANs with Keras (With diginmon generator as example)
Python
4
star
38

CVE-2021-2471

Java
3
star
39

Learning

好文章收集整理
3
star
40

Colorsys.jl

🌈 Colorsys.jl is a Julia package(or lib) for everyone to transform one color system to another. The transformation is among RGB, YIQ, HLS and HSV.
Julia
3
star
41

vultarget_web

Python
3
star
42

pget

pget is a go package for people to add parallel download func into there project. (Adapt from the go download client [https://github.com/Code-Hex/pget])
Go
3
star
43

clonehub

clone all images(with all tags) on dockerhub to your own dockerhub repo
Shell
2
star
44

Spark-Scala-Handle

Scala
2
star
45

Test-JNDI-Injection-Exploit-Plus

Examples for JNDI-Injection-Exploit-Plus
Java
2
star
46

DLMovies

提供查询下载电影的网站,爬取各大电影网站
Go
2
star
47

apereo-cas-docker

apereo cas docker-compose (can customize cas version)
Dockerfile
2
star
48

Dga.jl

Dga.jl can make you customize one or many DGAs. The included DGAs are [Banjori,Corebot,Cryptolocker,Dircrypt,Kraken,Lockyv2,Pykspa,Qakbot Ramdo,Ramnit,Simda]
Julia
2
star
49

Leetcode-go

Leetcode write in Golang.
Go
1
star
50

gunicorn_request_smuggling

gunicorn 20.0.4 request smuggling
Python
1
star
51

Spiders

随便写的爬虫
Python
1
star
52

Paper_torrent

Academic papers to download, the data is more than 10 TB
1
star