qpsu 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. qpsu-0.1.0/MANIFEST.in +3 -0
  2. qpsu-0.1.0/N/CA.py +164 -0
  3. qpsu-0.1.0/N/DjangoMiddleware.py +85 -0
  4. qpsu-0.1.0/N/HTML.py +2133 -0
  5. qpsu-0.1.0/N/HTTP.py +531 -0
  6. qpsu-0.1.0/N/HTTPServer.py +242 -0
  7. qpsu-0.1.0/N/__init__.py +3313 -0
  8. qpsu-0.1.0/N/ahttp.py +55 -0
  9. qpsu-0.1.0/N/async_dns.py +70 -0
  10. qpsu-0.1.0/N/async_interrupt.py +35 -0
  11. qpsu-0.1.0/N/async_port.py +64 -0
  12. qpsu-0.1.0/N/browser.py +59 -0
  13. qpsu-0.1.0/N/google_docs.py +10 -0
  14. qpsu-0.1.0/N/mirror_cache.py +135 -0
  15. qpsu-0.1.0/N/t.py +14 -0
  16. qpsu-0.1.0/N/webControl.py +93 -0
  17. qpsu-0.1.0/N/websocket_proxy.py +67 -0
  18. qpsu-0.1.0/N/websocket_server.py +70 -0
  19. qpsu-0.1.0/N/wsgi_app.py +11 -0
  20. qpsu-0.1.0/N/youtube.py +43 -0
  21. qpsu-0.1.0/N/z.py +78 -0
  22. qpsu-0.1.0/PKG-INFO +45 -0
  23. qpsu-0.1.0/README.md +33 -0
  24. qpsu-0.1.0/Win/Constants.py +288 -0
  25. qpsu-0.1.0/Win/KeyCode.py +179 -0
  26. qpsu-0.1.0/Win/WF.py +35 -0
  27. qpsu-0.1.0/Win/__init__.py +1602 -0
  28. qpsu-0.1.0/Win/auto.py +29 -0
  29. qpsu-0.1.0/Win/py_inspect.py +147 -0
  30. qpsu-0.1.0/Win/rcapplocale.py +284 -0
  31. qpsu-0.1.0/Win/reg.py +56 -0
  32. qpsu-0.1.0/pyproject.toml +21 -0
  33. qpsu-0.1.0/qpsu.egg-info/PKG-INFO +45 -0
  34. qpsu-0.1.0/qpsu.egg-info/SOURCES.txt +178 -0
  35. qpsu-0.1.0/qpsu.egg-info/dependency_links.txt +1 -0
  36. qpsu-0.1.0/qpsu.egg-info/top_level.txt +2 -0
  37. qpsu-0.1.0/requirements.txt +156 -0
  38. qpsu-0.1.0/setup.cfg +4 -0
  39. qpsu-0.1.0/setup.py +24 -0
  40. qpsu-0.1.0/tests/CopyQ.py +54 -0
  41. qpsu-0.1.0/tests/GS3105.py +127 -0
  42. qpsu-0.1.0/tests/TradingView.py +29 -0
  43. qpsu-0.1.0/tests/Xhofe/357/274/217alist.py +31 -0
  44. qpsu-0.1.0/tests/a.py +8 -0
  45. qpsu-0.1.0/tests/adb/taobao.py +34 -0
  46. qpsu-0.1.0/tests/aibv_cc.py +12 -0
  47. qpsu-0.1.0/tests/apk_size_analyzer.py +74 -0
  48. qpsu-0.1.0/tests/ast_test.py +39 -0
  49. qpsu-0.1.0/tests/async_uart.py +23 -0
  50. qpsu-0.1.0/tests/baostockT.py +43 -0
  51. qpsu-0.1.0/tests/binanceT.py +507 -0
  52. qpsu-0.1.0/tests/binance_client.py +66 -0
  53. qpsu-0.1.0/tests/bitcoin.py +189 -0
  54. qpsu-0.1.0/tests/bokeh/circle_html.py +9 -0
  55. qpsu-0.1.0/tests/bokeh_test.py +21 -0
  56. qpsu-0.1.0/tests/bybit/bybit_backtest.py +363 -0
  57. qpsu-0.1.0/tests/bybit/bybit_utils.py +6 -0
  58. qpsu-0.1.0/tests/bybit/test.py +37 -0
  59. qpsu-0.1.0/tests/byte_dance.py +56 -0
  60. qpsu-0.1.0/tests/decrypt_chrome_password.py +116 -0
  61. qpsu-0.1.0/tests/decryptchromecookies.py +71 -0
  62. qpsu-0.1.0/tests/dependency_analyzer.py +232 -0
  63. qpsu-0.1.0/tests/diff_apk.py +144 -0
  64. qpsu-0.1.0/tests/dolphindb_csv.py +34 -0
  65. qpsu-0.1.0/tests/edge/load_ext_config_leveldb.py +209 -0
  66. qpsu-0.1.0/tests/eth.py +37 -0
  67. qpsu-0.1.0/tests/find_duplicated_file.py +102 -0
  68. qpsu-0.1.0/tests/flet_calc.py +29 -0
  69. qpsu-0.1.0/tests/frida_get_android_class.py +57 -0
  70. qpsu-0.1.0/tests/gsdata.py +256 -0
  71. qpsu-0.1.0/tests/jk_bms.py +66 -0
  72. qpsu-0.1.0/tests/jlc.py +111 -0
  73. qpsu-0.1.0/tests/jlcfa.py +64 -0
  74. qpsu-0.1.0/tests/kivy/bluetooth_noke.py +122 -0
  75. qpsu-0.1.0/tests/lc.py +239 -0
  76. qpsu-0.1.0/tests/linux/key.py +77 -0
  77. qpsu-0.1.0/tests/linux/usb_monitor.py +9 -0
  78. qpsu-0.1.0/tests/linux_net_tcp.py +98 -0
  79. qpsu-0.1.0/tests/memoryrepo.py +36 -0
  80. qpsu-0.1.0/tests/micropython/async_uart.py +94 -0
  81. qpsu-0.1.0/tests/micropython/async_webserver.py +72 -0
  82. qpsu-0.1.0/tests/micropython/at.py +26 -0
  83. qpsu-0.1.0/tests/micropython/ble.py +124 -0
  84. qpsu-0.1.0/tests/micropython/fs100p.py +57 -0
  85. qpsu-0.1.0/tests/micropython/mdot/async_websocket_client.py +251 -0
  86. qpsu-0.1.0/tests/micropython/mdot/mdot.py +215 -0
  87. qpsu-0.1.0/tests/micropython/mdot/microdot.py +1134 -0
  88. qpsu-0.1.0/tests/micropython/mdot/microdot_asyncio.py +430 -0
  89. qpsu-0.1.0/tests/micropython/mdot/microdot_asyncio_websocket.py +108 -0
  90. qpsu-0.1.0/tests/micropython/mdot/microdot_websocket.py +177 -0
  91. qpsu-0.1.0/tests/micropython/mdot/spi_read.py +222 -0
  92. qpsu-0.1.0/tests/micropython/mrequests.py +372 -0
  93. qpsu-0.1.0/tests/micropython/noise_detect.py +40 -0
  94. qpsu-0.1.0/tests/micropython/postf.py +53 -0
  95. qpsu-0.1.0/tests/micropython/uaioinput.py +56 -0
  96. qpsu-0.1.0/tests/micropython/uaiorepl.py +77 -0
  97. qpsu-0.1.0/tests/micropython/uaiot.py +4 -0
  98. qpsu-0.1.0/tests/micropython/uaiowebrepl.py +107 -0
  99. qpsu-0.1.0/tests/micropython/utelnetserver.py +127 -0
  100. qpsu-0.1.0/tests/micropython/uweb_t.py +35 -0
  101. qpsu-0.1.0/tests/micropython/websocket_helper.py +75 -0
  102. qpsu-0.1.0/tests/micropython/ws_server.py +63 -0
  103. qpsu-0.1.0/tests/moonraker/k.py +215 -0
  104. qpsu-0.1.0/tests/moonraker/unix_socket_test.py +361 -0
  105. qpsu-0.1.0/tests/mt.py +26 -0
  106. qpsu-0.1.0/tests/multiprocessing_test.py +16 -0
  107. qpsu-0.1.0/tests/pdb_test.py +50 -0
  108. qpsu-0.1.0/tests/pebble_test.py +35 -0
  109. qpsu-0.1.0/tests/pyqt_t.py +59 -0
  110. qpsu-0.1.0/tests/pysmb_test.py +1 -0
  111. qpsu-0.1.0/tests/qywx.py +3 -0
  112. qpsu-0.1.0/tests/radius.py +33 -0
  113. qpsu-0.1.0/tests/rtsp_usb.py +37 -0
  114. qpsu-0.1.0/tests/sg.py +7 -0
  115. qpsu-0.1.0/tests/shared_immutable_dict.py +117 -0
  116. qpsu-0.1.0/tests/skidl_test.py +61 -0
  117. qpsu-0.1.0/tests/socket_echo.py +20 -0
  118. qpsu-0.1.0/tests/socket_multi_client.py +77 -0
  119. qpsu-0.1.0/tests/socket_multi_client_py2.py +33 -0
  120. qpsu-0.1.0/tests/socketio/server.py +52 -0
  121. qpsu-0.1.0/tests/socketio/server_flask.py +72 -0
  122. qpsu-0.1.0/tests/socketio/server_flask_0.py +70 -0
  123. qpsu-0.1.0/tests/socketio/server_flask_500.py +91 -0
  124. qpsu-0.1.0/tests/sol.py +39 -0
  125. qpsu-0.1.0/tests/streamlit_script.py +34 -0
  126. qpsu-0.1.0/tests/streamlit_slider.py +30 -0
  127. qpsu-0.1.0/tests/tantivy_test.py +39 -0
  128. qpsu-0.1.0/tests/taobao_trade.py +1347 -0
  129. qpsu-0.1.0/tests/tb_10.py +35 -0
  130. qpsu-0.1.0/tests/telegram_export_parser.py +100 -0
  131. qpsu-0.1.0/tests/telnet.py +44 -0
  132. qpsu-0.1.0/tests/test_dependency_analyzer.py +45 -0
  133. qpsu-0.1.0/tests/test_py.py +16 -0
  134. qpsu-0.1.0/tests/tkinter/hand_drawn_curve.py +27 -0
  135. qpsu-0.1.0/tests/tkinter/vtt_play.py +232 -0
  136. qpsu-0.1.0/tests/tkinter/vtt_qt.py +445 -0
  137. qpsu-0.1.0/tests/tkinter/vtt_text.py +272 -0
  138. qpsu-0.1.0/tests/tornado_flask.py +53 -0
  139. qpsu-0.1.0/tests/totp.py +16 -0
  140. qpsu-0.1.0/tests/trc20.py +100 -0
  141. qpsu-0.1.0/tests/twitter.py +17 -0
  142. qpsu-0.1.0/tests/ucloud_firewall.py +264 -0
  143. qpsu-0.1.0/tests/vivo.py +121 -0
  144. qpsu-0.1.0/tests/vtt2text.py +110 -0
  145. qpsu-0.1.0/tests/wdom_ac/wdom_ac.py +130 -0
  146. qpsu-0.1.0/tests/wdom_err.py +34 -0
  147. qpsu-0.1.0/tests/whoosh_test.py +3 -0
  148. qpsu-0.1.0/tests/ws_server.py +54 -0
  149. qpsu-0.1.0/tests/www.xiezhen.xyz.py +67 -0
  150. qpsu-0.1.0/tests/yandex_password.py +31 -0
  151. qpsu-0.1.0/tests/zhihu_scrapy_single_QA.py +165 -0
  152. qpsu-0.1.0/tests/zhihu_x-zse-96.py +83 -0
