<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8255987636826363948</id><updated>2011-10-23T06:10:01.664-07:00</updated><category term='Exploits'/><category term='Microsoft'/><category term='WMI'/><category term='Ossim'/><category term='Syslog'/><category term='Database'/><title type='text'>Aliensanti</title><subtitle type='html'>A place about Alienvault SIEM, network security and Open Source tools</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://aliensanti.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://aliensanti.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Santiago Bassett</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://3.bp.blogspot.com/_wBC0qcp7pis/S8ovkwr_kdI/AAAAAAAAAE4/HKt4nEGolyQ/S220/Santiago.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8255987636826363948.post-7631220726010770394</id><published>2010-06-23T08:48:00.000-07:00</published><updated>2010-06-23T11:52:43.413-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WMI'/><category scheme='http://www.blogger.com/atom/ns#' term='Ossim'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Collecting and managing data remotely via WMI</title><content type='html'>WMI seems to be a good method to remotely collect Microsoft Windows events and data in an agent-less way. So, as remote access configuration is a bit tricky, i wanted to explain how I've done it from a Debian box using wmic (a wmi client implementation). Also, as it is interesting as well, I have done brief explanations on how to manage WMI namespaces security and how to explore WMI classes.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
It's fair to mention that most of the steps described below have been found in the Internet (references are listed at the end of the guide). So I have just put it all together as, at least for me, it makes much more sense this way.&lt;br /&gt;
&lt;br /&gt;
In this case my scenario is composed by two different boxes:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Microsoft Windows XP SP2: Data source&lt;/li&gt;
&lt;li&gt;Debian Linux: Data collector&lt;/li&gt;
&lt;/ul&gt;&lt;b&gt;1.- Creating a user for remote WMI access.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
First step is creating a new limited user, so we don't need to use an administrator account for remote connections. This makes the installation much more secure, but of course the same configuration would work for administrators.&lt;br /&gt;
In this case, as an example, I have created the following limited user:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Name: wmiuser&lt;/li&gt;
&lt;li&gt;Password: wmi&lt;/li&gt;
&lt;/ul&gt;Once this is done, then we need to configure DCOM settings to allow our user to access the computer remotely. This is perfectly described at &lt;a href="http://msdn.microsoft.com/en-us/library/aa393266(VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/aa393266(VS.85).aspx&lt;/a&gt;. Nevertheless, to sum up, there are two main points, explained below:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Grant DCOM remote launch and activation permissions for our user.&lt;/li&gt;
&lt;li&gt;Grant DCOM remote access permissions&lt;/li&gt;
&lt;/ol&gt;&lt;b&gt;2.- Grant DCOM remote launch and activation permissions for our user.&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Click Start, click Run, type DCOMCNFG, and then click OK.&lt;/li&gt;
&lt;li&gt;In the Component Services dialog box, expand Component Services, expand Computers, and then right-click My Computer and click Properties.&lt;/li&gt;
&lt;li&gt;In the My Computer Properties dialog box, click the COM Security tab.&lt;/li&gt;
&lt;li&gt;Under Launch and Activation Permissions, click Edit Limits.&lt;/li&gt;
&lt;li&gt;In the Launch Permission dialog box, follow these steps to add our "wmiuser" user:&lt;br /&gt;
&lt;ol type=a&gt;&lt;li&gt;In the Launch Permission dialog box, click Add.&lt;/li&gt;
&lt;li&gt;In the "Select Users, Computers, or Groups" dialog box, add your name in the "Enter the object names to select" box, and then click OK.&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;In the Launch Permission dialog box, select our user in the "Group or user names" box. In the Allow column under Permissions for User, select Remote Launch, Local Activation and Remote Activation, and then click OK.&lt;/li&gt;
&lt;/ol&gt;&lt;center&gt;&lt;a href="http://lh6.ggpht.com/_wBC0qcp7pis/TCEsehmuZMI/AAAAAAAAAH0/W4k7bITkG-c/wmi_1.png"&gt;&lt;img src="http://lh6.ggpht.com/_wBC0qcp7pis/TCEsehmuZMI/AAAAAAAAAH0/W4k7bITkG-c/wmi_1.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;
&lt;b&gt;3.- Grant DCOM remote access permissions.&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Click Start, click Run, type DCOMCNFG, and then click OK.&lt;/li&gt;
&lt;li&gt;In the Component Services dialog box, expand Component Services, expand Computers, and then right-click My Computer and click Properties.&lt;/li&gt;
&lt;li&gt;In the My Computer Properties dialog box, click the COM Security tab.&lt;/li&gt;
&lt;li&gt;Under Access Permissions, click Edit Limits.&lt;/li&gt;
&lt;li&gt;In the Access Permission dialog box, select ANONYMOUS LOGON name in the Group or user names box. In the Allow column under Permissions for User, select Remote Access, and then click OK.&lt;/li&gt;
&lt;/ol&gt;&lt;center&gt;&lt;a href="http://lh6.ggpht.com/_wBC0qcp7pis/TCEwRs62iXI/AAAAAAAAAH4/aNex9Yt_PJM/wmi_2.png"&gt;&lt;img src="http://lh6.ggpht.com/_wBC0qcp7pis/TCEwRs62iXI/AAAAAAAAAH4/aNex9Yt_PJM/wmi_2.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;
&lt;b&gt;4.- Allowing remote administration at Windows firewall.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
At this point we have already done the hard part. Now we just need to go ahead allowing remote administration in the Windows firewall. This is needed as when querying WMI, we are going to execute an asynchronous call, so we need to add an exception for it. This all is done executing the following from the command line:&lt;br /&gt;
&lt;br /&gt;
C:\&gt; netsh firewall set service RemoteAdmin enable&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5.- For Windows XP and 2003 only: Relaxing the security policy.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Sharing and security model is set to "Guest only" on Windows XP Pro and Windows 2003, so we must to make sure that remote logons are not being coerced to the "Guest" account (this is enabled by default on computers that are not attached to a domain). To do this, open the Local Security Policy editor (e.g. by typing 'secpol.msc' into the Run box, without quotes). Expand the "Local Policies" node and select "Security Options". Now scroll down to the setting titled "Network access: Sharing and security model for local accounts". If this is set to "Guest only", change it to "Classic" and restart the computer.&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;a href="http://lh3.ggpht.com/_wBC0qcp7pis/TCHNocCMIII/AAAAAAAAAH8/-RWln7pmwXk/wmi_3.png"&gt;&lt;img src="http://lh3.ggpht.com/_wBC0qcp7pis/TCHNocCMIII/AAAAAAAAAH8/-RWln7pmwXk/wmi_3.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;
&lt;b&gt;6.- Querying WMI locally.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
At this point your system should be ready to be queried. So you don't need to do any further configuration and we can start playing a little bit. So we can test access this way:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Click Start -&gt; Run and type wbemtest. The wbemtest application starts.&lt;/li&gt;
&lt;li&gt;Click Connect and type \root\cimv2, replacing &lt;server&gt; with the name of the remote server. Click Connect. If you are unable to connect, there is a problem with the authentication between the machines.&lt;/li&gt;
&lt;li&gt;If you are able to connect, click Query and type select * from win32_service. Click Apply. After a short wait, you should see a list of running services. If this does not work, then the authentication works, but the user is running as does not have enough privileges to run that operation.&lt;/li&gt;
&lt;/ol&gt;&lt;center&gt;&lt;a href="http://lh4.ggpht.com/_wBC0qcp7pis/TCITj5bucjI/AAAAAAAAAIA/jvlVnMH30_M/wmi_4.png"&gt;&lt;img src="http://lh4.ggpht.com/_wBC0qcp7pis/TCITj5bucjI/AAAAAAAAAIA/jvlVnMH30_M/wmi_4.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;
&lt;b&gt;7.- Querying WMI remotely from a Debian box.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Using Debian packages manager, "apt-get", I have installed "wmi-client" in my box. It includes a DCOM/WMI  client implementation, allowing us to query our Windows box remotely. That can be done using "wmic" command with the following syntax:&lt;br /&gt;
&lt;br /&gt;
# wmic -U wmiuser%wmi --namespace='root\cimv2' //windows_ip_address "select * from Win32_Process"&lt;br /&gt;
&lt;br /&gt;
Of course, "windows_ip_address" should be replaced by the real IP address of your Windows host. One of the resulting events (the one related to the System Idle Process) looks like this:&lt;br /&gt;
&lt;br /&gt;
System Idle Process|(null)|Win32_Process|(null)|Win32_ComputerSystem|WINDOWS-DB0B159|System Idle Process|(null)|0|0|0|(null)|692341250000|0|0|System Idle Process|Win32_OperatingSystem|Microsoft Windows XP Professional|C:\WINDOWS||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|(null)|(null)|1|0|0|5.1.2600|28672|0|0&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;8.- Managing WMI namespaces security.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
It's also very interesting to mention you can set permissions for each WMI namespace, using wmimgmt.msc tool. In this tool, you can set security that is based off of the root or select individual namespaces. You can also use inheritance that is based on namespace hierarchy.&lt;br /&gt;
&lt;br /&gt;
For example, in case we want to set permission for our "wmiuser" we would open "WMI Control (Local) Properties) and, once selected a namespace, click on "Security" adding our user. &lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;a href="http://lh6.ggpht.com/_wBC0qcp7pis/TCIgyNH7WBI/AAAAAAAAAIE/MgyKdky5tBg/wmi_5.png"&gt;&lt;img src="http://lh6.ggpht.com/_wBC0qcp7pis/TCIgyNH7WBI/AAAAAAAAAIE/MgyKdky5tBg/wmi_5.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;
&lt;b&gt;9.- Exploring WMI classes.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Browsing in the Internet I have found "WMI Explorer" which is a useful tool if you want to explore the full set of WMI management classes, objects and their properties. It can be found at the following website:&lt;br /&gt;
&lt;a href="http://www.ks-soft.net/hostmon.eng/wmi/index.htm"&gt;http://www.ks-soft.net/hostmon.eng/wmi/index.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Once you download and run it you will see an easy to use interface that allows you not only to explore the WMI classes but also to execute anny WQL query and view the result set. Playing a little bit with it will give you an idea of how powerful WMI is, and how many different ways you can use it for your own profit. In my case, those will be mainly related to applications inventory.&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;a href="http://lh5.ggpht.com/_wBC0qcp7pis/TCIpngMUE1I/AAAAAAAAAII/59NIhgPCaVc/wmi_6.png"&gt;&lt;img src="http://lh5.ggpht.com/_wBC0qcp7pis/TCIpngMUE1I/AAAAAAAAAII/59NIhgPCaVc/wmi_6.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;
&lt;b&gt;10.- Where to find more information.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
As mentioned at the beginning most of this guide is based on documentation found somewhere in the Internet, so here is a list of useful links where you can find more detailed documentation about issues discussed here:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;WMI documentation: &lt;a href="http://msdn.microsoft.com/en-us/library/aa394582(v=VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/aa394582(v=VS.85).aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Configuring and securing a remote WMI connection: &lt;a href="http://msdn.microsoft.com/en-us/library/aa393266(VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/aa393266(VS.85).aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Examples: &lt;a href="http://msdn.microsoft.com/en-us/library/aa394585(v=VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/aa394585(v=VS.85).aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Troubleshooting: &lt;a href="http://www.10-strike.com/networkinventoryexplorer/help/wmi.shtml"&gt; http://www.10-strike.com/networkinventoryexplorer/help/wmi.shtml&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;WMI Explorer homepage: &lt;a href="http://www.ks-soft.net/hostmon.eng/wmi/index.htm"&gt;http://www.ks-soft.net/hostmon.eng/wmi/index.htm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8255987636826363948-7631220726010770394?l=aliensanti.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliensanti.blogspot.com/feeds/7631220726010770394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aliensanti.blogspot.com/2010/06/collecting-data-remotely-via-wmi.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/7631220726010770394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/7631220726010770394'/><link rel='alternate' type='text/html' href='http://aliensanti.blogspot.com/2010/06/collecting-data-remotely-via-wmi.html' title='Collecting and managing data remotely via WMI'/><author><name>Santiago Bassett</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://3.bp.blogspot.com/_wBC0qcp7pis/S8ovkwr_kdI/AAAAAAAAAE4/HKt4nEGolyQ/S220/Santiago.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_wBC0qcp7pis/TCEsehmuZMI/AAAAAAAAAH0/W4k7bITkG-c/s72-c/wmi_1.png' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255987636826363948.post-2664738762880848403</id><published>2010-04-29T05:12:00.000-07:00</published><updated>2010-04-30T00:50:02.879-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>MySQL replication master-master for two hosts</title><content type='html'>This howto describes, step by step, how to setup a MySQL replication cluster with only two hosts. It tries to give a solution to the one-way synchronization master-slave documented in MySQL website without the need to setup a cluster (which requires at least three hosts). So, with this howto, a two-ways synchronization can be done and, because of that, I named it master-master replication mode.&lt;br /&gt;
&lt;br /&gt;
It has been successfully tested in Mysql Server 5.1.41 but it probably will also work for more advanced versions.&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1.- Edit my.cnf files:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
[In server A]&lt;br /&gt;
server-id = 1 &lt;br /&gt;
log_bin = /var/log/mysql/mysql-bin.log&lt;br /&gt;
auto_increment_increment = 2&lt;br /&gt;
auto_increment_offset = 1&lt;br /&gt;
#bind-address = 0.0.0.0&lt;br /&gt;
&lt;br /&gt;
[In server B]&lt;br /&gt;
server-id = 2&lt;br /&gt;
log_bin = /var/log/mysql/mysql-bin.log&lt;br /&gt;
auto_increment_increment = 2&lt;br /&gt;
auto_increment_offset = 2&lt;br /&gt;
#bind-address = 0.0.0.0&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Server-id should be different for every node&lt;/li&gt;
&lt;li&gt;There is a well known issue with master-master replication and auto_increments described here: &lt;a href="http://onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html"&gt; http://onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Bind address should be commented or set to the ip address where mysql daemon will be listening.&lt;/li&gt;
&lt;/ul&gt;Then restart both servers.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2.- Server A to server B replication:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In both servers stop every connection to the databases. &lt;br /&gt;
Check it with a "show full processlist" and use "kill" if necessary.&lt;br /&gt;
&lt;br /&gt;
[In server A]&lt;br /&gt;
mysql&gt; CREATE USER 'repl'@'ip_server_B' IDENTIFIED BY 'password';&lt;br /&gt;
mysql&gt; GRANT REPLICATION SLAVE ON *.* TO 'repl'@'ip_server_B';&lt;br /&gt;
&lt;br /&gt;
Lock tables:&lt;br /&gt;
mysql&gt;FLUSH TABLES WITH READ LOCK;&lt;br /&gt;
mysql&gt;SHOW MASTER STATUS&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Take note of these values as they will be used later.&lt;/li&gt;
&lt;li&gt;Very important - Keep that mysql client running so tables keep locked.&lt;/li&gt;
&lt;/ul&gt;Backup the entire database:&lt;br /&gt;
mysqldump --all-databases --lock-all-tables --master-data -u root -ppassword &gt; dbdump.db&lt;br /&gt;
Note: --master-data option includes a line with master position &lt;br /&gt;
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS= 270346;&lt;br /&gt;
&lt;br /&gt;
move the backup file to server B:&lt;br /&gt;
scp -v dbdump.db root@ip_server_B:/root/&lt;br /&gt;
&lt;br /&gt;
[In server B]&lt;br /&gt;
recover backup from server A:&lt;br /&gt;
mysql -u root -ppassword &lt; dbdump.db&lt;br&gt;&lt;br /&gt;
mysql&gt;CREATE USER 'repl'@'ip_server_A' IDENTIFIED BY 'password';&lt;br /&gt;
mysql&gt;GRANT REPLICATION SLAVE ON *.* TO 'repl'@'ip_server_A';&lt;br /&gt;
mysql&gt;STOP SLAVE;&lt;br /&gt;
mysql&gt;CHANGE MASTER TO MASTER_HOST='ip_server_A', MASTER_USER='repl', MASTER_PASSWORD='password', MASTER_LOG_FILE='binary_log_file', MASTER_LOG_POS='position';&lt;br /&gt;
Note: For MASTER_LOG_FILE and MASTER_LOG_POS use values you already got.&lt;br /&gt;
&lt;br /&gt;
mysql&gt;START SLAVE;&lt;br /&gt;
mysql&gt; SHOW MASTER STATUS;&lt;br /&gt;
Note: Take note of these values too, as they will be used when replicating server B to server A.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3.-Server B to server A replication:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
[In server A]&lt;br /&gt;
mysql&gt;STOP SLAVE;&lt;br /&gt;
mysql&gt;CHANGE MASTER TO MASTER_HOST='ip_server_B', MASTER_USER='repl', MASTER_PASSWORD='password', MASTER_LOG_FILE='binary_log_file', MASTER_LOG_POS='position';&lt;br /&gt;
Note: For MASTER_LOG_FILE and MASTER_LOG_POS use values you already got.&lt;br /&gt;
&lt;br /&gt;
mysql&gt;START SLAVE;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4.- Summary:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Once finished these steps you should have a high-availability system.&lt;br /&gt;
&lt;br /&gt;
Every change, doesn't matter on which server, should be replicated in the other. And, in case of outage of one of them, the other will keep working and changes will be synchronized when it comes back up again.&lt;br /&gt;
&lt;br /&gt;
It is still in my TODO to test it using linux-ha so that way replication cluster will be transparent for clients using the database.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8255987636826363948-2664738762880848403?l=aliensanti.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliensanti.blogspot.com/feeds/2664738762880848403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aliensanti.blogspot.com/2010/04/mysql-replication-master-master-for-two.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/2664738762880848403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/2664738762880848403'/><link rel='alternate' type='text/html' href='http://aliensanti.blogspot.com/2010/04/mysql-replication-master-master-for-two.html' title='MySQL replication master-master for two hosts'/><author><name>Santiago Bassett</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://3.bp.blogspot.com/_wBC0qcp7pis/S8ovkwr_kdI/AAAAAAAAAE4/HKt4nEGolyQ/S220/Santiago.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255987636826363948.post-7954248047964314671</id><published>2009-10-06T12:00:00.000-07:00</published><updated>2010-04-29T06:40:59.582-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ossim'/><title type='text'>OSSIM Alarms by type radar graph</title><content type='html'>I want to share a new graph configuration I have done for OSSIM "Executive Panel". It just shows most generated alarms in a radar. &lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;a href="http://lh3.ggpht.com/_wBC0qcp7pis/S3lqF54WNmI/AAAAAAAAAEQ/9DahoJFC5kw/alarms_by_type.png"&gt;&lt;img src="http://lh3.ggpht.com/_wBC0qcp7pis/S3lqF54WNmI/AAAAAAAAAEQ/9DahoJFC5kw/alarms_by_type.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
To create it just edit a graph, go to "Category -&gt; Config Import" and paste the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=post-code&gt;plugin_custom_sql::&lt;br /&gt;
YTo0OntzOjY6InBsdWdpbiI7czoyMjoicGx&lt;br /&gt;
1Z2luX2NvbmZpZ19leGNoYW5nZSI7czoxMT&lt;br /&gt;
oicGx1Z2luX29wdHMiO2E6Mjc6e3M6ODoiZ&lt;br /&gt;
3JhcGhfZGIiO3M6NToib3NzaW0iO3M6OToi&lt;br /&gt;
Z3JhcGhfc3FsIjtzOjI0NDoic2VsZWN0IEN&lt;br /&gt;
PTkNBVChTVUJTVFJJTkcoUkVQTEFDRShwbH&lt;br /&gt;
VnaW5fc2lkLm5hbWUsImRpcmVjdGl2ZV9ld&lt;br /&gt;
mVudDogIiwiIiksMSwxNyksIi4uLiIpLCBj&lt;br /&gt;
b3VudCgqKSBhcyBudW0gZnJvbSBhbGFybSw&lt;br /&gt;
gcGx1Z2luX3NpZCAKd2hlcmUgYWxhcm0ucG&lt;br /&gt;
x1Z2luX2lkID0gcGx1Z2luX3NpZC5wbHVna&lt;br /&gt;
W5faWQgYW5kIAphbGFybS5wbHVnaW5fc2lk&lt;br /&gt;
ID0gcGx1Z2luX3NpZC5zaWQKZ3JvdXAgYnk&lt;br /&gt;
gYWxhcm0ucGx1Z2luX3NpZCBsaW1pdCA4Oy&lt;br /&gt;
I7czoxMToiZ3JhcGhfdGl0bGUiO3M6MDoiI&lt;br /&gt;
jtzOjEwOiJncmFwaF90eXBlIjtzOjU6InJh&lt;br /&gt;
ZGFyIjtzOjE4OiJncmFwaF9sZWdlbmRfZml&lt;br /&gt;
lbGQiO3M6Mzoicm93IjtzOjE2OiJncmFwaF&lt;br /&gt;
9wbG90c2hhZG93IjtzOjE6IjEiO3M6MTU6I&lt;br /&gt;
mdyYXBoX3BpZV90aGVtZSI7czo1OiJ3YXRl&lt;br /&gt;
ciI7czoxNzoiZ3JhcGhfcGllXzNkYW5nbGU&lt;br /&gt;
iO3M6MjoiNDUiO3M6MTc6ImdyYXBoX3BpZV&lt;br /&gt;
9leHBsb2RlIjtzOjM6ImFsbCI7czoyMToiZ&lt;br /&gt;
3JhcGhfcGllX2V4cGxvZGVfcG9zIjtzOjE6&lt;br /&gt;
IjEiO3M6MjI6ImdyYXBoX3BpZV9hbnRpYWx&lt;br /&gt;
pYXNpbmciO3M6MToiMSI7czoxNjoiZ3JhcG&lt;br /&gt;
hfcGllX2NlbnRlciI7czo0OiIwLjIzIjtzO&lt;br /&gt;
jE4OiJncmFwaF9wb2ludF9sZWdlbmQiO3M6&lt;br /&gt;
MDoiIjtzOjE3OiJncmFwaF9zaG93X3ZhbHV&lt;br /&gt;
lcyI7czoxOiIwIjtzOjExOiJncmFwaF9jb2&lt;br /&gt;
xvciI7czo3OiIjMDAwMDgwIjtzOjE0OiJnc&lt;br /&gt;
mFwaF9ncmFkaWVudCI7czoxOiIwIjtzOjEw&lt;br /&gt;
OiJncmFwaF9saW5rIjtzOjA6IiI7czoxNjo&lt;br /&gt;
iZ3JhcGhfcmFkYXJfZmlsbCI7czoxOiIxIj&lt;br /&gt;
tzOjExOiJncmFwaF95X21pbiI7czoxOiIwI&lt;br /&gt;
jtzOjExOiJncmFwaF95X21heCI7czoxOiIw&lt;br /&gt;
IjtzOjExOiJncmFwaF94X21pbiI7czoxOiI&lt;br /&gt;
wIjtzOjExOiJncmFwaF94X21heCI7czoxOi&lt;br /&gt;
IwIjtzOjExOiJncmFwaF95X3RvcCI7czoxO&lt;br /&gt;
iIwIjtzOjExOiJncmFwaF95X2JvdCI7czox&lt;br /&gt;
OiIwIjtzOjExOiJncmFwaF94X3RvcCI7czo&lt;br /&gt;
xOiIwIjtzOjExOiJncmFwaF94X2JvdCI7cz&lt;br /&gt;
oxOiIwIjtzOjE1OiJleHBvcnRlZF9wbHVna&lt;br /&gt;
W4iO3M6MTc6InBsdWdpbl9jdXN0b21fc3Fs&lt;br /&gt;
Ijt9czoxMToid2luZG93X29wdHMiO2E6Mzp&lt;br /&gt;
7czoyOiJpZCI7czozOiIxeDMiO3M6NToidG&lt;br /&gt;
l0bGUiO3M6MTQ6IkFsYXJtcyBieSBUeXBlI&lt;br /&gt;
jtzOjQ6ImhlbHAiO3M6MDoiIjt9czoxMToi&lt;br /&gt;
bWV0cmljX29wdHMiO2E6NDp7czoxNDoiZW5&lt;br /&gt;
hYmxlX21ldHJpY3MiO3M6MToiMCI7czoxMD&lt;br /&gt;
oibWV0cmljX3NxbCI7czowOiIiO3M6MTM6I&lt;br /&gt;
mxvd190aHJlc2hvbGQiO2k6MDtzOjE0OiJo&lt;br /&gt;
aWdoX3RocmVzaG9sZCI7aTowO319&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
And, on the other hand, if you are curious about the SQL query, here it is:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=post-code&gt;select CONCAT(SUBSTRING(REPLACE(plugin_sid.name,"directive_event: ",""),1,17),"..."), count(*) as num from alarm, plugin_sid where alarm.plugin_id = plugin_sid.plugin_id and alarm.plugin_sid = plugin_sid.sid group by alarm.plugin_sid limit 8;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8255987636826363948-7954248047964314671?l=aliensanti.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliensanti.blogspot.com/feeds/7954248047964314671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aliensanti.blogspot.com/2010/02/ossim-alarms-by-type-radar-graph.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/7954248047964314671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/7954248047964314671'/><link rel='alternate' type='text/html' href='http://aliensanti.blogspot.com/2010/02/ossim-alarms-by-type-radar-graph.html' title='OSSIM Alarms by type radar graph'/><author><name>Santiago Bassett</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://3.bp.blogspot.com/_wBC0qcp7pis/S8ovkwr_kdI/AAAAAAAAAE4/HKt4nEGolyQ/S220/Santiago.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_wBC0qcp7pis/S3lqF54WNmI/AAAAAAAAAEQ/9DahoJFC5kw/s72-c/alarms_by_type.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255987636826363948.post-1126990581083986868</id><published>2009-09-08T12:00:00.000-07:00</published><updated>2010-04-29T06:56:18.070-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ossim'/><category scheme='http://www.blogger.com/atom/ns#' term='Syslog'/><title type='text'>OSSIM Collecting events with rsyslog</title><content type='html'>This article tries to be a small how-to about OSSIM events collection using rsyslog. For example lets try to configure OSSIM to collect events from a Netscreen firewall.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OSSIM agent&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;First of all we need to active the plugin at /etc/ossim/agent/config.cfg adding a new line to our plugins list. This line could be like the following:&lt;br /&gt;
&lt;div class=post-code&gt;netscreen=/etc/ossim/agent/plugins/netscreen-firewall.cfg &lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Then we will set the "location" variable at the config file of the plugin we want to use. In our case this file will be at /etc/ossim/agent/plugins/netscreen-firewall.cfg (other config files can be found here too). For example lets set it this way:&lt;br /&gt;
&lt;div class=post-code&gt;location=/var/log/netscreen-firewall.log &lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Once finished other two steps don't forget to restart the ossim-agent daemon, so it will load the new configuration. &lt;br /&gt;
&lt;div class=post-code&gt;/etc/init.d/ossim-agent restart&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;b&gt;Rsyslog&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Then it's time to go through rsyslogd configuration.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;To enable logging from remote machines we have to edit /etc/default/syslogd and set SYSLOGD variable to "-r". This line should be enough: &lt;br /&gt;
&lt;div class=post-code&gt;SYSLOGD="-r"&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Then, to use rsyslog v3 native interface (I am not sure if this is needed, but just in case), we will need to set RSYSLOGD_OPTIONS variable to "-c3" at /etc/default/rsyslog file.&lt;br /&gt;
&lt;div class=post-code&gt;RSYSLOGD_OPTIONS="-c3" &lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Now lets edit the /etc/rsyslog.conf file. For our example I will add this lines at the beginning of the logging rules. Be aware of the comments to know what does they do.&lt;br /&gt;
&lt;div class=post-code&gt;# Line 1: Discard logs with "action=Permit" string&lt;br /&gt;
# This is just tuning, as this kind of logs are useless for our security system (as they are accepted by the firewall policy)&lt;br /&gt;
:msg, contains, "action=Permit" ~&lt;br /&gt;
&lt;br /&gt;
# Line 2: If coming from "netscreen_hostname" (at /etc/hosts) send logs to /var/log/netscreen-firewall.log&lt;br /&gt;
# The symbol "-" means that it wont sync every log (faster)&lt;br /&gt;
:fromhost, isequal, "netscreen_hostname" -/var/log/netscreen-firewall.log&lt;br /&gt;
&lt;br /&gt;
# Line 3: Then discard all logs coming from "netscreen_hostname" so they wont be written at system log files.&lt;br /&gt;
:fromhost, isequal, "netscreen_hostname" ~&lt;br /&gt;
&lt;br /&gt;
#... standard logging rules should go right here ...&lt;br /&gt;
&lt;/div&gt;If you need more help with rsyslog.conf possibilities you can find it at:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.rsyslog.com/doc-rsyslog_conf_filter.html"&gt;http://www.rsyslog.com/doc-rsyslog_conf_filter.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;At last we just need to restart rsyslogd daemon:&lt;br /&gt;
&lt;div class=post-code&gt;/etc/init.d/rsyslogd restart &lt;br /&gt;
&lt;/div&gt;At this point it should be listening at port 514 (the default one), you can check it with netstat command. So, once we configure our device to send logs to our OSSIM sensor, they should be collected and correlated.&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;As you can see this how-to is quite simple, but I hope it can help you with your configurations or help me to remember it if needed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8255987636826363948-1126990581083986868?l=aliensanti.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliensanti.blogspot.com/feeds/1126990581083986868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aliensanti.blogspot.com/2010/03/ossim-collecting-events-with-rsyslog.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/1126990581083986868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/1126990581083986868'/><link rel='alternate' type='text/html' href='http://aliensanti.blogspot.com/2010/03/ossim-collecting-events-with-rsyslog.html' title='OSSIM Collecting events with rsyslog'/><author><name>Santiago Bassett</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://3.bp.blogspot.com/_wBC0qcp7pis/S8ovkwr_kdI/AAAAAAAAAE4/HKt4nEGolyQ/S220/Santiago.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8255987636826363948.post-7413540749350535774</id><published>2009-09-01T12:00:00.000-07:00</published><updated>2010-04-29T07:06:43.052-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ossim'/><category scheme='http://www.blogger.com/atom/ns#' term='Exploits'/><title type='text'>OSSIM Detecting a buffer overflow attack</title><content type='html'>&lt;b&gt;Introduction&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I am posting for the first time at my recently opened blog. Hope issues discussed here will be interesting for OSSIM users and probably for some other people.&lt;br /&gt;
&lt;br /&gt;
First thing I will try to explain is how to test OSSIM generating real time attacks, such as exploiting a buffer overflow against a non patched host. For this purpose we will use Micrososft ASN.1 library buffer overflow vulnerability, whose details can be found at &lt;a href="http://www.phreedom.org/solar/exploits/msasn1-bitstring/"&gt; http://www.phreedom.org/solar/exploits/msasn1-bitstring/&lt;/a&gt; We can even find here an exploit called kill-bill to take advantage of the mentioned vulnerability ;-)&lt;br /&gt;
&lt;br /&gt;
Now lets see steps in order to get an alarm with OSSIM and execute an action-response policy...&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;OSSIM configuration&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
1.- Detecting the intrusion with snort rules. In this case it's done by the rule "NETBIOS SMB Session Setup NTMLSSP unicode asn1 overflow attempt". I paste it here, copied from the /etc/snort/rules/netbios.rules file:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="post-code"&gt;netbios.rules:alert tcp $EXTERNAL_NET any -&amp;gt; $HOME_NET 139 (msg:"NETBIOS SMB Session Setup NTMLSSP unicode asn1 overflow attempt"; flow:established,to_server; content:"|00|"; depth:1; content:"|FF|SMBs"; within:5; distance:3; byte_test:1,&amp;amp;,128,6,relative; pcre:"/^.{27}/R"; byte_test:4,&amp;amp;,2147483648,21,relative,little; content:!"NTLMSSP"; within:7; distance:27; asn1:double_overflow, bitstring_overflow, relative_offset 27, oversize_length 2048; reference:bugtraq,9633; reference:bugtraq,9635; reference:cve,2003-0818; reference:nessus,12052; reference:nessus,12065; reference:url,www.microsoft.com/technet/security/bulletin/MS04-007.mspx; classtype:protocol-command-decode; sid:3000; rev:4;) &lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
2.- Next step is to create a simple directive to feed the correlation engine. It can be done at /etc/ossim/server/generic.xml. The one I have created is:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="post-code"&gt;&amp;lt;directive id="24" name="Buffer overflow attempt against DST_IP" priority="9"&amp;gt;&lt;br /&gt;
&amp;lt;rule type="detector" name="Buffer overflow rule matched" reliability="9" occurrence="1" from="ANY" to="ANY" port_from="ANY" port_to="ANY" plugin_id="1001" plugin_sid="2383"/&amp;gt;&lt;br /&gt;
&amp;lt;/directive&amp;gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
This is the simplest form of a directive, but if we want, we can use different levels to detect more complex attacks (i.e. we can add rules matching port scans or session duration...). Here is an example of a port scan with an open port found directive (I also use it for the video demo you will find below):&lt;br /&gt;
&lt;br /&gt;
&lt;div class="post-code"&gt;&amp;lt;directive id="25" name="TCP Portscan against DST_IP" priority="6"&amp;gt;&lt;br /&gt;
&amp;lt;rule type="detector" name="TCP Portscan" reliability="5" occurrence="1" from="ANY" to="ANY" port_from="ANY" port_to="ANY" plugin_id="1122" plugin_sid="1"&amp;gt;&lt;br /&gt;
&amp;lt;rules&amp;gt;&lt;br /&gt;
&amp;lt;rule type="detector" name="portscan: Open Port" reliability="+3" occurrence="1" from="1:SRC_IP" to="1:DST_IP" port_from="ANY" port_to="ANY" plugin_id="1122" plugin_sid="27"/&amp;gt;&lt;br /&gt;
&amp;lt;/rules&amp;gt;&lt;br /&gt;
&amp;lt;/rule&amp;gt;&lt;br /&gt;
&amp;lt;/directive&amp;gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
3.- Last thing is to configure an action (for example sending a mail) to execute when the alarm is generated. We can use the web framework to do it in a easy way.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Video Demo&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Well, at the end, I have decided to upload a video demo which has been made as a proof of concept of all I have been talking before. Its duration is 10:33, it has no sound but I think it's quite self explanatory. Hope you will enjoy it.&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;br /&gt;
&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/vlXrs3NZGzM&amp;hl=en_US&amp;fs=1&amp;rel=0"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/vlXrs3NZGzM&amp;hl=en_US&amp;fs=1&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;
&lt;/center&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8255987636826363948-7413540749350535774?l=aliensanti.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliensanti.blogspot.com/feeds/7413540749350535774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aliensanti.blogspot.com/2010/03/detecting-asn1-buffer-overflow-attack.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/7413540749350535774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8255987636826363948/posts/default/7413540749350535774'/><link rel='alternate' type='text/html' href='http://aliensanti.blogspot.com/2010/03/detecting-asn1-buffer-overflow-attack.html' title='OSSIM Detecting a buffer overflow attack'/><author><name>Santiago Bassett</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://3.bp.blogspot.com/_wBC0qcp7pis/S8ovkwr_kdI/AAAAAAAAAE4/HKt4nEGolyQ/S220/Santiago.png'/></author><thr:total>1</thr:total></entry></feed>
