DressPD / IPv6_probing

Repo to check existence of IPv6 address and check validity avoiding aliases
0 stars 2 forks source link

Cronjob setting for zmap not work #2

Open zhang12574 opened 1 year ago

zhang12574 commented 1 year ago

I have tried to set cronjob configurations by both using command crontab -e and sudo crontab -e
And set the config line as:
* * * * * zmap -M ipv6_tcp_synopt -p "80" --ipv6-source-ip=2402:f000:4:1001:809:ba4f:f163:1925 -B 100M --max-runtime=30 --ipv6-target-file=/home/zhangy/zmap_scanning/responsive-addresses.txt >> /home/zhangy/zmap_scanning/log.log
But to find that the redirected output file log.log is empty.
Using command service cron status to check the running status get the result:

cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-04-27 13:52:02 CST; 7min ago
       Docs: man:cron(8)
   Main PID: 727 (cron)
      Tasks: 1 (limit: 38310)
     Memory: 512.0K
     CGroup: /system.slice/cron.service
             └─727 /usr/sbin/cron -f

4月 27 13:59:01 zhangy-System-Product-Name CRON[15266]: pam_unix(cron:session): session opened for user zhangy by (uid=0)
4月 27 13:59:01 zhangy-System-Product-Name CRON[15267]: pam_unix(cron:session): session opened for user zhangy by (uid=0)
4月 27 13:59:01 zhangy-System-Product-Name CRON[15268]: (root) CMD (zmap -M ipv6_tcp_synopt -p "80" --ipv6-source-ip=2402:f000:4:1001:809:ba4f:f163:1925 -B 100M --max-runtime=30 --ipv6-t>
4月 27 13:59:01 zhangy-System-Product-Name CRON[15269]: (zhangy) CMD (echo "hello" >> /home/zhangy/zmap_scanning/l.log)
4月 27 13:59:01 zhangy-System-Product-Name CRON[15270]: (zhangy) CMD (zmap -M ipv6_tcp_synopt -p "80" --ipv6-source-ip=2402:f000:4:1001:809:ba4f:f163:1925 -B 100M --max-runtime=30 --ipv6>
4月 27 13:59:01 zhangy-System-Product-Name CRON[15271]: (zhangy) CMD (/home/zhangy/zmap_scanning/zmap_scan_once.sh >> /home/zhangy/zmap_scanning/f2.log)
4月 27 13:59:01 zhangy-System-Product-Name CRON[15265]: pam_unix(cron:session): session closed for user zhangy
4月 27 13:59:01 zhangy-System-Product-Name CRON[15264]: pam_unix(cron:session): session closed for user root
4月 27 13:59:01 zhangy-System-Product-Name CRON[15267]: pam_unix(cron:session): session closed for user zhangy
4月 27 13:59:01 zhangy-System-Product-Name CRON[15266]: pam_unix(cron:session): session closed for user zhangy

It shows that the cron commands are really executed, and the command echo "hello" >> l.log can normally run and output
And the zmap command is runned both in user mode and root mode I think, so I guess authority is not the problem.

DressPD commented 1 year ago

can u try to save the output in another file/location rather than custom logs? The behavior seems correct overall. Check also the system logs as I suppose you need to configure the cron daemon to send logs to a different destination editing syslog configuration located at /etc/rsyslog.conf or /etc/syslog.conf,

zhang12574 commented 1 year ago

I've just tried both saving the output through zmap -o parameter and redirection, like this

* * * * *  zmap -M ipv6_tcp_synopt -p "80" --ipv6-source-ip=2402:f000:4:1001:809:ba4f:f163:1925 -B 100M --max-runtime=36 --output-module=csv -o "/home/zhangy/zmap_scanning/output2.csv" --ipv6-target-file=/home/zhangy/zmap_scanning/responsive-addresses.txt
* * * * *  zmap -M ipv6_tcp_synopt -p "80" --ipv6-source-ip=2402:f000:4:1001:809:ba4f:f163:1925 -B 100M --max-runtime=36 --ipv6-target-file=/home/zhangy/zmap_scanning/responsive-addresses.txt >> /home/zhangy/zmap_scanning/log2.log

and neither of them give a valid output, for redirection, the log file is empty, and for -o parameter, there is no file output.csv.

zhang12574 commented 1 year ago

I checked the syslog related with zmap and get:

May  7 14:25:50 zhangy-System-Product-Name zmap: recv: unsuccessful responses will be excluded from output
May  7 14:25:50 zhangy-System-Product-Name zmap: zmap: 1 sender threads spawned
May  7 14:25:50 zhangy-System-Product-Name zmap: zmap: Pinning a send thread to core 1
May  7 14:25:50 zhangy-System-Product-Name zmap: zmap: Pinning monitor thread to core 2
May  7 14:25:50 zhangy-System-Product-Name zmap: send: send thread started
May  7 14:25:50 zhangy-System-Product-Name zmap: send: source MAC address fc:34:97:e2:07:52
May  7 14:25:51 zhangy-System-Product-Name zmap: send: send thread 0 finished (max targets of 10000 reached)
May  7 14:25:51 zhangy-System-Product-Name zmap: send: thread 0 cleanly finished
May  7 14:25:51 zhangy-System-Product-Name zmap: zmap: senders finished
May  7 14:26:01 zhangy-System-Product-Name CRON[11004]: (root) CMD (zmap -B 10M -p 80 -n 10000 >> /home/zhangy/zmap_scanning/log3.log)
May  7 14:26:01 zhangy-System-Product-Name CRON[11003]: (root) CMD (echo "hello" >> /home/zhangy/zmap_scanning/l2.log)
May  7 14:26:01 zhangy-System-Product-Name CRON[11005]: (zhangy) CMD (echo "hello" >> /home/zhangy/zmap_scanning/l.log)
May  7 14:27:01 zhangy-System-Product-Name CRON[11153]: (root) CMD (zmap -B 10M -p 80 -n 10000 >> /home/zhangy/zmap_scanning/log3.log)
May  7 14:27:01 zhangy-System-Product-Name CRON[11154]: (root) CMD (echo "hello" >> /home/zhangy/zmap_scanning/l2.log)
May  7 14:27:01 zhangy-System-Product-Name CRON[11155]: (zhangy) CMD (echo "hello" >> /home/zhangy/zmap_scanning/l.log)
May  7 14:28:01 zhangy-System-Product-Name CRON[11319]: (root) CMD (echo "hello" >> /home/zhangy/zmap_scanning/l2.log)
May  7 14:28:01 zhangy-System-Product-Name CRON[11320]: (root) CMD (zmap -B 10M -p 80 -n 10000 >> /home/zhangy/zmap_scanning/log3.log)
May  7 14:28:01 zhangy-System-Product-Name CRON[11321]: (zhangy) CMD (echo "hello" >> /home/zhangy/zmap_scanning/l.log)
May  7 14:29:01 zhangy-System-Product-Name CRON[11465]: (root) CMD (zmap -B 10M -p 80 -n 10000 >> /home/zhangy/zmap_scanning/log3.log)
May  7 14:29:01 zhangy-System-Product-Name CRON[11466]: (root) CMD (echo "hello" >> /home/zhangy/zmap_scanning/l2.log)

and noticed that running zmap command by hand, I get a series of syslogs about it (the upper part of log), while running zmap with cronjob, there're no such logs, only some cron service logs (like the lower part of log).

zhang12574 commented 1 year ago

I don't know whether it's related with the failure