-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrecordminer.py
More file actions
123 lines (111 loc) · 4.75 KB
/
recordminer.py
File metadata and controls
123 lines (111 loc) · 4.75 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
import os
import csv
import sqlite3
import json
import pandas as pd
import concurrent.futures
# Developer: SirCryptic (NullSecurityTeam)
# Info: RecordMiner 1.0
# dly4evarjw
# Fuck The System Before It Fucks You!
os.system('cls' if os.name == 'nt' else 'clear')
banner = '''
________ ______________ _______
___ __ \_____________________________ /__ |/ /__(_)___________________
__ /_/ / _ \ ___/ __ \_ ___/ __ /__ /|_/ /__ /__ __ \ _ \_ ___/
_ _, _// __/ /__ / /_/ / / / /_/ / _ / / / _ / _ / / / __/ /
/_/ |_| \___/\___/ \____//_/ \__,_/ /_/ /_/ /_/ /_/ /_/\___//_/
'''
print(banner)
def search_file(file_path, name, dob, address):
if not os.path.exists(file_path):
return []
file_ext = os.path.splitext(file_path)[1]
results = []
if file_ext == ".csv":
try:
with open(file_path, "r") as f:
reader = csv.reader(f)
headers = next(reader)
for row in reader:
if name in row and (not dob or dob in row) and (not address or address in row):
results.append(dict(zip(headers, row)))
except Exception as e:
print(f"An error occured while reading the CSV file: {e}")
elif file_ext == ".txt":
try:
with open(file_path, "r") as f:
for line in f:
if name in line and (not dob or dob in line) and (not address or address in line):
results.append({"content": line})
except Exception as e:
print(f"An error occured while reading the text file: {e}")
elif file_ext == ".sql":
try:
conn = sqlite3.connect(file_path)
c = conn.cursor()
query = f"SELECT * from records where name like '%{name}%'"
if dob:
query += f" and dob like '%{dob}%'"
if address:
query += f" and address like '%{address}%'"
c.execute(query)
rows = c.fetchall()
headers = [desc[0] for desc in c.description]
for row in rows:
results.append(dict(zip(headers, row)))
conn.close()
except Exception as e:
print(f"An error occured while reading the SQLite file: {e}")
elif file_ext == ".json":
try:
with open(file_path, "r") as f:
data = json.load(f)
for record in data:
if name in record.values() and (not dob or dob in record.values()) and (not address or address in record.values()):
results.append(record)
except Exception as e:
print(f"An error occured while reading the JSON file: {e}")
elif file_ext == ".xlsx":
try:
df = pd.read_excel(file_path, engine='openpyxl')
headers = df.columns.tolist()
for i, row in df.iterrows():
if name in row.values and (not dob or dob in row.values) and (not address or address in row.values):
results.append(dict(zip(headers, row.tolist())))
except Exception as e:
print(f"An error occured while reading the xlsx file: {e}")
return results
def main(folder_location):
name = input("Enter the name to search: ")
dob = input("Enter the date of birth (optional): ")
address = input("Enter the address (optional): ")
results = []
with concurrent.futures.ThreadPoolExecutor() as executor:
filenames = os.listdir(folder_location)
future_to_filename = {executor.submit(search_file, os.path.join(folder_location, filename), name, dob, address): filename for filename in filenames}
for future in concurrent.futures.as_completed(future_to_filename):
result = future.result()
results.extend(result)
if results:
save = input("Do you want to save the results to a text file (yes/no)? ")
if save.lower() == "yes":
with open(f"{name}.txt", "w") as f:
for result in results:
f.write(str(result))
f.write("\n")
print("Results:")
for result in results:
print(result)
else:
print("No results found.")
if __name__ == "__main__":
folder_location = input("Enter the folder location: ")
while not os.path.isdir(folder_location):
print(f"Error: '{folder_location}' is not a valid directory.")
folder_location = input("Enter the folder location: ")
try:
main(folder_location)
except FileNotFoundError:
print(f"Error: The directory '{folder_location}' does not exist.")
main(folder_location)