Skip to main content

🤔What is QSNCTF?

青少年CTF训练平台是一个公益、免费、供给全国青少年学习、训练的CTF在线平台。

(本仓库)qsnctf是青少年CTF训练平台进行编写的一个Python包程序,意图在Python中为大家快速使用一些CTF常用功能开发的开源包。这里有很多CTF常用功能,如Base编码、hash加密,甚至少见的社会主义核心价值观编码、quipqiup等都在其中。

当前项目将长期更新

如果您有好的想法和建议,欢迎与我取得联系:QQ:1044631097。

Alt

安装

首先将GitHub上的项目下载下来后可以文件中有一个setup.py

打开终端然后输入

python setup.py install

或者也可以直接使用pip来进行安装**(由于本Python库仍在开发,所以pip可能不是最新版,如果您有较高的需求,可以直接clone本仓库进行安装)**

pip install qsnctf

也可以使用以下命令来更新此库

pip install --upgrade qsnctf

可选依赖

核心功能开箱即用,以下功能需要额外安装可选依赖:

pip install qsnctf[js]   # jsfuck_decode(需要 JS 引擎执行)
pip install Pillow       # EXIF 读取等图片功能

如果你想知道具体怎么使用可以导入这个包,然后使用help(qsnctf)查看库的用法

>>> import qsnctf
>>> help(qsnctf)
Help on package qsnctf:

NAME
    qsnctf

PACKAGE CONTENTS
    base
    crypto
    hash
    main
    misc
    uuid

FILE
    c:\users\xiniyi\appdata\local\programs\python\python39\lib\site-packages\qsnctf-0.0.4-py3.9.egg\qsnctf\__init__.py

然后使用help(qsnctf.PACKAGE CONTENTS)来查看具体的使用方法

安全默认行为

从当前版本开始,网络扫描、压缩包爆破和消息/API 客户端在构造对象时不会自动执行操作,需要显式调用对应方法:

scanner = DirScan("https://example.com", dirlist=["/admin"])
scanner.run()

webhook = FeishuWebhook("标题", "内容", "token")
webhook.send()

如需兼容原有的一行式调用,可传入 auto_run=True、auto_send=True、auto_solve=True 或 auto_validate=True。所有 HTTP 请求现在默认设置超时,Web 请求默认验证 TLS 证书。

演示

查看base的使用方法

>>> help(qsnctf.base)              
Help on module qsnctf.base in qsnct
                                   
NAME                               
    qsnctf.base                    
                                   
DESCRIPTION                        
    # Base编码解码功能                   
    # 2023年1月1日                    
    # 末心                           
                                   
FUNCTIONS                          
    base16_decode(text)            
                                   
    base16_encode(text)            
                                   
    base32_decode(text)            
                                   
    base32_encode(text)            
                                   
    base64_decode(text)            
                                   
    base64_encode(text)            
                                   
    base85_decode(text)
>>>

功能列表

BASE

base16 base32 base36 base58 base62
base64 base85 base91 base92 base100
自定义base64

CRYPTO

凯撒密码 凯撒爆破 培根密码 ROT5 ROT13
ROT18 八卦密码 埃特巴什码 摩斯密码(支持自定义)

MD5

md5 sha1 sha224 sha256 sha384
sha512 shake128 shake256 HMAC-SHA256 sha3-224
sha3-256 sha3-385 sha3-512

MISC

核心价值观加密解密 文本逆向 url加密解密 位异或 文本逆向(步长2)
文本逆向(自定义步长) 获取uuid ord转字符串 字符串转ord 字符串分割
flag寻找 百家姓编码 Qwerty编码 HTM编码 JSFUCK
AAencode str2hex hex2str ZIP密码爆破 ZIP解压缩(高级)
词频统计 时间戳转换 IP转换

API

quipqiup词频分析 飞书Webhook 钉钉Talk 微步在线 FOFA
大圣云沙箱 零零信安 Go-CQ-HTTP SMTP邮件

WEB

目录扫描 网站存活检测 取网站标题 子域名扫描 取网站描述
取网站关键字 取网站ICP 取网站a标签地址 取网站注释 取网站响应时间
取网站ICO POST Webshell GET Webshell exec-shell eval-shell
WebShell爆破

RSA

RSA加解密 已知因子解密 dp泄漏攻击 小指数攻击 共模攻击
广播攻击 Wiener攻击 公因子攻击 因数分解 factordb在线

JWT

JWT解码

IMAGE

EXIF读取

新增功能示例

时间戳 ↔ 日期转换

from qsnctf import *

timestamp_to_date(1700000000)                   # '2023-11-15 06:13:20'
timestamp_to_date(1700000000000)                # 毫秒自动识别
timestamp_to_date(1700000000, timezone=0)       # UTC 时间
date_to_timestamp('2024-06-01 08:30:00')        # 1717201800
date_to_timestamp('2024-06-01', unit='ms')      # 1717171200000

