Ankit19102004 commited on
Commit
3b11c51
·
1 Parent(s): cd37d41
Files changed (1) hide show
  1. honeypot_api.py +52 -50
honeypot_api.py CHANGED
@@ -124,83 +124,85 @@ def generate_agent_reply(session_id):
124
  history = conversation_store[session_id]
125
  scammer_msgs = [m for m in history if m["sender"] == "scammer"]
126
  turn = len(scammer_msgs)
127
-
128
  last_text = scammer_msgs[-1]["text"].lower()
129
 
130
- # Escalation Phases
 
 
 
 
 
 
131
  if turn <= 2:
132
- phase = "confused"
133
  elif turn <= 5:
134
- phase = "concerned"
135
  elif turn <= 8:
136
- phase = "skeptical"
137
  else:
138
- phase = "firm"
139
 
140
  emotional_map = {
141
- "confused": [
142
- "I am not fully understanding this.",
143
- "This is confusing to me."
144
- ],
145
- "concerned": [
146
- "I am worried about my account.",
147
- "This situation feels risky."
148
- ],
149
- "skeptical": [
150
- "Something does not feel right here.",
151
- "I am starting to doubt this."
152
- ],
153
- "firm": [
154
- "Before I proceed, I need proper proof.",
155
- "I will not share anything without verification."
156
- ]
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  red_flags = []
160
  if "otp" in last_text:
161
  red_flags.append("You are asking for my OTP which is extremely sensitive.")
162
  if "urgent" in last_text:
163
  red_flags.append("You are creating urgency which is suspicious.")
164
  if "fee" in last_text:
165
- red_flags.append("Why is there a fee before resolving this?")
166
  if "link" in last_text:
167
  red_flags.append("The link you shared looks suspicious.")
168
- if "upi" in last_text:
169
- red_flags.append("I am unsure about this UPI ID.")
170
-
171
- opener = random.choice(emotional_map[phase])
172
- flag_statement = random.choice(red_flags) if red_flags else ""
173
-
174
- investigative_questions = [
175
- "Can you provide your official employee ID?",
176
- "What is your branch location?",
177
- "Can you share your direct contact number?",
178
- "Is there an official website I can verify?",
179
- "What is the reference or case ID?",
180
- "Please resend the full bank account details clearly.",
181
- "What is the registered company name?"
182
- ]
183
 
184
- question = random.choice(investigative_questions)
185
-
186
- structure_type = random.choice(["short", "medium", "long"])
187
-
188
- if structure_type == "short":
189
- reply = f"{opener} {question}"
190
- elif structure_type == "medium":
191
- reply = f"{opener} {flag_statement} {question}"
192
- else:
193
- reply = f"{opener} {flag_statement} If this is genuine, why is this different from standard procedure? {question}"
194
 
 
195
  reply = re.sub(r"\s+", " ", reply).strip()
196
 
197
  if not reply.endswith("?"):
198
  reply += "?"
199
 
200
- time.sleep(random.uniform(0.3, 0.8))
201
 
202
  return reply
203
-
204
  # ======================================================
205
  # FINAL OUTPUT SUBMISSION
206
  # ======================================================
 
124
  history = conversation_store[session_id]
125
  scammer_msgs = [m for m in history if m["sender"] == "scammer"]
126
  turn = len(scammer_msgs)
 
127
  last_text = scammer_msgs[-1]["text"].lower()
128
 
129
+ # Track asked categories
130
+ if "asked_categories" not in session_meta[session_id]:
131
+ session_meta[session_id]["asked_categories"] = set()
132
+
133
+ asked = session_meta[session_id]["asked_categories"]
134
+
135
+ # Escalation
136
  if turn <= 2:
137
+ tone = "confused"
138
  elif turn <= 5:
139
+ tone = "concerned"
140
  elif turn <= 8:
141
+ tone = "skeptical"
142
  else:
143
+ tone = "firm"
144
 
145
  emotional_map = {
146
+ "confused": ["I am not fully understanding this."],
147
+ "concerned": ["I am worried about my account."],
148
+ "skeptical": ["Something does not feel right here."],
149
+ "firm": ["I will not share anything without proper verification."]
 
 
 
 
 
 
 
 
 
 
 
 
150
  }
151
 
152
+ opener = random.choice(emotional_map[tone])
153
+
154
+ # Aggressive elicitation order
155
+ elicitation_priority = [
156
+ ("phoneNumbers", "Can you provide your direct official contact number?"),
157
+ ("emailAddresses", "What is your official company email address?"),
158
+ ("bankAccounts", "Please resend the full bank account number clearly."),
159
+ ("upiIds", "Can you resend the exact UPI ID?"),
160
+ ("caseIds", "What is the official case reference number?"),
161
+ ("policyNumbers", "What is the policy number linked to this?"),
162
+ ("orderNumbers", "Is there any transaction or order ID?")
163
+ ]
164
+
165
+ intel = intelligence_store[session_id]
166
+
167
+ question = None
168
+
169
+ for key, q in elicitation_priority:
170
+ if not intel.get(key) and key not in asked:
171
+ question = q
172
+ asked.add(key)
173
+ break
174
+
175
+ if not question:
176
+ fallback_questions = [
177
+ "Which branch are you calling from?",
178
+ "What is your registered company name?",
179
+ "Can you share the official website?",
180
+ "Can you provide your employee ID again?"
181
+ ]
182
+ question = random.choice(fallback_questions)
183
+
184
+ # Red flag statements
185
  red_flags = []
186
  if "otp" in last_text:
187
  red_flags.append("You are asking for my OTP which is extremely sensitive.")
188
  if "urgent" in last_text:
189
  red_flags.append("You are creating urgency which is suspicious.")
190
  if "fee" in last_text:
191
+ red_flags.append("Why is there a fee involved?")
192
  if "link" in last_text:
193
  red_flags.append("The link you shared looks suspicious.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
+ flag = random.choice(red_flags) if red_flags else ""
 
 
 
 
 
 
 
 
 
196
 
197
+ reply = f"{opener} {flag} {question}"
198
  reply = re.sub(r"\s+", " ", reply).strip()
199
 
200
  if not reply.endswith("?"):
201
  reply += "?"
202
 
203
+ time.sleep(random.uniform(0.3, 0.7))
204
 
205
  return reply
 
206
  # ======================================================
207
  # FINAL OUTPUT SUBMISSION
208
  # ======================================================