sethsec / celerystalk

An asynchronous enumeration & vulnerability scanner. Run all the tools on all the hosts.
https://sethsec.github.io/celerystalk/
MIT License
396 stars 72 forks source link

Ability to Resume Scan after Reboot #55

Closed decidedlygray closed 5 years ago

decidedlygray commented 5 years ago

This feature request is for a script similar to the reset.sh script to allow resuming of jobs, but without wiping out all existing jobs (no deleting of the database or flushing redis).

My host was rebooted (thanks Windows 10 auto update). I thought starting the redis server in my Kali guest would be enough to resume my jobs. In fact, when I run ./celerystalk query summary it says that 5 jobs are running. But this is a lie :)

I also tried a ./celerystalk cancel 123,456,789 to cancel those that were in the Currently Running state from ./celerystalk query. My hope was: redis would load up some new jobs and continue execution once I cleared out those jobs that were running when my machine rebooted. It moved 5 more tasks (different task ids than those I had canceled) into the Currently Running state, visible in ./celerystalk query, but a day later those tasks are still executing. The jobs are a couple of nikto scans and a photon crawl, and I don't think they would run for more than a day. I think they are actually "stuck", and I'm not sure how to resume them.

sethsec commented 5 years ago

Thanks for this. The short answer is that right now there is no way to resume them. The jobs that were currently executing when celery crashed were terminated, but the celery task that executed them wasn't around to tell the DB that they were terminated/finished, so the DB is incorrect on those 5 tasks from that point forward. When you restart celery (or reboot) and start celery, celery starts grabbing NEW jobs from redis but is out of sync regarding the terminated jobs.

to your first question, as soon as you start celery up, it starts resuming jobs. celery gets started by celerystalk when you run a scan, rescan, import, etc... but I will add another option so that you can just start celery from within celerystalk without doing anything else.

to the more difficult point, I really need to find a better way to update the DB state if a celery is terminated/stopped/crashes.

sethsec commented 5 years ago

added new command to celerystalk: celery.

root@kali:/opt/celerystalk# ./celerystalk celery -h

celerystalk  -  An asynchronous network enumeration/vulnerability scanner
                Run all your tools against all your hosts (IPs/virtual hosts/subdomains)
                by @sethsec
                Build: 134

+---------+--------------------------------+
| Options | Description                    |
+---------+--------------------------------+
|  start  | Start Celery & Redis processes |
|   stop  | Stop Celery & Redis processes  |
+---------+--------------------------------+

Examples:
    ./celerystalk celery start
    ./celerystalk celery stop

Thoughts? Can you think of a better name? or leave it as is?

decidedlygray commented 5 years ago

I may not totally understand the problem, but would restarting the jobs after a reboot require any interaction with redis as well?

If redis should be handled separately, then I think the name names sense. Otherwise adding them under the scan command as a sub command. Like how workspace has kind of a sub command create..

sethsec commented 5 years ago

I updated query so that it will auto start the services any time query is run.

decidedlygray commented 5 years ago

Seems to work, thanks!!