So i ran into this issue creating diamond sorter and yeah..... im stumped ....This is my code that i have for parsing specfic values from stealer logs
the issue im having is that when i set my file directory path - my console_widget_textedit detects it - however it does not crawl and it displays the error that is defined on line 63
Код:
def display_results(output, console_widget_textedit):
console_widget_textedit.append(output)
def extract_ip_variable(directory_path):
user_info_file = os.path.join(directory_path, "UserInformation.txt")
ip_variable = "{IP}" # Variable to extract
if os.path.exists(user_info_file):
with open(user_info_file, "r") as file:
for line in file:
if line.startswith("IP:"):
ip = line.strip().split(":")[1].strip()
return ip
return None
def parse_button_function(self):
format_text = self.format_request_textedit.toPlainText() # Get input text from format_request_textedit
directory_path = self.directoryResultsTextBox_2.toPlainText() # Get the directory path from directoryResultsTextBox
variables_chosen = f"=====================\n\nEntered Data\n\n================ =====\n{format_text}"
results_path = self.savedResultsTextBox.toPlainText() # Get the saving results path from savedResultsTextBox
format_capture = f"Capture Format:\n{format_text}"
results_path_text = f"\n\nSaving Results to Path: {results_path}"
self.console_widget_textedit.setPlainText(f"Crawling From:{directory_path}{results_path_text}\n{format_capture}\n{variables_chosen}\n")
if os.path.isdir(directory_path):
directory_path = QFileDialog.getExistingDirectory(self, "Select Directory")
if not directory_path:
return
try:
print("Directory path:", directory_path) # Add this line to print the directory path
status = "Parsing completed."
extracted_variables = {}
# Extract variables
ip_variable = "{IP}"
extracted_variables = {}
# Extract variables
extracted_variables["IP"] = ip_variable
for variable in ["CC", "CVC"]:
value = self.extract_autofill_variable(directory_path, variable)
if value:
extracted_variables[variable] = value
# Define additional variables
extracted_variables["FULLZ"] = "{FULLZ}"
extracted_variables["MM"] = "{MM}"
extracted_variables["YY"] = "{YY}"
extracted_variables["?"] = "{?}"
extracted_variables["A"] = "{A}"
extracted_variables["$"] = "{$}"
# Process variables
processed_output = self.process_variables(format_text, extracted_variables)
# Display results
output = f"Results:\n{processed_output}\n\nStatus: {status}"
self.display_results(output)
except AttributeError:
error_message = "Error: Invalid directory path!"
QMessageBox.critical(self, "Error", error_message, QMessageBox.Ok)
def extract_autofill_variable(self, directory_path, variable):
autofills_folder = os.path.join(directory_path, "Autofills")
variable_names = {
"CC": ["ccName", "cardNumber", "Card", "card-number", "ccnumber", "cc"],
"CVC": ["cvc", "cvv", "securityCode"],
}
value = None
if os.path.exists(autofills_folder):
for file_name in os.listdir(autofills_folder):
file_path = os.path.join(autofills_folder, file_name)
with open(file_path, "r") as file:
content = file.read()
for name in variable_names.get(variable, []):
pattern = r"Name:\s*{}\s*.*?Value:\s*(.+)".format(name)
match = re.search(pattern, content, re.IGNORECASE)
if match:
value = match.group(1)
break
if value:
break
return value
def process_variables(self, format_text, variables):
result = format_text
for variable, value in variables.items():
result = result.replace("{" + variable + "}", str(value))
return result
the issue im having is that when i set my file directory path - my console_widget_textedit detects it - however it does not crawl and it displays the error that is defined on line 63