IP ↔ 整数转换

from qsnctf import *

ip_to_int('192.168.1.1')                         # 3232235777
int_to_ip(3232235777)                            # '192.168.1.1'
int_to_ip(ip_to_int('2001:db8::1'), version=6)   # '2001:db8::1'

RSA 攻击套件

from qsnctf import *

# 已知 p、q 解密
m = rsa_decrypt_with_factors(c, e, p, q)
int_to_bytes(m).decode()                         # 还原明文

rsa_small_e_attack(c, 3, n)                                  # 小公钥指数
rsa_common_modulus_attack(c1, c2, e1, e2, n)                 # 共模攻击
rsa_broadcast_attack([c1, c2, c3], 3, [n1, n2, n3])          # 广播攻击
rsa_wiener_attack(e, n)                                      # Wiener(返回 d, p, q)
rsa_shared_factor_attack(n1, n2)                             # 公因子
rsa_decrypt_with_dp(c, e, n, dp)                             # dp 泄漏
rsa_factor(n)                                                # 本地因数分解
rsa_factordb(n)                                              # 在线因数分解(需联网)

JWT 解码

from qsnctf import *

jwt_decode('eyJhbGciOiJIUzI1NiJ9.eyJhZG1pbiI6dHJ1ZX0.signature')
# {'header': {'alg': 'HS256'}, 'payload': {'admin': True}, 'signature': '...', 'raw': [...]}

EXIF 读取(需 pip install Pillow

from qsnctf import *

exif_read('photo.jpg')
# {'Make': 'Canon', 'Model': 'EOS 5D', 'DateTime': '2024:06:01 08:30:00',
#  'GPS': {'Latitude': 39.90722222, 'Longitude': 116.39138889, ...}}

词频统计

from qsnctf import *

word_freq('The fox jumps over the fox', top=2)   # {'fox': 2, 'the': 2}

SMTP 邮件发送

from qsnctf import *

mail = SMTPMail('smtp.qq.com', 465, 'xxxxx@qq.com', '授权码')   # 构造时不发送
mail.send('to@example.com', '标题', '正文', sender='xxxxx@qq.com')

具体使用

命令行使用

第一步导入qsnctf

from qsnctf import *

例如需要使用base64编码

base64_encode("需要编码的")# 6ZyA6KaB57yW56CB55qE

相同如果使用base64解码的话就是

 base64_decode("6ZyA6KaB57yW56CB55qE")# 需要编码的

其他的编码解码类似


编译器使用

这里还是使用base64来演示,其他的编码解码类似。

from qsnctf import qsnctf

a=base64_encode("需要编码的")
print(a)
b=base64_decode("6ZyA6KaB57yW56CB55qE")
print(b)

返回信息 需要编码的

6ZyA6KaB57yW56CB55qE

Base62的encode值应该是整数!

from qsnctf import qsnctf

a = base62_encode(34441886726)
print(a)
b = base62_decode("base62")
print(b)

传参方法

文档移动到:Function.md

环境

开发环境

Windows11 + Python3.11

使用环境

支持 python 3.x 环境。

文档持续更新。

✨ Contributors

感谢下面的所有人:


Moxin


xinyi


yiye-yfs

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qsnctf-0.0.12.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qsnctf-0.0.12-py3-none-any.whl (55.9 kB view details)

Uploaded Python 3

File details

Details for the file qsnctf-0.0.12.tar.gz.

File metadata

  • Download URL: qsnctf-0.0.12.tar.gz
  • Upload date:
  • Size: 62.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for qsnctf-0.0.12.tar.gz
Algorithm Hash digest
SHA256 17b99119b30dd335d53cb1649abfabc6f5fdecb9bc2b7484085b9eb71197c366
MD5 43a3138afac04db626d38867abb1af49
BLAKE2b-256 c248ca48f013739dc2295b0bde1f97a1ea385a48df36dba08a5f69982778a3ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for qsnctf-0.0.12.tar.gz:

Publisher: python-publish.yml on Moxin1044/qsnctf-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qsnctf-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: qsnctf-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 55.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for qsnctf-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 c89dd013c5fca75c802208b0ea179e3d3ed59e15d5335969ab0aa08105e69307
MD5 113230ac2ad0c9320369581c1aead950
BLAKE2b-256 092bde16fe9723094b449ae2c54c9c6a04faf3b1ff74a1a32a9c6a5f5b9cf3e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for qsnctf-0.0.12-py3-none-any.whl:

Publisher: python-publish.yml on Moxin1044/qsnctf-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.12 This release

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9.3

2 files

0.0.9.2

2 files

0.0.9.1

2 files

0.0.8.10

2 files

0.0.8.9

2 files

0.0.8.8

2 files

0.0.8.7

2 files

0.0.8.6

2 files

0.0.8.5

2 files

0.0.8.3

2 files

0.0.8.2

2 files

0.0.8.1

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page