Masscan FIX ERROR: bad packet template

From Luniwiki
Jump to: navigation, search

Issue

Using masscan through a OpenVPN interface raises an error.

u505@naos:~$ sudo masscan -e tun0 -p1-65535,U:1-65535 --rate 1000 10.10.10.84
[sudo] password for u505:
ERROR: bad packet template

The issue seems to affect Kali distro.

u505@naos:/opt/utils$ sudo masscan --version

Masscan version 1.3.0 ( https://github.com/robertdavidgraham/masscan ) Compiled on: Jan 18 2021 13:14:36 Compiler: gcc 10.2.1 20210110 OS: Linux CPU: unknown (64 bits) GIT version: unknown

Fix

We download the source and copy the patch written by sCRiPTz-TEAM

u505@naos:/opt/utils$ git clone https://github.com/robertdavidgraham/masscan.git
Cloning into 'masscan'...
remote: Enumerating objects: 41, done.
remote: Counting objects: 100% (41/41), done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 5022 (delta 16), reused 24 (delta 7), pack-reused 4981
Receiving objects: 100% (5022/5022), 3.19 MiB | 6.21 MiB/s, done.
Resolving deltas: 100% (3491/3491), done.

In the src folder we copy the patched version of templ-pkt.c.

u505@naos:/opt/utils$ cd masscan/
u505@naos:/opt/utils/masscan$ cd src/
u505@naos:/opt/utils/masscan/src$ wget https://raw.githubusercontent.com/scriptzteam/masscan-openVPN/main/src/templ-pkt.c
--2021-01-29 10:19:58--  https://raw.githubusercontent.com/scriptzteam/masscan-openVPN/main/src/templ-pkt.c
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 199.232.0.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|199.232.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 57413 (56K) [text/plain]
Saving to: ‘templ-pkt.c.1’

templ-pkt.c.1 100%[===================>] 56.07K --.-KB/s in 0.01s
2021-01-29 10:19:58 (5.55 MB/s) - ‘templ-pkt.c.1’ saved [57413/57413]

The new version of templ-pkt.c ignores the error.

u505@naos:/opt/utils/masscan/src$ mv templ-pkt.c templ-pkt.c.org
u505@naos:/opt/utils/masscan/src$ mv templ-pkt.c.1 templ-pkt.c
u505@naos:/opt/utils/masscan/src$ diff templ-pkt.c templ-pkt.c.org
1121,1122c1121,1122
<         //LOG(0, "ERROR: bad packet template\n");
<         //exit(1);
---
>         LOG(0, "ERROR: bad packet template\n");
>         exit(1);
1185,1186c1185,1186
<         //LOG(0, "ERROR: bad packet template\n");
<         //exit(1);
---
>         LOG(0, "ERROR: bad packet template\n");
>         exit(1);
1232,1233c1232,1233
<         //LOG(0, "ERROR: bad packet template\n");
<         //exit(1);
---
>         LOG(0, "ERROR: bad packet template\n");
>         exit(1);
1508a1509
>

Compile and install

u505@naos:/opt/utils/masscan/src$ cd ..
u505@naos:/opt/utils/masscan$ make
...
u505@naos:/opt/utils/masscan$ sudo make install
install -pDm755 bin/masscan /usr/bin/masscan
u505@naos:~$ masscan --version

Masscan version 1.3.1 ( https://github.com/robertdavidgraham/masscan ) Compiled on: Jan 29 2021 10:18:54 Compiler: gcc Debian Clang 11.0.1 OS: Linux CPU: unknown (64 bits) GIT version: 1.3.1-2-g4407812

References