gophish / api-client-python

A Python API Client for Gophish
MIT License
44 stars 48 forks source link

Cannot create a campaign with the python client #6

Closed RobinXaXa closed 7 years ago

RobinXaXa commented 7 years ago

Hi!,

i'm having trouble setting up a new campaign in gophish. here's the script i use :

_def Ajout_Campagne(): #Funtion to ceate a new campaign

#user input for the campaign name name = raw_input ("Quel nom voulez vous donner a votre campagne? ")

#user input to select a group to use with the campaign print "quel groupe voulez vous associer à cette campagne? voici une liste des groupes exisans: " #function used for listing existing groups ListeGroupe() group = raw_input("Groupe?: ") groups = [Group(name=group)] print groups

#it goes the same way for all needed settings for a valid campaign: template,smtp,page and URL

    print "Quel template voulez-vous utiliser pour cette campagne? voici une liste des template existants: "
    ListeTemplate()
    templ = raw_input ("Template? ")
    template = Template(name=templ)
    print template

    print "Quel profil SMTP souhaitez-vous utiliser? voici la liste de l'existant: "
    ListeSender()
    smtp = raw_input("profil? ")
    profile = SMTP(name=smtp)
    print profile

    print ("quelle Page de parking voulez-vous utiliser? " )
    parking = raw_input ("Page? ")
    page = Page(name=parking)
    print page

    urlph = raw_input (" Quel est l'url de votre page de traking? ")

    campaign = Campaign(name=name, groups=groups, page=page,template=template, profile=profile)
    print campaign
    bob = api.campaigns.post(campaign)
    print bob_

When i use this script i get an error 400 in gophish logs which mean bad request.. but i can't see what i'm doing wrong since I followed your guide ;)

By the way, in the gophish.models.Group section you might want to change:

targets = [ Target(first_name='John', last_name='Doe', email='johndoe@example.com'), Target(first_name='Jane', last_name='Doe', email='janedoe@example.com')]

Target --> User since Target isn't defined in models.py

Best regards,

Robin