1N3 / Sn1per

Attack Surface Management Platform
https://sn1persecurity.com
Other
7.9k stars 1.82k forks source link

Cronjob not running #309

Closed njmulsqb closed 3 years ago

njmulsqb commented 3 years ago

Hello,

I have scheduled a daily task for cronjob in sniper, using the guide for scheduling mentioned on this repository but I dont know why the cronjob is not executing.

The OS I am using is Kali, I have manually executed the command that is supposed to be running in cronjob, manually it runs alright and gives notification on slack as well but it is not being executed by cron.

1N3 commented 3 years ago

Did you run crontab -e as 'root'? Sn1per requires root to run properly, so executing as a normal user won't work.

njmulsqb commented 3 years ago

Did you run crontab -e as 'root'? Sn1per requires root to run properly, so executing as a normal user won't work.

Yes it's run as root with sudo.

1N3 commented 3 years ago

I tested this earlier on the latest Kali Linux 2020.4 image, and everything is working as expected for me. Can you send the output of your /usr/share/sniper/loot/workspace//scans/scheduled/*.sh ?

cat /usr/share/sniper/loot/workspace/<your_workspace_here>/scans/scheduled/*.sh
njmulsqb commented 3 years ago

I tested this earlier on the latest Kali Linux 2020.4 image, and everything is working as expected for me. Can you send the output of your /usr/share/sniper/loot/workspace//scans/scheduled/*.sh ?

cat /usr/share/sniper/loot/workspace/<your_workspace_here>/scans/scheduled/*.sh

Sure, the output to the above command is: sudo sniper -t af.mil -w af.mil -re >> cron.log

1N3 commented 3 years ago

Thanks. That should work. Does cron.log show any output at all after?

1N3 commented 3 years ago

Also, can you try running the following manually to make sure this works as 'root'? This assumes you're running a daily scheduled scan.

find /usr/share/sniper/loot/workspace/ -type f -name "daily.sh" -exec bash {} \;
njmulsqb commented 3 years ago

Thanks. That should work. Does cron.log show any output at all after? Also, can you try running the following manually to make sure this works as 'root'? This assumes you're running a daily scheduled scan.

find /usr/share/sniper/loot/workspace/ -type f -name "daily.sh" -exec bash {} \;

When run manually it works alright and creates a cron.log file but there is no cron.log file otherwise which is proof that cronjob is not running on its own, that's what I mentioned here in my very first post as well

1N3 commented 3 years ago

Just to simplify and confirm some things, I ran crontab -e as 'root' (sudo su) and added the following:

*/1 * * * * sudo sniper -t 127.0.0.1 -m fullportonly -w 127.0.0.1 >> cron.log

After a minute, cat /root/cron.log to view output. This worked on a fresh Kali 2020.4 image. Can you try on your end?

1N3 commented 3 years ago

Closing out for now, but let me know if you still need help with this.