qpsu-0.1.0/MANIFEST.in ADDED
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include requirements.txt
3
+ recursive-include tests *.py
qpsu-0.1.0/N/CA.py ADDED
@@ -0,0 +1,164 @@
1
+ #coding=utf-8
2
+ import sys #endswith 是为了适配qgb处于另外一个包内的情况
3
+ if __name__.endswith('qgb.N.CA'):from .. import py
4
+ else:
5
+ from pathlib import Path
6
+ gsqp=Path(__file__).parent.parent.parent.absolute().__str__()
7
+ if gsqp not in sys.path:sys.path.append(gsqp)#py3 works
8
+ from qgb import py
9
+ U,T,N,F=py.importUTNF()
10
+
11
+ def generate_consistent_ecdsa_key(secexp,curve='NIST256p',dir='C:/test/ssh/'):
12
+ ''' pip install ecdsa
13
+ 在不同的机器上,U.generate_ecdsa_by_secexp 相同的secexp生成的 privateKey 文件内容不完全相同(#todo),但是都可以正常连接
14
+
15
+ from qgb.N import CA;CA.generate_consistent_ecdsa_key() 输出相同文件 ;
16
+ '''
17
+ import ecdsa,hashlib,base64
18
+ curve = getattr(ecdsa, curve)
19
+ # 强制使用相同的哈希函数和参数
20
+ sk = ecdsa.SigningKey.from_secret_exponent(
21
+ secexp=secexp,
22
+ curve=curve,
23
+ hashfunc=hashlib.sha256 # 固定哈希函数
24
+ )
25
+
26
+ # 获取DER编码
27
+ der_encoded = sk.to_der() # 注意:这里没有参数
28
+
29
+ # 将DER转换为PEM格式(手动)
30
+ # 对DER进行base64编码
31
+ b64_encoded = base64.b64encode(der_encoded).decode('ascii')
32
+ # 每64个字符插入一个换行
33
+ b64_lines = [b64_encoded[i:i+64] for i in range(0, len(b64_encoded), 64)]
34
+ b64_with_newlines = '\n'.join(b64_lines)
35
+ # 添加PEM头部和尾部
36
+ pem_encoded = '-----BEGIN EC PRIVATE KEY-----\n' + b64_with_newlines + '\n-----END EC PRIVATE KEY-----'
37
+ return pem_encoded,F.write(f"{dir}privateKey_{curve}_{secexp}.pem",pem_encoded)
38
+
39
+
40
+
41
+ def get_certificate_expiration(crt_path):
42
+ from cryptography import x509
43
+ from cryptography.hazmat.backends import default_backend
44
+ # from datetime import datetime
45
+ with open(crt_path, 'rb') as crt_file:
46
+ crt_data = crt_file.read()
47
+ certificate = x509.load_pem_x509_certificate(crt_data, default_backend())
48
+ expiration_date = certificate.not_valid_after
49
+ return expiration_date # return type datetime.datetime
50
+ get_crt_date=get_crt_expiration_date=get_certificate_expiration
51
+
52
+ def secexp_to_bytes_len_32(secexp):
53
+ # Ensure secexp is 32 bytes long
54
+ if isinstance(secexp, int):
55
+ # Convert integer to bytes
56
+ secexp = secexp.to_bytes(32, byteorder='little')
57
+ elif isinstance(secexp, bytes):
58
+ if len(secexp) < 32:
59
+ # Pad with \x00 to make it 32 bytes long
60
+ secexp = b'\x00' * (32 - len(secexp)) + secexp
61
+ elif len(secexp) > 32:
62
+ raise ValueError("The secret exponent must be 32 bytes long for Ed25519.")
63
+ else:
64
+ raise ValueError("The secret exponent must be an integer or a byte string.")
65
+ return secexp
66
+
67
+ def generate_ed25519_PEM_format_by_secexp(secexp=None, curve='Ed25519', comment="", dir='C:/test/ssh/', return_pub=False):
68
+ '''
69
+ Generate Ed25519 key pair using the provided secret exponent or a new one if not provided.
70
+
71
+ for b
72
+ '''
73
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
74
+ from cryptography.hazmat.primitives import serialization
75
+ import base64
76
+ U, T, N, F = py.importUTNF()
77
+
78
+ if py.istr(secexp):
79
+ comment = T.file_legalized(secexp)
80
+ secexp = py.eval(secexp)
81
+
82
+ if not comment:
83
+ comment = py.str(secexp)
84
+
85
+ if secexp is None:
86
+ # Generate a new private key if secexp is not provided
87
+ private_key = Ed25519PrivateKey.generate()
88
+ else:
89
+ secexp = secexp_to_bytes_len_32(secexp)
90
+ private_key = Ed25519PrivateKey.from_private_bytes(secexp)
91
+
92
+ public_key = private_key.public_key()
93
+
94
+ # Serialize the private key to PEM format
95
+ private_pem = private_key.private_bytes(
96
+ encoding=serialization.Encoding.PEM,
97
+ format=serialization.PrivateFormat.PKCS8,
98
+ encryption_algorithm=serialization.NoEncryption()
99
+ )
100
+
101
+ # Serialize the public key to PEM format
102
+ public_pem = public_key.public_bytes(
103
+ encoding=serialization.Encoding.PEM,
104
+ format=serialization.PublicFormat.SubjectPublicKeyInfo
105
+ )
106
+
107
+ with open(f"{dir}privateKey_{curve}_{comment}.pem", "wb") as f:
108
+ f.write(private_pem)
109
+
110
+ with open(f"{dir}publicKey_{curve}_{comment}.pem", "wb") as f:
111
+ f.write(public_pem)
112
+
113
+ if return_pub:
114
+ return public_pem.decode()
115
+
116
+ return private_key, public_key
117
+
118
+
119
+ def generate_rsa_PEM_format_by_secexp(secexp=None,secexp_n=0,key_size=2048, comment="", dir='C:/test/ssh/', return_pub=False):
120
+ '''
121
+ Generate RSA key pair using the provided secret exponent or a new one if not provided.
122
+ '''
123
+ import rsa.prime
124
+ # nbits = key_size
125
+ # m = secexp
126
+
127
+ def generate_prime(nbits):
128
+ nonlocal secexp_n
129
+ print('generate_prime',nbits)
130
+ while True:
131
+ value = secexp + secexp_n
132
+ value |= 1 << (nbits - 1)
133
+ value |= 1
134
+ if rsa.prime.is_prime(value):
135
+ print(secexp_n)
136
+ break
137
+ secexp_n += 1
138
+ return value
139
+
140
+ # Generate the keys
141
+ (p, q, e, d) = rsa.key.gen_keys(key_size, generate_prime)
142
+
143
+ # Create the key objects
144
+ n = p * q
145
+ public_key = rsa.PublicKey(n, e)
146
+ private_key = rsa.PrivateKey(n, e, d, p, q)
147
+
148
+ # Serialize the private key to PEM format
149
+ private_pem = private_key.save_pkcs1(format='PEM')
150
+
151
+ # Serialize the public key to PEM format
152
+ public_pem = public_key.save_pkcs1(format='PEM')
153
+
154
+ with open(f"{dir}privateKey_RSA_{comment}.pem", "wb") as f:
155
+ f.write(private_pem)
156
+
157
+ with open(f"{dir}publicKey_RSA_{comment}.pem", "wb") as f:
158
+ f.write(public_pem)
159
+
160
+ if return_pub:
161
+ return public_pem.decode()
162
+
163
+ return private_key, public_key
164
+
@@ -0,0 +1,85 @@
1
+ import sys
2
+ if sys.platform=='win32':
3
+ 'qgb.U' in sys.modules or sys.path.append('E:/QGB/babun/cygwin/bin/');
4
+ if sys.platform=='linux':
5
+ 'qgb.U' in sys.modules or sys.path.append('/home/qgb/');
6
+ import qgb.N.DjangoMiddleware
7
+
8
+ from qgb import U,T,N,F,py
9
+
10
+ from django.shortcuts import HttpResponse
11
+
12
+ class Log:
13
+ def __init__(self, get_response):
14
+ self.get_response = get_response
15
+ # One-time configuration and initialization.
16
+ self.g={'sys':sys,
17
+ 'py':py, 'U':U, 'T':T, 'N':N, 'F':F}
18
+ def __call__(self, request):
19
+ q=request.META['QUERY_STRING']
20
+ q=('?'+q) if q else ''
21
+ url=request.path+q
22
+ try:
23
+ # if not U.DEBUG:raise Exception(request._stream.stream)
24
+ ip=''
25
+ try:
26
+ if U.isLinux():ip,port=request._stream.stream.stream.raw._sock.getpeername()
27
+ else :ip,port=request._stream.stream.raw._sock.getpeername()
28
+ except:
29
+ ip=request.META[ 'REMOTE_ADDR']
30
+ port=py.No("can't access stream.raw._sock.getpeername() ")
31
+
32
+ ip=N.ip_location(ip,reverse_ip=True)
33
+
34
+ log_obj={
35
+ 'url': url,
36
+ 'ua': request.environ['HTTP_USER_AGENT'],
37
+ 'data':request.body,
38
+ 'ip':ip,
39
+ 'port':port,
40
+ }
41
+ self.s=log_obj
42
+ F.write('log/8000/'+U.stime(),U.pformat(log_obj))
43
+ except Exception as e:
44
+ self.e=e
45
+ F.write('log/8000/e'+U.stime(),U.pformat(e))
46
+
47
+ if url.startswith('/#rpc\n'):
48
+ self.g['self']=self #test?
49
+
50
+ request.url=url
51
+ self.g['q']=request
52
+
53
+ response = HttpResponse()
54
+ response['content-type'] = 'text/plain; charset=utf-8'
55
+ response['X-XSS-Protection']='0'
56
+ response['Access-Control-Allow-Origin'] = '*'
57
+ self.g['p']=response
58
+
59
+ r=U.execStrResult(url[1:],globals=self.g)
60
+ if not response.content:
61
+ response.content=r
62
+ return response
63
+
64
+ # Code to be executed for each request before
65
+ # the view (and later middleware) are called.
66
+ response = self.get_response(request)
67
+ # Code to be executed for each request/response after
68
+ # the view is called.
69
+ return response
70
+
71
+ # from django import template
72
+ # register = template.Library()
73
+
74
+ # @register.tag(name='eval')
75
+ # def do_eval(parser, token):
76
+ # "Usage: {% eval %}1 + 1{% endeval %}"
77
+
78
+ # nodelist = parser.parse(('endeval',))
79
+
80
+ # class EvalNode(template.Node):
81
+ # def render(self, context):
82
+ # return eval(nodelist.render(context))
83
+
84
+ # parser.delete_first_token()
85
+ # return EvalNode()