Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
se-import: Modules import in a safe source protection, support for python module code and custom des encryption, ase decryption operation or custom decryption callback module loading
se-import: Modules import in a safe source protection, support for python module code and custom des encryption, ase decryption operation or custom decryption callback module loading
# -*- coding: utf-8 -*-
# @Time : 2021/11/10 11:22
'''
模块的安全导入,对python模块代码支持des和自定义加密,运行des解密或者自定义解密回调
'''
se_import demo:
# -*- coding: utf-8 -*-
# @Time : 2021/11/9 16:42
import sys
import se_import
print(dir(se_import))
#从内存加载模块
def test_load_mem():
s = "a = 100\nb=1000"
#自定义模块名
name = 'test_load_mem_test'
ret = se_import.load_module(name,s,name + '.py')
print(ret)
print(dir(ret))
print(ret.a)
print(ret.b)
#从内存加载模块,支持模块解密回调
def test_load_custom():
#从内存加载模块
s = "a = 100\nb=1000"
# 自定义模块名
name = 'load_module_custom_test'
ret= se_import.load_module_custom(name,s,name + '.py',lambda x:x + '\nadasdadada=1000')
print(ret)
print(dir(ret))
print(ret.a)
print(ret.b)
#从本地 ase加密文件加载模块
def test_save_load_asefile():
#模块ase 加密,保存到文件
infile = "./ase.py"
outfile = './ase.pys'
key = bytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
iv = bytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
#第一个参数类型是字符串 是文件名, bytes 则为二进制文件内容
ret = se_import.dump_module_to_asefile(infile, key, iv)
with open(outfile,mode='wb') as f:
f.write(ret)
#从文件加载加密模块
# 自定义模块名
infile = './ase.pys'
name = 'test_save_load_asefile_test'
ret2 = se_import.load_module_from_asefile(name,infile,name + '.py')
print(ret2)
print(dir(ret2))
if __name__ == '__main__':
test_save_load_asefile()
FAQs
se-import: Modules import in a safe source protection, support for python module code and custom des encryption, ase decryption operation or custom decryption callback module loading
We found that se-import demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.