Skip to content

script mysql-audit fails - ERROR: cannot open usr/share/nmap/nselib/data/mysql-cis.audit: No such file or directory #2125

Closed

Description

@ks6274

Hey there, nmap.
Recently, during a test, i have been facing the issue where, i am trying to run a demo on auditing mysql database using mysql-audit script. The following is the output when i try to run the script and its corresponding arguments.
The script fails and gives the error - cannot open usr/share/nmap/nselib/data/mysql-cis.audit: No such file or directory
however, the path exists and file mysql-cis.audit exists.
I have tried the variation in paths, i.e - mysql-audit.filename='nselib/data/mysql-cis.audit'
but still the same error is thrown.

Kindly help. Thanks in advance.

kali@kali:~$ nmap -p 3306 --script mysql-audit --script-args "mysql-audit.filename='usr/share/nmap/nselib/data/mysql-cis.audit',mysql-audit.username='root',mysql-audit.password='password'" 192.168.56.103 -d --reason
Starting Nmap 7.80 ( https://nmap.org ) at 2020-09-21 06:38 EDT
--------------- Timing report ---------------
hostgroups: min 1, max 100000
rtt-timeouts: init 1000, min 100, max 10000
max-scan-delay: TCP 1000, UDP 1000, SCTP 1000
parallelism: min 0, max 0
max-retries: 10, host-timeout: 0
min-rate: 0, max-rate: 0

NSE: Using Lua 5.3.
NSE: Arguments from CLI: mysql-audit.filename='usr/share/nmap/nselib/data/mysql-cis.audit',mysql-audit.username='root',mysql-audit.password='password'
NSE: Arguments parsed: mysql-audit.filename='usr/share/nmap/nselib/data/mysql-cis.audit',mysql-audit.username='root',mysql-audit.password='password'
NSE: Loaded 1 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 1) scan.
Initiating NSE at 06:38
Completed NSE at 06:38, 0.00s elapsed
Initiating Ping Scan at 06:38
Scanning 192.168.56.103 [2 ports]
Completed Ping Scan at 06:38, 0.00s elapsed (1 total hosts)
Overall sending rates: 2534.85 packets / s.
mass_rdns: Using DNS server 10.0.2.3
Initiating Parallel DNS resolution of 1 host. at 06:38
mass_rdns: 13.00s 0/1 [#: 1, OK: 0, NX: 0, DR: 0, SF: 0, TR: 3]
Completed Parallel DNS resolution of 1 host. at 06:39, 13.00s elapsed
DNS resolution of 1 IPs took 13.00s. Mode: Async [#: 1, OK: 0, NX: 0, DR: 1, SF: 0, TR: 3, CN: 0]
Initiating Connect Scan at 06:39
Scanning 192.168.56.103 [1 port]
Discovered open port 3306/tcp on 192.168.56.103
Completed Connect Scan at 06:39, 0.00s elapsed (1 total ports)
Overall sending rates: 457.67 packets / s.
NSE: Script scanning 192.168.56.103.
NSE: Starting runlevel 1 (of 1) scan.
Initiating NSE at 06:39
NSE: Starting mysql-audit against 192.168.56.103:3306.
NSE: Finished mysql-audit against 192.168.56.103:3306.
Completed NSE at 06:39, 0.00s elapsed
Nmap scan report for 192.168.56.103
Host is up, received syn-ack (0.00053s latency).
Scanned at 2020-09-21 06:38:53 EDT for 13s

PORT STATE SERVICE REASON
3306/tcp open mysql syn-ack
| mysql-audit:
| ERROR: Failed to load rulebase:
|_ ERROR: cannot open usr/share/nmap/nselib/data/mysql-cis.audit: No such file or directory
Final times for host: srtt: 527 rttvar: 4049 to: 100000

NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 1) scan.
Initiating NSE at 06:39
Completed NSE at 06:39, 0.00s elapsed
Read from /usr/bin/../share/nmap: nmap-payloads nmap-services.
Nmap done: 1 IP address (1 host up) scanned in 13.25 seconds

Activity

  1. changed the title [-]script mysql-audit fails - /nselib/mysql.lua:93: bad argument #2 to 'unpack' (data string too short)[/-] [+]script mysql-audit fails - ERROR: cannot open usr/share/nmap/nselib/data/mysql-cis.audit: No such file or directory[/+] on Sep 21, 2020
  2. cldrn commented on Sep 21, 2020

    @cldrn
    Member

    I swear now I feel like every one of these errors is caused by the ghost of fragmentation I'm seeing everywhere

  3. self-assigned this
    on Oct 4, 2020
  4. nnposter commented on Oct 4, 2020

    @nnposter

    Where exactly do you have file mysql-cis.audit?

    You were running nmap from your home directory and you specified usr/share/nmap/nselib/data/mysql-cis.audit, so nmap will try to load the file from $HOME/usr/share/nmap/nselib/data/mysql-cis.audit, which is probably not what you wanted. Have you tried adding a leading forward slash?

  5. nnposter commented on Oct 4, 2020

    @nnposter

    New commit r38082 makes bundled mysql-cis.audit the default value for script argument mysql-audit.filename.

  6. ks6274 commented on Oct 4, 2020

    @ks6274
    Author

    Where exactly do you have file mysql-cis.audit?

    You were running nmap from your home directory and you specified usr/share/nmap/nselib/data/mysql-cis.audit, so nmap will try to load the file from $HOME/usr/share/nmap/nselib/data/mysql-cis.audit, which is probably not what you wanted. Have you tried adding a leading forward slash?

    Yes. I was running nmap from my home directory. Also, i have tried giving the default path for the mysql-cis.audit file as per the documentation, but the script gives error " ERROR: Failed to load rulebase:
    |_ ERROR: cannot open usr/share/nmap/nselib/data/mysql-cis.audit: No such file or directory"
    tried all the combinations for adding/removing the forward slash, but the script does'nt work and throws the same error.

    The path of the mysql-cis.audit file is - ~/usr/share/nmap/nselib/data/

  7. nnposter commented on Oct 4, 2020

    @nnposter

    Please run and provide output from the following commands:

    cd ~
    pwd
    echo $HOME
    ls -l usr/share/nmap/nselib/data/mysql-cis.audit
    nmap -p 3306 --script mysql-audit --script-args mysql-audit.filename=usr/share/nmap/nselib/data/mysql-cis.audit,mysql-audit.username=root,mysql-audit.password=password 192.168.56.103 -d --reason
    
  8. ks6274 commented on Oct 4, 2020

    @ks6274
    Author

    **cd ~**
    pwd --> /home/machine-k6
    ls -l usr/share/nmap/nselib/data/mysql-cis.audit -->
    ls: cannot access 'usr/share/nmap/nselib/data/mysql-cis.audit': No such file or directory

    Now, adding a forward slash (/) to the starting of usr i.e /usr gives output of the target file as follows:
    -rw-r--r-- 1 root root 9796 Aug 2 2019 /usr/share/nmap/nselib/data/mysql-cis.audit

    nmap -p 3306 --script mysql-audit --script-args mysql-audit.filename=usr/share/nmap/nselib/data/mysql-cis.audit,mysql-audit.username=root,mysql-audit.password=password 192.168.56.103 -d --reason
    OUTPUT::
    Starting Nmap 7.80 ( https://nmap.org ) at 2020-10-04 22:43 IST
    --------------- Timing report ---------------
    hostgroups: min 1, max 100000
    rtt-timeouts: init 1000, min 100, max 10000
    max-scan-delay: TCP 1000, UDP 1000, SCTP 1000
    parallelism: min 0, max 0
    max-retries: 10, host-timeout: 0
    min-rate: 0, max-rate: 0

    NSE: Using Lua 5.3.
    NSE: Arguments from CLI: mysql-audit.filename=usr/share/nmap/nselib/data/mysql-cis.audit,mysql-audit.username=root,mysql-audit.password=password
    NSE: Arguments parsed: mysql-audit.filename=usr/share/nmap/nselib/data/mysql-cis.audit,mysql-audit.username=root,mysql-audit.password=password
    NSE: Loaded 1 scripts for scanning.
    NSE: Script Pre-scanning.
    NSE: Starting runlevel 1 (of 1) scan.
    Initiating NSE at 22:43
    Completed NSE at 22:43, 0.00s elapsed
    Initiating Ping Scan at 22:43
    Scanning 192.168.56.103 [2 ports]
    Completed Ping Scan at 22:43, 0.00s elapsed (1 total hosts)
    Overall sending rates: 4319.65 packets / s.
    mass_rdns: Using DNS server 127.0.1.1
    Initiating Parallel DNS resolution of 1 host. at 22:43
    mass_rdns: 0.40s 0/1 [#: 1, OK: 0, NX: 0, DR: 0, SF: 0, TR: 1]
    Completed Parallel DNS resolution of 1 host. at 22:43, 0.40s elapsed
    DNS resolution of 1 IPs took 0.40s. Mode: Async [#: 1, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
    Initiating Connect Scan at 22:43
    Scanning 192.168.56.103 [1 port]
    Discovered open port 3306/tcp on 192.168.56.103
    Completed Connect Scan at 22:43, 0.00s elapsed (1 total ports)
    Overall sending rates: 900.09 packets / s.
    NSE: Script scanning 192.168.56.103.
    NSE: Starting runlevel 1 (of 1) scan.
    Initiating NSE at 22:43
    NSE: Starting mysql-audit against 192.168.56.103:3306.
    NSE: Finished mysql-audit against 192.168.56.103:3306.
    Completed NSE at 22:43, 0.00s elapsed
    Nmap scan report for 192.168.56.103
    Host is up, received syn-ack (0.00042s latency).
    Scanned at 2020-10-04 22:43:48 IST for 1s

    PORT STATE SERVICE REASON
    3306/tcp open mysql syn-ack
    | mysql-audit:
    | ERROR: Failed to load rulebase:
    |_ ERROR: cannot open usr/share/nmap/nselib/data/mysql-cis.audit: No such file or directory
    Final times for host: srtt: 425 rttvar: 3807 to: 100000

    NSE: Script Post-scanning.
    NSE: Starting runlevel 1 (of 1) scan.
    Initiating NSE at 22:43
    Completed NSE at 22:43, 0.00s elapsed
    Read from /usr/bin/../share/nmap: nmap-payloads nmap-services.
    Nmap done: 1 IP address (1 host up) scanned in 0.88 seconds

    _From the error, it seems that the "/" (Forward slash) gets missed and nmap is unable to generate path to the mysql-cis.audit file; and hence throws error._

  9. nnposter commented on Oct 4, 2020

    @nnposter

    Based on the output of ls, you are mistaken that the file is in ~/usr/share/nmap/nselib/data/.
    Are you trying to use some private version of the file or you are aiming for the version bundled with nmap?

  10. ks6274 commented on Oct 4, 2020

    @ks6274
    Author
  11. nnposter commented on Oct 4, 2020

    @nnposter

    So what happens when you run the following?

    nmap -p 3306 --script mysql-audit --script-args mysql-audit.filename=/usr/share/nmap/nselib/data/mysql-cis.audit,mysql-audit.username=root,mysql-audit.password=password 192.168.56.103 -d --reason
    
  12. ks6274 commented on Oct 4, 2020

    @ks6274
    Author
  13. nnposter commented on Oct 4, 2020

    @nnposter

    If it no longer complains about the file being missing then we have identified the cause: You were using a relative path for the file but you should have used absolute path, with the leading forward slash.

    If you are now running into a different error, unrelated to this file-not-found, then please create a new issue.

  14. ks6274 commented on Oct 5, 2020

    @ks6274
    Author

    If it no longer complains about the file being missing then we have identified the cause: You were using a relative path for the file but you should have used absolute path, with the leading forward slash.

    If you are now running into a different error, unrelated to this file-not-found, then please create a new issue.

    Sorry for the late response.
    I have tried to run the mysql-cis.audit script using the following command:
    sudo nmap -p 3306 --script mysql-audit --script-args mysql-audit.filename=/usr/share/nmap/nselib/data/mysql-cis.audit,mysql-audit.username=root,mysql-audit.password=password 192.168.56.103 -d --reason

    with absolute path to the mysql-cis.audit now it is throwing another error, relating to lua.
    The part output is as follows:
    ....................
    .........................
    Initiating NSE at 10:40
    NSE: Starting mysql-audit against 192.168.56.103:3306.
    NSE: mysql-audit against 192.168.56.103:3306 threw an error!
    /usr/bin/../share/nmap/nselib/mysql.lua:93: bad argument #2 to 'unpack' (data string too short)
    stack traceback:
    [C]: in function 'string.unpack'
    /usr/bin/../share/nmap/nselib/mysql.lua:93: in upvalue 'decodeHeader'
    /usr/bin/../share/nmap/nselib/mysql.lua:469: in function 'mysql.decodeDataPackets'
    /usr/bin/../share/nmap/nselib/mysql.lua:532: in function 'mysql.sqlQuery'
    /usr/bin/../share/nmap/scripts/mysql-audit.nse:153: in function </usr/bin/../share/nmap/scripts/mysql-audit.nse:118>
    (...tail calls...)

    Completed NSE at 10:40, 0.03s elapsed
    Nmap scan report for 192.168.56.103
    Host is up, received arp-response (0.00023s latency).
    Scanned at 2020-10-05 10:40:56 IST for 0s
    ..............................
    ...............................

    Thanks a lot for your support.

  15. nnposter commented on Oct 6, 2020

    @nnposter

    I am closing this issue.

    As previously noted, please create new issues for unrelated errors. In your specific case, this new "unpack" error appears to have been already reported by another user (see #2128) so you might be already covered.

  16. added a commit that references this issue on Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions