pentestgeek / phishing-frenzy

Ruby on Rails Phishing Framework
www.phishingfrenzy.com
GNU General Public License v3.0
794 stars 297 forks source link

Email success in PF dashboard, but fail in Sidekiq. Error "Couldn't find Campaign with 'id'=26" logged. #312

Closed RedLee3 closed 8 years ago

RedLee3 commented 8 years ago

Testing a new campaign and attempting to send test emails to confirm it works. In the PF campaign dashboard, "Recent blasts" show that the test email sent with 0 SMTP failures. Opening the Sidekiq dashboard shows that the emails fail. Below is the relevant errors from the sidekiq log:

2016-06-22T13:58:41.162Z 20913 TID-9xlaw INFO: Running in ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux] 2016-06-22T13:58:41.162Z 20913 TID-9xlaw INFO: See LICENSE and the LGPL-3.0 for licensing details. 2016-06-22T13:58:41.162Z 20913 TID-9xlaw INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org/pro 2016-06-22T13:58:41.162Z 20913 TID-9xlaw INFO: Booting Sidekiq 3.3.3 with redis options {} 2016-06-22T13:58:41.163Z 20913 TID-9xlaw INFO: Starting processing, hit Ctrl-C to stop 2016-06-22T13:59:05.861Z 20913 TID-en094 MailWorker JID-45b792eb86c6ec050be23d74 INFO: start 2016-06-22T13:59:05.862Z 20913 TID-en094 MailWorker JID-45b792eb86c6ec050be23d74 INFO: Attempting to send mail: campaign_id 26,target target@test.com, blast_id 250 2016-06-22T13:59:05.888Z 20913 TID-en094 MailWorker JID-45b792eb86c6ec050be23d74 ERROR: Failed to send mail: campaign_id 26, target target@test.com, blast_id 250 - Couldn't find Campaign with 'id'=26 2016-06-22T13:59:05.888Z 20913 TID-en094 MailWorker JID-45b792eb86c6ec050be23d74 INFO: fail: 0.027 sec 2016-06-22T13:59:05.894Z 20913 TID-en094 WARN: {"retry"=>false, "queue"=>"default", "class"=>"MailWorker", "args"=>[26, "target@test.com", 250, 1], "jid"=>"45b792eb86c6ec050be23d74", "enqueued_at"=>1466603945.8521497} 2016-06-22T13:59:05.894Z 20913 TID-en094 WARN: Couldn't find Campaign with 'id'=26 2016-06-22T13:59:05.894Z 20913 TID-en094 WARN: /var/www/phishing-frenzy/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.7/lib/active_record/relation/finder_methods.rb:320:inraise_record_not_found_exception!' `

The same error happens when launching the campaign: 2016-06-22T14:23:28.237Z 20913 TID-en094 QueueMailWorker JID-c9438f120f97637279a9ded9 INFO: start 2016-06-22T14:23:28.238Z 20913 TID-en094 QueueMailWorker JID-c9438f120f97637279a9ded9 INFO: fail: 0.001 sec 2016-06-22T14:23:28.245Z 20913 TID-en094 WARN: {"retry"=>false, "queue"=>"default", "class"=>"QueueMailWorker", "args"=>["26"], "jid"=>"c9438f120f97637279a9ded9", "enqueued_at"=>1466605408.2357106} 2016-06-22T14:23:28.245Z 20913 TID-en094 WARN: Couldn't find Campaign with 'id'=26 2016-06-22T14:23:28.245Z 20913 TID-en094 WARN: /var/www/phishing-frenzy/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.7/lib/active_record/relation/finder_methods.rb:320:inraise_record_not_found_exception!' `

Anything I need to further do to troubleshoot?

zeknox commented 8 years ago

Sounds like your sidekiq is not started in the proper rails env. Try this:

$ RAILS_ENV=production bundle exec sidekiq
RedLee3 commented 8 years ago

Tried the command, sidekiq started okay, but test emails produce the same below error: 2016-06-22T14:39:06.585Z 24049 TID-2p7ag INFO: Running in ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux] 2016-06-22T14:39:06.585Z 24049 TID-2p7ag INFO: See LICENSE and the LGPL-3.0 for licensing details. 2016-06-22T14:39:06.585Z 24049 TID-2p7ag INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org/pro 2016-06-22T14:39:06.586Z 24049 TID-2p7ag INFO: Booting Sidekiq 3.3.3 with redis options {} 2016-06-22T14:39:06.586Z 24049 TID-2p7ag INFO: Starting processing, hit Ctrl-C to stop 2016-06-22T14:39:40.320Z 24049 TID-73e0g MailWorker JID-90678b2dba82293e76f9be37 INFO: start 2016-06-22T14:39:40.320Z 24049 TID-73e0g MailWorker JID-90678b2dba82293e76f9be37 INFO: Attempting to send mail: campaign_id 26, target target@test.com, blast_id 252 2016-06-22T14:39:40.343Z 24049 TID-73e0g MailWorker JID-90678b2dba82293e76f9be37 ERROR: Failed to send mail: campaign_id 26, target target@test.com, blast_id 252 - Couldn't find Campaign with 'id'=26 2016-06-22T14:39:40.347Z 24049 TID-73e0g MailWorker JID-90678b2dba82293e76f9be37 INFO: fail: 0.027 sec 2016-06-22T14:39:40.349Z 24049 TID-73e0g WARN: {"retry"=>false, "queue"=>"default", "class"=>"MailWorker", "args"=>[26, "target@test.com", 252, 1], "jid"=>"90678b2dba82293e76f9be37", "enqueued_at"=>1466606380.3103976} 2016-06-22T14:39:40.349Z 24049 TID-73e0g WARN: Couldn't find Campaign with 'id'=26 2016-06-22T14:39:40.349Z 24049 TID-73e0g WARN: /var/www/phishing-frenzy/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.7/lib/active_record/relation/finder_methods.rb:320:inraise_record_not_found_exception!' `

zeknox commented 8 years ago

Are you running your application in development mode or production? You need to make sure that sidekiq matches whatever environment you have configured. Are you sure this record still exists, perhaps you need to clear your queue and try again.

RedLee3 commented 8 years ago

The application is in production mode, and Sidekiq is started with the production command you suggested.

What record and queue exactly are you referring to?

zeknox commented 8 years ago

Alright, start your sidekiq in production environment like I illustrated above. Then go to the sidekiq Web interface and you'll see all the jobs pending, go in there and clear out all your jobs in the queue. Then try to launch the emails again to test.

RedLee3 commented 8 years ago

Sidekiq started in production mode. Nothing is shown as queued in the Sidekiq dashboard.

zeknox commented 8 years ago

That version of sidekiq does not show anything in the console. If the queue is empty, then try to perform a test email to see if you get different results.

Also, you can disable using Sidekiq for sending emails. There is a setting within Global Settings where you can uncheck "Send Emails in Background". This causes emails to be sent in the frontend and can hang the app until all emails are sent.

RedLee3 commented 8 years ago

Unchecked the "Send Emails in Background" option, and emails can send now.