chrismaddalena / Goreport

A Python script to collect campaign data from Gophish and generate a report
BSD 3-Clause "New" or "Revised" License
180 stars 50 forks source link

Error with campaign ID when generating report #25

Closed DKhalaf closed 2 years ago

DKhalaf commented 5 years ago

[+] A total of 1 campaign IDs have been provided for processing. [+] GoReport will process the following campaign IDs: 88 [+] Now fetching results for Campaign ID 88 (1/1). [!] There was a problem fetching this campaign ID's details. Make sure your URL and API key are correct. Check HTTP vs HTTPS! L.. Details: super() takes at least 1 argument (0 given) [+] Success! [!] Looks like campaign ID None does not exist! Skipping it... [!] There was a problem processing campaign ID 88! L.. Details: 'NoneType' object has no attribute 'timeline'

Any suggestions on how to fix this? btw, both url and id are correct and im running http.

CyberM070 commented 4 years ago

Hi Chris,

I experience the same issue here, please help to fix this.

loganthewerewolf commented 4 years ago

Hey Chris,

Getting the same issue, please help!

SarthakKohli commented 4 years ago

Facing same issue , kindly guide to resolve Thanks

CyberM070 commented 4 years ago

I am using version 0.9.0. I even tried to copy the database to the older version op Gophish, where Goreport used to work in the past, and that didn't work as well. Perhaps it has something to do with campaigns that have been conducted via the latest version?

ahmedkhlief commented 4 years ago

I traced the issue to error : urllib3.exceptions.LocationParseError: Failed to parse: https://:3333/api/campaigns/

the solution was :

python3 -m pip install --upgrade urllib3

CyberM070 commented 4 years ago

I traced the issue to error : urllib3.exceptions.LocationParseError: Failed to parse: https://:3333/api/campaigns/

the solution was :

python3 -m pip install --upgrade urllib3

Thanks for the suggestion but it did not work for me. Hope that @chrismaddalena can fix this issue.

dineshdinz commented 4 years ago

I am also facing the same issue.

[+] A total of 1 campaign IDs have been provided for processing. [+] GoReport will process the following campaign IDs: 5 [+] Now fetching results for Campaign ID 5 (1/1). [!] There was a problem fetching this campaign ID's details. Make sure your URL and API key are correct. Check HTTP vs HTTPS! L.. Details: Failed to parse: https://:3333/api/campaigns/5 [+] Success! [!] Looks like campaign ID None does not exist! Skipping it... [!] There was a problem processing campaign ID 5! L.. Details: 'NoneType' object has no attribute 'timeline'

vincentcox commented 4 years ago

Okay, so I did some debugging. The error is triggered here: https://github.com/chrismaddalena/Goreport/blob/master/lib/goreport.py#L433

kpomeroy1979 commented 4 years ago

I also ran into a similar issue a while ago and my fix was to DISABLE my iptables firewall. Once I disabled the firewall, the GoReport script ran and generated reports as expected.

Hope this helps someone.

Cheers

On Fri, Jul 10, 2020 at 8:14 AM Vincent Cox notifications@github.com wrote:

Okay, so I did some debugging. The error is triggered here: https://github.com/chrismaddalena/Goreport/blob/master/lib/goreport.py#L433

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chrismaddalena/Goreport/issues/25#issuecomment-656698720, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5LZHQ2TYX2IEL64FHL34DR24O5TANCNFSM4JUGSHKA .

vincentcox commented 4 years ago

@kpomeroy1979, did you ran it over HTTP instead of HTTPS? I am digging in the code and I think there is something about that.

vincentcox commented 4 years ago

@kpomeroy1979 , just tested, it has no effect... I have no idea why it's failing

vincentcox commented 4 years ago

I followed the trace and I ended up at: https://github.com/chrismaddalena/Goreport/blob/master/lib/goreport.py#L230 This is where the error occurs.

Error code when I put that command outside the try function (to get some actual debug info):

  File "/usr/lib/python3/dist-packages/requests/models.py", line 380, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/lib/python3/dist-packages/urllib3/util/url.py", line 392, in parse_url
    return six.raise_from(LocationParseError(source_url), None)
  File "<string>", line 2, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: http://phishysite.com:3333/api/campaigns/23

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "GoReport.py", line 94, in <module>
    parse_options()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "GoReport.py", line 91, in parse_options
    gophish.run(id, combine, complete)
  File "/root/tools/Goreport/lib/goreport.py", line 228, in run
    print(self.api.campaigns.get(campaign_id=CAM_ID))    
  File "/usr/local/lib/python3.8/dist-packages/gophish/api/campaigns.py", line 15, in get
    return super(API, self).get(resource_id=campaign_id)
  File "/usr/local/lib/python3.8/dist-packages/gophish/api/api.py", line 88, in get
    return self.request("GET",
  File "/usr/local/lib/python3.8/dist-packages/gophish/api/api.py", line 58, in request
    response = self.api.execute(method, endpoint, json=body)
  File "/usr/local/lib/python3.8/dist-packages/gophish/client.py", line 24, in execute
    response = requests.request(
  File "/usr/lib/python3/dist-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 449, in prepare_request
    p.prepare(
  File "/usr/lib/python3/dist-packages/requests/models.py", line 314, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python3/dist-packages/requests/models.py", line 382, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: http://phishysite.com:3333/api/campaigns/23

This is as far my knowledge goes... If somebody has an idea, feel free. This issue might be related: https://stackoverflow.com/questions/58444298/requests-exceptions-invalidurl-failed-to-parse

vincentcox commented 4 years ago

Okay I found the fix!

git clone git://github.com/urllib3/urllib3.git
python3 setup.py install

Have a nice weekend guys!

kpomeroy1979 commented 4 years ago

I ran it over HTTPS.

Have you ever been able to successfully run a report? Also make sure your permissions are right on the directories (just a shot in the dark). Check your goreport/gophish.conf and make sure your gp_host is correct. It should be https://x.x.x.x:3333/ and that your API key is correct.

Also, when I had my firewall ENABLED and was getting errors, I saw this in the output and fixed it like so. There was also another reference to an ot of date python utility but I can't remember now off the top of my head which one it was.

ERROR: gophish 0.4.0 has requirement python-dateutil==2.6.0, but you'll have python-dateutil 2.8.1 which is incompatible.

pip uninstall python-dateutil

apt-get remove --auto-remove python-dateutil

apt-get purge --auto-remove python-dateutil

pip install python-dateutil==2.6.0

On Fri, Jul 10, 2020 at 8:31 AM Vincent Cox notifications@github.com wrote:

@kpomeroy1979 https://github.com/kpomeroy1979, did you ran it over HTTP instead of HTTPS? I am digging in the code and I think there is something about that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chrismaddalena/Goreport/issues/25#issuecomment-656706978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5LZHXM2XLBRPL2HTOQSLLR24Q5FANCNFSM4JUGSHKA .

kpomeroy1979 commented 4 years ago

That was the other one I had to fix, urllib3.

good job.

On Fri, Jul 10, 2020 at 8:49 AM Vincent Cox notifications@github.com wrote:

Okay I found the fix!

git clone git://github.com/urllib3/urllib3.git python setup.py install

Have a nice weekend https://www.youtube.com/watch?v=IwLSrNu1ppI guys!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chrismaddalena/Goreport/issues/25#issuecomment-656715484, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5LZHQJZQQY5GDKOJ3BJCDR24S6TANCNFSM4JUGSHKA .