-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextscan.py
More file actions
149 lines (147 loc) · 5.56 KB
/
Copy pathtextscan.py
File metadata and controls
149 lines (147 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# DO NOT EDIT LINE BELOW UNLESS MAKING UPDATE
# v::1.0.2s
# DO NOT EDIT LINE ABOVE UNLESS MAKING UPDATE
# global OR, per-group AND
# Will this code work even if it's ugly?
# by userdev265scratchandpython(https://github.com/userdev265scratchandpython)
# optionnal but recommended
import builtins
from rich import print as print
from rich.console import Console
from rich.prompt import Prompt
input = Prompt.ask
console = Console(highlight=False)
print = console.print
builtins.print = print
import splash
splash.ss(color=True)
print("[yellow]pytextsearch[/yellow]")
import hashlib, sys, http.client
script_file = sys.argv[0]
with open(script_file, "rb") as f:
script_bytes = f.read()
script_hash = hashlib.sha256(script_bytes).hexdigest()
print(f"[cyan]Script hash: {script_hash}[/cyan]")
with open(script_file, "r") as f:
lines = f.read().split("\n")
verline = lines[1] # 2nd line, 1st line has ID of 0
ver = verline.split("v::")[1] # Version
print(f"[cyan]Version : {ver}[/cyan]")
# check legitimacy
# --get
host = "raw.githubusercontent.com"
path = "/userdev265scratchandpython/pytextsearch/refs/heads/main/versions.txt"
versinfo = ""
hashes = ["9d6b9e304282f3ae4e0f310ef0361950cca7a465e24e6166cfafb24b632628fa", "279db3f1c8e549770a1f2598431b1a8792394154adcde5b1a35ceac87c928211"]
if "0afc74a81a51b7b0d8c79ba3144ad82fedd00c69e60e2ac45afb2199ecff0a47" != hashlib.sha256(bytes(path.encode())).hexdigest():
print("[red]This application has been modified and will not work under any circumpstances. Please delete this from your computer and report this software online. This software is PyTextSearch by Userdev265scratchandpython. If you saw this message online and can communicate with me, please do it as soon as possible.[/red]")
exit(255)
try:
# Connect via HTTPS
conn = http.client.HTTPSConnection(host, timeout=10)
conn.request("GET", path)
response = conn.getresponse()
if response.status == 200:
# Read the content and save to a file
data = response.read().decode("utf-8")
versinfo = data.split("\n")
print("[green]File downloaded successfully![/green]")
conn.close()
elif response.status == 404:
print("[yellow]File not found[/yellow]")
else:
print("[red]Other error[/red]")
except Exception as e:
print(f"[red]Error connecting to server: {e}[/red]")
# --phrase
try:
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
with open("public_key.pem", "rb") as f:
public_key = serialization.load_pem_public_key(f.read())
with open("versions.txt", "rb") as f:
data = f.read()
with open("versions.sig", "rb") as f:
signature = f.read()
try:
public_key.verify(signature, data)
print("[green]VERSIONS FILE LEGIT[/green]")
except:
print("[red]TAMPERED VERSIONS FILE[/red]")
exit()
go, sphash = splash.m095(hashes)
if go == "stop":
print("[red]SPLASH file check failed[/red]")
print(f"SPLASH file hash : {sphash}")
exit(1)
else:
go, sphash = splash.m095("''")
if go != "stop":
print("[red]SPLASH file check failed[/red]")
print(f"SPLASH file hash : {sphash}")
exit(1)
go, sphash = splash.m095(script_hash)
if go != "stop":
print("[red]SPLASH file check failed[/red]")
print(f"SPLASH file hash : {sphash}")
exit(1)
print("[green]SPLASH file check succeeded[/green]")
go, sphash = splash.k095(hashes)
if go == "stop":
print("[red]dep0 file check failed[/red]")
print(f"dep0 file hash : {sphash}")
exit(1)
else:
go, sphash = splash.k095("''")
if go != "stop":
print("[red]dep0 file check failed[/red]")
print(f"dep0 file hash : {sphash}")
exit(1)
go, sphash = splash.k095(script_hash)
if go != "stop":
print("[red]dep0 file check failed[/red]")
print(f"dep0 file hash : {sphash}")
exit(1)
print("[green]dep0 file check succeeded[/green]")
if versinfo != "":
for I in versinfo:
if I.split("::")[0] == ver:
if I.split("::")[1] == script_hash:
print("[green]Legitimate[/green]")
break
else:
print("[red]Illegitimate[/red]")
exit(1)
break
else:
if I == versinfo[len(versinfo)-1]:
print("[red]Illegitimate or Unregistered, please get the latest version from the official repository[/red]")
else:
print("[yellow]Unable to verify![/yellow]")
except Exception as e:
print(f"[red]Error : {e}[/red]")
exit(1)
found = []
file = input("File ")
pattern = input("keyword(semicolons for or, ampersand for and, any of the two to separate) ").split(";")
try:
with open(file, "r", encoding="utf-8", errors="ignore") as f:
for I in f.read().split("\n"):
if not I in found:
for Y in pattern:
badand = len(Y.split("&"))
for Z in Y.split("&"):
if Z.lower() in I.lower():
badand -= 1
if badand == 0:
found.append(I)
except Exception as e:
print(f"[red]An error occured : {e}[/red]")
print("found matches :")
if len(found) > 0:
for I in found:
print(f"{I}")
else:
print("no matches found")
input("")
exit(0)