| Author |
Message |
wfz |
|
|
Post subject: MySQL syntax error
Posted: Dec 03, 2003 - 03:43 AM
|
|

Joined: Dec 02, 2003
Posts: 11
Status: Offline
|
|
I´m trying to use a W2K slave sensor to log to a MySQL database running on a Mandrake Linux 9.1 box. The database is running and I´ve granted the proper privileges to the second sensor, but when snort runs I get the following error message:
(sorry for the long quotation, I thought it would be easier for you if i gave you a complete dump)
Quote:
C:\Snort\bin>snort -de -c c:\snort\etc\snort.conf -l c:\snort\log -i1
Running in IDS mode
Log directory = c:\snort\log
Initializing Network Interface \
--== Initializing Snort ==--
Initializing Output Plugins!
Decoding Ethernet on interface \
Initializing Preprocessors!
Initializing Plug-ins!
Parsing Rules file c:\snort\etc\snort.conf
+++++++++++++++++++++++++++++++++++++++++++++++++++
Initializing rule chains...
No arguments to frag2 directive, setting defaults to:
Fragment timeout: 60 seconds
Fragment memory cap: 4194304 bytes
Fragment min_ttl: 0
Fragment ttl_limit: 5
Fragment Problems: 0
Self preservation threshold: 500
Self preservation period: 90
Suspend threshold: 1000
Suspend period: 30
Stream4 config:
Stateful inspection: ACTIVE
Session statistics: INACTIVE
Session timeout: 30 seconds
Session memory cap: 8388608 bytes
State alerts: INACTIVE
Evasion alerts: INACTIVE
Scan alerts: ACTIVE
Log Flushed Streams: INACTIVE
MinTTL: 1
TTL Limit: 5
Async Link: 0
State Protection: 0
Self preservation threshold: 50
Self preservation period: 90
Suspend threshold: 200
Suspend period: 30
Stream4_reassemble config:
Server reassembly: INACTIVE
Client reassembly: ACTIVE
Reassembler alerts: ACTIVE
Zero out flushed packets: INACTIVE
flush_data_diff_size: 500
Ports: 21 23 25 53 80 110 111 143 513 1433
Emergency Ports: 21 23 25 53 80 110 111 143 513 1433
http_decode arguments:
Unicode decoding
IIS alternate Unicode decoding
IIS double encoding vuln
Flip backslash to slash
Include additional whitespace separators
Ports to decode http on: 80
rpc_decode arguments:
Ports to decode RPC on: 111 32771
alert_fragments: INACTIVE
alert_large_fragments: ACTIVE
alert_incomplete: ACTIVE
alert_multiple_requests: ACTIVE
telnet_decode arguments:
Ports to decode telnet on: 21 23 25 119
database: compiled support for ( mysql odbc )
database: configured to use mysql
database: user = snort
database: password is set
database: database name = snort
database: host = X.X.X.X
database: port = 3306
database: sensor name = Sensor2
database: mysql_error: You have an error in your SQL syntax. Check the manual t
hat corresponds to your MySQL server version for the right syntax to use near '1
' AND encoding = '0' AND filter IS NULL' at line 1
database: mysql_error: You have an error in your SQL syntax. Check the manual t
hat corresponds to your MySQL server version for the right syntax to use near '1
','0', '0')' at line 1
SQL=INSERT INTO sensor (hostname, interface, detail, encoding, last_cid) VALUES
('Sensor2','\','1','0', '0')
database: mysql_error: You have an error in your SQL syntax. Check the manual t
hat corresponds to your MySQL server version for the right syntax to use near '1
' AND encoding = '0' AND filter IS NULL' at line 1
database: Problem obtaining SENSOR ID (sid) from snort->sensor
ERROR:
When this plugin starts, a SELECT query is run to find the sensor id for the
currently running sensor. If the sensor id is not found, the plugin will run
an INSERT query to insert the proper data and generate a new sensor id. Then a
SELECT query is run to get the newly allocated sensor id. If that fails then
this error message is generated.
Some possible causes for this error are:
* the user does not have proper INSERT or SELECT privileges
* the sensor table does not exist
If you are _absolutely_ certain that you have the proper privileges set and
that your database structure is built properly please let me know if you
continue to get this error. You can contact me at (roman@danyliw.com).
Fatal Error, Quitting..
C:\Snort\bin>
Can somebody give me a hand on how to figure this out? |
|
|
| |
|
|
|
 |
Morpheus |
|
Post subject:
Posted: Dec 03, 2003 - 04:06 AM
|
|
Site Admin

Joined: Sep 04, 2003
East Coast - USA
Posts: 1462
Location: East Coast - USA
Status: Offline
|
|
Try this line (removing the -de):
C:\Snort\bin>snort -c c:\snort\etc\snort.conf -l c:\snort\log -i1
If this works then you will need to reset the run line:
# c:\snort\bin\snort.exe \SERVICES \UNINSTALL
# c:\snort\bin\snort.exe \SERVICES \INSTALL c:\snort\etc\snort.conf -l c:\snort\log -i1
Note: You will need to go back into services and set snort to automatic and start the service
Notice: Anytime the Master sensor goes down you MUST restart all slaves after the Master is running.
Does this work? |
|
|
| |
|
|
|
 |
wfz |
|
Post subject:
Posted: Dec 03, 2003 - 08:10 AM
|
|

Joined: Dec 02, 2003
Posts: 11
Status: Offline
|
|
|
Morpheus said,
Try this line (removing the -de):
C:\Snort\bin>snort -c c:\snort\etc\snort.conf -l c:\snort\log -i1
If this works then you will need to reset the run line:
# c:\snort\bin\snort.exe \SERVICES \UNINSTALL
# c:\snort\bin\snort.exe \SERVICES \INSTALL c:\snort\etc\snort.conf -l c:\snort\log -i1
Note: You will need to go back into services and set snort to automatic and start the service
Notice: Anytime the Master sensor goes down you MUST restart all slaves after the Master is running.
Does this work?
First of all thanks for your help.
What you suggested didn´t work.
I think that is a problem of how arguments are passed to the MySQL database by snort.
Any oyher ideas?
I´ll keep trying, I´ll let you know if I figure this out.
Thanks again |
|
|
| |
|
|
|
 |
Morpheus |
|
Post subject:
Posted: Dec 03, 2003 - 08:31 AM
|
|
Site Admin

Joined: Sep 04, 2003
East Coast - USA
Posts: 1462
Location: East Coast - USA
Status: Offline
|
|
On the Master can you log into MySQL with the user name and password from the slave?
# mysql -u snort -p
Note: You will get a password prompt
# <type password>
Note: You will be at the MySQL prompt if it worked
# use mysql;
# show grants from user snort;
Note: This should show the grants associated with the user snort and INSERT and SELECT should be included.
# quit;
If the permissions are missing or you cannot login then these need to be fixed.
Editing configure files for UNIX should always be done on the UNIX box as Windows puts returns at the end of each line and UNIX may have a problem dealing with those.
You might try removing the sensor_name on the slave and give it another try.
Strange problem. |
|
|
| |
|
|
|
 |
wfz |
|
Post subject:
Posted: Dec 03, 2003 - 09:55 AM
|
|

Joined: Dec 02, 2003
Posts: 11
Status: Offline
|
|
Ok, I tried that, but:
user 'snort' has no access to database 'mysql'
with another user that has the proper rights it gives me a syntax error when trying to use SHOW GRANTS from inside the database... I´ll have to check mysql manual
Thanks |
|
|
| |
|
|
|
 |
Morpheus |
|
Post subject:
Posted: Dec 03, 2003 - 01:57 PM
|
|
Site Admin

Joined: Sep 04, 2003
East Coast - USA
Posts: 1462
Location: East Coast - USA
Status: Offline
|
|
The proper syntax:
show grants for snort@localhost;
You will need to be logged in with any user that has full previdleges to execute commands inside of mysql, usually root (mysql -u root -p).
The user snort needs INSERT and SELECT from your slave. |
|
|
| |
|
|
|
 |
wfz |
|
Post subject:
Posted: Dec 04, 2003 - 04:11 AM
|
|

Joined: Dec 02, 2003
Posts: 11
Status: Offline
|
|
It didn´t work anyway.
I deleted recreated the users and its privileges from scratch, but the problem persists.
I sent an e-mail to roman@danyliw.com to see if he knows about this problems.
I think there is something related to the passing and parsing of arguments to the MySQL database.
I´ll keep you informed if I find out anything.
Thanks |
|
|
| |
|
|
|
 |
Morpheus |
|
Post subject:
Posted: Dec 04, 2003 - 04:39 AM
|
|
Site Admin

Joined: Sep 04, 2003
East Coast - USA
Posts: 1462
Location: East Coast - USA
Status: Offline
|
|
Did you install this on a fresh machine?
Are you using NTFS?
You could try giving the slave god prividleges to MySQL.
I don't know who Roman is but I've been working with Snort for three years now and have installed hundreds of sensors. The error your describing doesn't make sense. If he figures it out please let us know and I'll update the guides if there is a specific problem that can be identified. |
|
|
| |
|
|
|
 |
wfz |
|
Post subject:
Posted: Dec 04, 2003 - 04:48 AM
|
|

Joined: Dec 02, 2003
Posts: 11
Status: Offline
|
|
OK, I contacted Roman because it´s who the snort error message says to contact.
I´n not using NTFS and it´s not a fresh machine.
What do you mean by God privileges to MySQL?
Thank you very much for your uninterested support. |
|
|
| |
|
|
|
 |
Morpheus |
|
Post subject:
Posted: Dec 04, 2003 - 05:28 AM
|
|
Site Admin

Joined: Sep 04, 2003
East Coast - USA
Posts: 1462
Location: East Coast - USA
Status: Offline
|
|
Sounds like Roman has something to do with MySQL and may be of little use in this situation.
Were the other sensors setup fresh and do they have NTFS?
You should have a user setup for maintenance and it's usually 'root'. Change the user in your snort.conf to that user with the approperate password and try removing the sensor_name.
A slave only requires INSERT and SELECT privedleges. There is a security risk by using 'root' so be sure to change it back.
A fresh install may be your only solution. Clone the system then do a fresh install, if it fails again you can always image the system back. I don't recommend a dirty install becuse of all the problems that can occur. |
|
|
| |
|
|
|
 |
wfz |
|
Post subject:
Posted: Dec 04, 2003 - 06:38 AM
|
|

Joined: Dec 02, 2003
Posts: 11
Status: Offline
|
|
There are no ohter sensors, only the master one which runs on the same machine as the database. That sensor is not NTFS, it´s a Linux machine (it´s EXT3).
I tried with root and removing the sensor_name, but it says 'access denied for user: 'root@<ip-address>' (Using password YES)
Later I tried to set the password for root@<ip-address> but it can find no matching row in the user table
This is harrassing me, I think I will quit trying to get a windows sensor running.
But I´ll keep trying for a while.
Thanks for your help. |
|
|
| |
|
|
|
 |
Morpheus |
|
Post subject:
Posted: Dec 04, 2003 - 09:27 AM
|
|
Site Admin

Joined: Sep 04, 2003
East Coast - USA
Posts: 1462
Location: East Coast - USA
Status: Offline
|
|
This problem is specific to your system and will be extreamy hard to trouble shoot.
Good luck, and let us know if you find a cure. |
|
|
| |
|
|
|
 |
wfz |
|
Post subject:
Posted: Dec 05, 2003 - 02:42 AM
|
|

Joined: Dec 02, 2003
Posts: 11
Status: Offline
|
|
I kept on working and finally I discovered I was right; the error occurs when the "output database" snort plugin passes the query to the remote database.
It still doesn´t work, but at least now I know what happens:
Look at this:
SELECT sid FROM sensor WHERE hostname='Sensor2' AND interface='\' AND detail='1' AND encoding='0' AND filter IS NULL;
I´ve sniffed the packets and this is the query the slave snort is sending to the database;
as you can see, the backslash after 'interface=' escapes the preceding single quote, thus producing a syntax error. I´ve checked it by submitting the same query via another type of MySQL client.
Perhaps this is a compilation error in the binary I´ve installed.
I´ll use an older version and tell you what happens.
Thank you very much |
|
|
| |
|
|
|
 |
wfz |
|
|
Post subject:
Posted: Dec 05, 2003 - 04:28 AM
|
|

Joined: Dec 02, 2003
Posts: 11
Status: Offline
|
|
I finally solved this, but I had to use an earlier version of the snort binary (2.0.0)
The problem occurs before than what I was analyzing.
the first lines of the snort output say:
<quote>
C:\Snort\bin>snort -de -c c:\snort\etc\snort.conf -l c:\snort\log -i1
Running in IDS mode
Log directory = c:\snort\log
Initializing Network Interface \
--== Initializing Snort ==--
Initializing Output Plugins!
Decoding Ethernet on interface \
Initializing Preprocessors!
Initializing Plug-ins!
Parsing Rules file c:\snort\etc\snort.conf
</quote>
The problem is that s pcap was passing unicode characters when being queried by the snort code for the interface it was listening on, or something like that.
I found it out searching the SNORT-development archives.
Cheers, and thanks again |
|
|
| |
|
|
|
 |
Morpheus |
|
Post subject:
Posted: Dec 05, 2003 - 06:08 AM
|
|
Site Admin

Joined: Sep 04, 2003
East Coast - USA
Posts: 1462
Location: East Coast - USA
Status: Offline
|
|
So your stuck with running an older version of Snort? The problem isn't solved , you hacked around it. I believe there may be some security issues in 2.0, not real sure but you should check on www.snort.org.
This may be happening to a few people, but the majority of the Windows users are not seeing this error. You either have some hardware incompatability (NIC) or software that is corrupt. You may have an old install of WinPcap and a new install is refusing to overwrite the old file. The problem is still there and when you find it out please post the solution here.
Good Luck... |
|
|
| |
|
|
|
 |
|
|