Appendix EAttack Optimization with Monte Carlo Simulations

As discussed in Chapter 7, “Weaponizing Social Intelligence,” Monte Carlo simulations can be executed by using an LLM service to play the roles of both the social engineering system and the target victim. By crafting instructions for each, it is possible to tailor and optimize attacks toward specific types of targets. The examples provided will use the following boilerplate Python code. While iterating through the Monte Carlo simulations to attempt to optimize automated social engineering attacks, we will primarily be updating the social engineering instructions, the target victim instructions, and the initial message. I have highlighted those in the following code for reference:

import openai
 
openai.api_key = '' # Add OpenAI API Key Here
model_test = str(1)
 
def updateTranscript(msg, transcript):
    #print(msg)
    transcript = f'{transcript}{msg}'
    return transcript
    
def updateConvo(transcript):
    if b1_convo[len(b1_convo)-1]['role'] == 'user':
        r = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=b1_convo)
        reply = r['choices'][0]['message']['content']
        b1_convo.append({'role': 'assistant','content': reply})
        b2_convo.append({'role': 'user','content': reply})        
        return updateTranscript(f'\nSocial Engineer: {reply}', transcript)
        
    elif b2_convo[len(b2_convo)-1]['role'] == 'user':
        r = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=b2_convo)
        reply = r['choices'][0]['message']['content']
 b2_convo.append({'role': ...

Get The Language of Deception now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.