robertdavidgraham / masscan

TCP port scanner, spews SYN packets asynchronously, scanning entire Internet in under 5 minutes.
GNU Affero General Public License v3.0
23k stars 3.02k forks source link

What signal should i send to process to save and close this tool? #732

Open lynrayy opened 9 months ago

lynrayy commented 9 months ago

What signal should i send to process to save and close this tool? SIGINT kills the process without pausing the progress, CTRL_C_EVENT does literally nothing

P.s coding some stuff on python, trying to emulate CTRL+C with os.kill(pid,signal.CTRL_C_EVENT)

lynrayy commented 9 months ago

I want to get this message:

waiting several seconds to exit...
saving resume file to: paused.conf
TechClusterHQ commented 9 months ago

I have had trouble with this in the past as well, it'd be great to know if this is possible.

gprime31 commented 9 months ago

sudo killall masscan or sudo killall -KILL masscan

lynrayy commented 9 months ago

sudo killall masscan or sudo killall -KILL masscan

  1. I'm on windows
  2. I'm using python to stop the process
  3. 'kill' just kill the process instead of save and stop it
TechClusterHQ commented 9 months ago

Yep exactly the same for me

Am Mi., 4. Okt. 2023 um 15:26 Uhr schrieb lynrayy @.***

:

sudo killall masscan or sudo killall -KILL masscan

  1. I'm on windows
  2. I'm using python to stop the process
  3. 'kill' just kill the process instead of save and stop it

— Reply to this email directly, view it on GitHub https://github.com/robertdavidgraham/masscan/issues/732#issuecomment-1746875123, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAQOCUBYO7KV27JUFKUKIETX5VPYJAVCNFSM6AAAAAA5MFH4TSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBWHA3TKMJSGM . You are receiving this because you commented.Message ID: @.***>

berney commented 8 months ago

masscan has a signal handler setup for Ctrl-C (SIGINT). https://github.com/robertdavidgraham/masscan/blob/9065684c52682d3e12a35559ef72cd0f07838bff/src/main.c#L1333

If you have masscan running in the foreground of your terminal just hit Ctrl-C. Or you can send the signal, e.g. kill -s int $(pidof masscan) - you may need sudo if masscan is running as root.

This will cause masscan to wait several seconds and save the paused.conf

waiting several seconds to exit...
saving resume file to: paused.conf

This works for me on Linux.

I haven't tested it on Windows. If you can't get it to work nicely on Windows, you could try using WSL, or Docker.

lynrayy commented 8 months ago

sudo

I'm on windows!

ben-elttam commented 8 months ago

If you can't get it to work nicely on Windows, you could try using WSL, or Docker.