========
Overview
========
OpenDLP is a free and open source, agent-based, centrally-managed, massively
distributable data loss prevention tool released under the GPL. OpenDLP can
identify sensitive data at rest on thousands of systems simultaneously. OpenDLP
has two components:

Web Application
- Automatically deploy and start agents over Netbios
- When done, automatically stop, uninstall, and delete agents over Netbios
- Pause, resume, and forcefully uninstall agents in an entire scan or on
  individual systems
- Concurrently and securely receive results from hundreds or thousands of
  deployed agents
- Create Perl-compatible regular expressions (PCREs) for finding sensitive data
  at rest
- Create reusable profiles for scans that include whitelisting or blacklisting
  directories and file extensions
- Review findings and identify false positives
- Export results as XML
- Writen in Perl with MySQL backend

Agent
- Runs on Windows 2000 and later systems
- Written in C with no .NET Framework requirements
- Runs as a Windows Service at low priority so users do not see or feel it
- Resumes automatically upon system reboot with no user interaction
- Securely transmit results to web application at user-defined intervals
- Uses PCREs to identify sensitive data inside files
- Performs additional checks on potential credit card numbers to reduce false
  positives

OpenDLP is copyright Andrew Gavin (andrew.opendlp@gmail.com) 2009, 2010.

============
Requirements
============
- Apache 2.x (tested with 2.2.10)
- MySQL (tested with 5.0.70)
- Samba (tested with 3.0.33)
- winexe (http://eol.ovh.org/winexe/) somewhere in $PATH
- Perl (tested with 5.8.8)
- Additional Perl modules (see under "Perl Configuration")
- "sc.exe" from a Windows system


=====================
SSL Certificate Setup
=====================
# taken from http://hausheer.osola.com/docs/9
# Create an RSA server key
openssl genrsa -des3 -out server.key 1024

# Remove the passphrase
openssl rsa -in server.key -out server.key

# Create a self-signed X509 certificate. O, OU, CN must be same as CA stuff
openssl req -new -key server.key -x509 -out server.crt -days 1825

# Setup a new CA. O, OU, CN must be same as server keys
/etc/ssl/misc/CA.pl -newca

# Create a client key
openssl genrsa -out client.key 1024

# Create a certificate request. O must be same. OU and CN must be different!
openssl req -new -key client.key -out client.csr

# Sign the certificate request.
openssl ca -in client.csr -cert server.crt -keyfile server.key -out client.crt -days 9999

# Create PKCS12 file. Distribute this to other OpenDLP admins for use in their
  browsers.
openssl pkcs12 -export -in client.crt -inkey client.key -out client.p12

# Remove password, convert to pkcs12 to PEM
# client.pem is distributed to systems
openssl pkcs12 -in client.p12 -out client.pem -nodes

# convert server.crt/server.key to server.p12
openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12

# Remove password, convert to pkcs12 to PEM
# server.pem is distributed to systems
openssl pkcs12 -in server.p12 -out server.pem -nodes

# Copy client.pem and server.pem to the web server at:
# /var/www/localhost/OpenDLP/bin

====================
Apache Configuration
====================
Add the following to your Apache configuration file. You will want to create an
htaccess user to protect the contents of this application.

ScriptAlias /OpenDLP/ /var/www/localhost/OpenDLP/web/bin/
<Directory "/var/www/localhost/OpenDLP/web/bin/results/">
        Options FollowSymLinks
        AllowOverride None
        order allow,deny
        allow from all
        AuthType Basic
        AuthName "OpenDDT"
        AuthUserFile /etc/apache2/.htpasswd.dlp.agent
        Require user ddt
</Directory>
<Directory "/var/www/localhost/OpenDLP/web/bin/">
        Options FollowSymLinks
        AllowOverride None
        order allow,deny
        allow from all
        AuthType Basic
        AuthName "OpenDDT"
        AuthUserFile /etc/apache2/.htpasswd.dlp.user
        Require user dlpuser
</Directory>

Also add this stuff to the Apache config file:
# taken from http://hausheer.osola.com/docs/9
SSLVerifyClient require
SSLCertificateFile /path/to/server.crt
SSLCertificateKeyFile /path/to/server.key
SSLCACertificateFile /path/to/server.crt

Modify your /etc/apache2/vhosts.d/00_default_ssl_vhost.conf file so that it
points to the correct "crt" and "key" files.

Recursively put OpenDLP's "OpenDLP/web/bin/" files into
  "/var/www/localhost/OpenDLP/web/bin/".
Put OpenDLP's "OpenDLP/web/etc/" files into
  "/var/www/localhost/OpenDLP/web/etc/".
Put OpenDLP's "OpenDLP/bin/" files into "/var/www/localhost/OpenDLP/bin/".

Run "htpasswd" or "htpasswd2" to create the files:
- /etc/apache2/.htpasswd.dlp.user
- /etc/apache2/.htpasswd.dlp.agent
".htpasswd.dlp.agent" will be used when you create policies. This will be your
  username and password for the "phonehomeuser" and "phonehomepassword" options.
".htpasswd.dlp.user" will be used for you to authenticate to the web
  application. 


===================
MySQL Configuration
===================
You must create OpenDLP's database and table structures with the following
commands:

1. Authenticate to MySQL as your root user.
2. mysql> CREATE DATABASE OpenDLP;
3. mysql> USE OpenDLP;
4. mysql> CREATE TABLE profiles (profile VARCHAR(64), username VARCHAR(128),\
   password VARCHAR(255), domain VARCHAR(255), exts TEXT, ignore_exts \
   VARCHAR(10), dirs TEXT, ignore_dirs VARCHAR(10), regex TEXT, path TINYTEXT,\
   phonehomeurl VARCHAR(255), phonehomeuser VARCHAR(32), phonehomepass \
   VARCHAR(32), delaytime SMALLINT UNSIGNED, description VARCHAR(128), \
   debug SMALLINT UNSIGNED, number SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, \
   primary key (number), concurrent SMALLINT UNSIGNED);
5. mysql> CREATE TABLE systems (scan VARCHAR(64), system VARCHAR(255), domain\
   VARCHAR(255), ip VARCHAR(40), filestotal INT, filesdone INT, bytestotal\
   BIGINT, bytesdone BIGINT, status VARCHAR(10), updated VARCHAR(12), \
   tracker VARCHAR(32), profile VARCHAR(64), control VARCHAR(16));
6. mysql> CREATE TABLE results (scan VARCHAR(64), system VARCHAR(64), domain \
   VARCHAR(255), type VARCHAR(64), pattern VARCHAR(255), file VARCHAR(8096),\
   offset BIGINT UNSIGNED, md5 VARCHAR(32), tracker VARCHAR(32), number \
   BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, primary key (number), is_false \
   TINYINT);
7. mysql> CREATE TABLE regexes (name VARCHAR(64), pattern TEXT, number \
   SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, primary key (number));
8. mysql> CREATE TABLE falsepositives (scan VARCHAR(64), tracker VARCHAR(32), \
   domain VARCHAR(255), type VARCHAR(64), file VARCHAR(8096), offset BIGINT \
   UNSIGNED, md5 VARCHAR(32));
9. mysql> CREATE TABLE logs (tracker VARCHAR(32), line INT UNSIGNED, data \
   VARCHAR(255), updated VARCHAR(12), scan VARCHAR(64), profile VARCHAR(64));

Populate the database with some default regexes. The credit card regex names are
hardcoded into the client, so use these same names in the database. The client
does mod10 checks on matches (to cut down on false positives) and needs to know
that the following regexes are credit cards.

1. mysql> load data infile \
  '/var/www/localhost/OpenDLP/web/etc/default_regexes' into table regexes \
  fields terminated by ':';

You will need to create a MySQL user for OpenDLP. Replace "OpenDLP" and
  "password" with whatever you like. Keep in mind that OpenDLP's tables will
  likely contain sensitive information, so use strong authentication
  credentials. These credentials are not distributed with the agent to Windows
  systems, they are only kept on the web server.
1. mysql> create user 'OpenDLP'@'localhost' identified by 'password';
2. mysql> grant all privileges on OpenDLP.* to 'OpenDLP'@'localhost';


=============================
Web Application Configuration
=============================
1. Edit "/var/www/localhost/OpenDLP/etc/db_admin" so it contains the MySQL
   authentication credentials delimited by a colon.  Example:
   OpenDLP:password
2. Copy Microsoft Windows' "sc.exe" to "/var/www/localhost/OpenDLP/bin/".
   OpenDLP uses this to install the agent as a Windows service on Windows
   systems. It cannot be distributed with OpenDLP because of licensing issues.
   "sc.exe" is freely available from Microsoft, so use The Google to find it.


==================
Perl Configuration
==================
OpenDLP requires the following modules:
1. CGI
2. DBI
3. Filesys::SmbClient
4. Proc::Queue
5. XML::Writer
6. MIME::Base64


=========================================
Web Server Operating System Configuration
=========================================
1. Copy "winexe" so it is somewhere in Apache's $PATH. "/usr/bin" is a good
   start.
2. Optional: You may want to put the MySQL tables on a Truecrypt volume. This
   is out of scope for this tool, but documentation is available on Truecrypt's
   website on how to configure this.


=====================
Browser configuration
=====================
1. Firefox
	A. Go to Firefox's preferences
	B. Go to the "Advanced" tab
	C. Go to the "Encryption" sub-tab
	D. Click the "View Certificates" button
	E. In the "Certificate Manager" window, go to the "Your Certificates"
           tab
	F. Click the "Import..." button
	G. Find the "client.pem" file and import it

