forked from JMousqueton/ransomware.live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyse_negotiation.py
49 lines (40 loc) · 1.67 KB
/
analyse_negotiation.py
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
# Pre version to analyse ransom negotiation with chat GPT
import json
import openai
import argparse
import os
from dotenv import load_dotenv
# Load OpenAI API key from .env file
load_dotenv()
openai.api_key = os.getenv('OPENAI_API_KEY')
def read_json_file(filename):
with open(filename, 'r') as file:
return json.load(file)
def ask_openai(question, content):
response = openai.Completion.create(
engine="text-davinci-002",
prompt=f"{content}\n\n{question}",
max_tokens=150
)
return response.choices[0].text.strip()
def extract_details_from_json(json_content):
# Extract ransom demand
ransom_demand_question = "How much was the ransom demand, answer only the figure of the amount?"
ransom_demand = ask_openai(ransom_demand_question, json_content)
print(f"Ransom Demand: {ransom_demand}")
# Extract negotiated ransom
negotiated_ransom_question = "How much was the negotiated ransom, answer only the figure of the amount?"
negotiated_ransom = ask_openai(negotiated_ransom_question, json_content)
print(f"Negotiated Ransom: {negotiated_ransom}")
# Check if victim paid the ransom
paid_ransom_question = "Did the victim pay the ransom, answer only yes or no?"
paid_ransom = ask_openai(paid_ransom_question, json_content)
print(f"Paid Ransom: {paid_ransom}")
def main():
parser = argparse.ArgumentParser(description='Analyse negotiation json file file using ChatGPT.')
parser.add_argument('filename', help='Path to the JSON file.')
args = parser.parse_args()
json_content = read_json_file(args.filename)
extract_details_from_json(str(json_content))
if __name__ == "__main__":
main()