Friday, March 13, 2015

Protecting Your Online Identity

Have you had your online identity stolen? Had your Twitter or Facebook account compromised? Do you use the same username and password across multiple sites on the Internet? Everyday, hackers are exposing weak security practices of not only company websites but also attacking online identities, putting you at risk.
Having to remember multiple usernames, passwords and the websites used for those credentials is a problem for everyone. Some people write them on a piece of paper, a text file or spreadsheet stored on their computer, or use the same credentials across all websites. These poor password management practices greatly increase the risk to your identity. There are a number of ways to simplify the problem by utilizing multifactor authentication or using a password management application.
Multifactor authentication is best described as something you know, something you have, or something you are. When authenticating to an application you need to use two of the three before the application allows access. This is not a new concept. If you use a debit card, you use this type of authentication all the time without realizing it. When you make a purchase or withdraw money out of an ATM, you first insert your card (something you have) and then type in your PIN (something you know).
The difference between your debit card and using multifactor authentication online is the PIN changes at a particular interval, usually 60 seconds. Once that PIN has been used, and authentication is successful, that PIN cannot be reused. This prevents someone who may have seen your username, password, and PIN, so they cannot use it themselves.
Banks, social media, cloud storage companies, even Apple, Microsoft and Google have integrated multifactor authentication into their applications, as they understand how important it is. Some send out text messages to a registered cellular phone, while others provide the second factor through a smartphone app. There are other companies which will consolidate all the applications into one, saving you from having multiple smart apps which all do the same thing.
In the event a particular service does not provide multifactor authentication, there are password management applications that can help. These tools not only remember the username and password for a service, they will also generate secure passwords for you. These applications are independent of password managers which are part of a particular web browser and are encrypted. Some password management services sync passwords to the cloud so they are available on any device. There are password management services which provide "zero knowledge" to your information, so only you have access to your credentials and allow multifactor authentication when accessing your passwords from an untrusted device.
To begin, use your favorite search engine and look for both “password managers” and “multifactor authentication smartphone app.” These services are generally free or have a low monthly cost for personal use. Integrating these services with your online identity will not only streamline the authentication process, it will greatly increase the protections to that identity.

Sunday, October 20, 2013

Creating a Blackhole DNS with Bind 9

​Malware can be delivered many different ways from either advertisements (remember the NY Times malicous ads?) to hacked websites that contain malicious code.  One technique designed to help curb these infections is through the use of DNS blackhole.  This technique will redirect your internal users to an internal website to block their access.  To do so, first install Bind on your Linux server.  Then edit your named.conf file which should be located in /etc/bind and enter:

     include "/etc/named/blackhole.conf";

Create a new file called blackhole.conf.  This file will contain every website you wish to redirect to an internal site, effectivly blocking your users from accessing it:

     zone "" {type master; file "/etc/bind/blackhole.db";};

Each additional website that you want to block should containt he same format as the one stated above.
Next, create your zone file which will redirect all traffic destined to FQDN's listed in the blackhole.db file to your internal website:

$TTL 3600
@ IN SOA (
                                                                      20131020 ;
                                                                      3600  ;
                                                                      600  ;
                                                                      86400  ;
                                                                      600 )


* IN A
There are plenty of websites on the Internet that maintain an updated list of malware websites.  One that I use quite frequently is Malware Domain List

Sunday, August 26, 2012

Part 2: Adding the firewall rules

In part two of this series we're going to discuss adding firewall rules to the router.  Everyone knows that adding ingress (or incoming) firewall rules is important to securing your network.  However, the same can be said for adding egress rules for traffic leaving your network.  For instance, aside from an email server, no client should ever send traffic to the Internet via TCP port 25.  If you see traffic like this, it could mean that you have an infected computer within your network.  Egress firewall rules, along with logging of those rules, will help track down problems before it gets out of hand.  

First lets up the ingress rules to protect the router from incoming traffic we do not want.
    iptables -A INPUT -m state --state INVALID -j DROP
    iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -A INPUT -s -p icmp -j ACCEPT
    iptables -A INPUT -i lo -j ACCEPT
    iptables -A INPUT -s -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
    iptables -A INPUT -i eth0 -j LOG --log-prefix " *** IPTABLES DENY IN *** "
    iptables -A INPUT -j REJECT

The first rule allows us to configure the stateful firewall.  Any connections that are already established on the server is allowed through, new connections will not be allowed by this line.  The second rule allows for internal clients to ping their default gateway.  Third rule is VERY IMPORTANT as it allows server traffic to be allowed on the loopback interface.  Most Linux communication including X and service daemons use the loopback for internal communication.  If you do not allow this rule then you could kill everything.  The fourth line allows internal traffic to connect through SSH for remote administration.  We can further restrict SSH by only allowing SSH keys, or if you have a monitor hooked up to the router you could skip this rule altogether.  And the last rule blocks all other incoming traffic to the router.

Now lets setup the egress rules on the router.  To do this, we will use the forward table in iptables.  This is used to forward traffic from one interface to another.
    iptables -A FORWARD -m state --state INVALID -j DROP
    iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
    iptables -A FORWARD -i eth1 -p tcp -m tcp --dport 22 -j ACCEPT
    iptables -A FORWARD -i eth1 -p tcp -m tcp --dport 80 -j ACCEPT
    iptables -A FORWARD -i eth1 -p tcp -m tcp --dport 443 -j ACCEPT
    iptables -A FORWARD -i eth1 -p tcp -m tcp --dport 465 -j ACCEPT
    iptables -A FORWARD -i eth1 -p tcp -m tcp --dport 587 -j ACCEPT
    iptables -A FORWARD -i eth1 -p tcp -m tcp --dport 993 -j ACCEPT
    iptables -A FORWARD -i eth1 -j LOG --log-prefix " *** IPTABLES DENY OUT *** "
    iptables -A FORWARD -j REJECT
    iptables -A FORWARD -s -i eth0 -j DROP

The first rule for this is similar to the first rule to the last set.  The next set of rules allow internal clients to connect to any server on the Internet using SSH, HTTP/HTTPS, and email.  The last few lines are important as first we log dropped packets, then drop packets that do not meet the lines above, and then an anti-spoofing line.  We will talk about logging in a minute, I just want to point out one additional thing.  Be extremely careful when creating egress firewall rules as this will break things.  For instance, if someone needs to establish an outgoing VPN connection then you will need to add those rules in or it will not work.

To get IPTABLES to log dropped packets to a log file, we use rsyslog.  In the /etc/rsyslog.conf file add the following lines:
    :msg,startswith," *** IPTABLES DENY OUT *** " /var/log/iptables-egress
    :msg,startswith," *** IPTABLES DENY IN *** " /var/log/iptables-ingress
Now start the rsyslog daemon and restart iptables and you'll be all set.

PyMyDB Backup 0.5.1

The first version of PyMyDB Backup has been released and is based on Python 2.4.3. This is a Python script that will back up your MySQL databases, calculate the size of the backed up files, tarball and compress the contents, then email the results.
To use:
    Download the EPEL RPM which can be found at:
     Install pymydb-0.5.1-1.noarch.rpm which can be found at: GitHub
         This script creates the necessary directories and user account
     After installation, there will be two scripts placed in /usr/local/bin which are and
     Run the script, this will configure the script
         Logs into the MySQL server
         Creates the backup user, sets a password, and gives him select and lock tables privileges
         Configures the email settings
     Change the permissions on the script
         chown root.pymydb
     Add the script into cron and make sure to add a password for the system user
 You can download it at my GitHub page

Friday, August 3, 2012

Setting up NAT with CentOS/Red Hat 6

​This will be part 1 in a series of configuring CentOS/Red Hat 6 as a secured firewall. Though I am a huge fan of pfSense (which can be found here pfSense), I wanted to build my own from scratch. So, the first part of this series will consist of setting up PAT (or NAT overload for the Cisco geeks) on Linux.
The first step is to configure the network cards.  In this scenario we will use eth0 as the WAN connection and eth1 as the LAN connection.  Refer to the diagram below
 | ISP - | <--- | eth0(WAN) - | --- NAT Server --- | eth1(LAN) - | ---> Internal Network
Edit both the ifcfg-eth0 and the ifcfg-eth1 files located in /etc/sysconfig/network-scripts/, make sure both of the network cards are set to BOOTPROTO="static".
The second step is to setup IP forwarding which can be done by editing the /etc/sysctl.conf file and adding
    net.ipv4.ip_forward = 1
You can then either reload the server or issue the 'sysctl -p' command. Once that command is run, you will see the output of the command and you should see 'net.ipv4.ip_forward = 1' in the output. You can also verify by running 'cat /proc/sys/net/ipv4/ip_forward' and it will return a '1'. If it returns a 0 then the command did not run correctly and you need to try again.
The last step is to set up masquerade with IPTABLES. As eth0 is your outside (or WAN) connection, run
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Connect a laptop to the eth1 NIC with a crossover cable, and statically set the IP address to with the default gateway of  You should now be able to ping out of the LAN to the Internet. If successful run,
    service iptables save
which will save the command to the /etc/sysconfig/iptables file when either the service or the server is reloaded.

Saturday, June 9, 2012

Mounting a USB Device In a Xen Guest

​Mounting a USB device
 Attach the USB device to the Dom0 and run ‘dmesg’ to see if the device attached
 Run ‘fdisk -l’ to see if the drive is partitioned the way you want it
 For instance:
[root@example ~]# fdisk -l /dev/sdc
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
dev/sdc1 1 121601 976760001 8e Linux LVM
Now find a drive letter that is not being used on the DomU, in this instance we’ll use /dev/sde
To attach the USB device to the DomU run the following command
    xm block-attach exampledomu phy:/dev/sdc sde w
You should now see the device on the DomU, run either ‘dmesg’ or ‘fdisk -l’ to verify
Mount the device as normal
    mount /dev/sde1 /mnt/usb
Unmounting the device
You first need to get the device id number from the block list. Do this by running:
    xm block-list exampledomu
This will return:
    Vdev BE handle state evt-ch ring-ref BE-path
    51712 0 0 4 9 8 /local/domain/0/backend/tap/23/51712
    2176 0 0 4 10 1338 /local/domain/0/backend/vbd/23/2176
The number you need to use to remove the device is 2176
Unmount the USB device from the DomU
     umount /mnt/usb

 Now on the Dom0 run:
     xm block-detach exampledomu 2176
 You may now remove the USB device

Getting Linksys AE2500 to work with Fedora 17

​In order to get the AE2500 wireless USB adapter to work you must install ndiswrapper. First, the ndiswrapper-1.57 version is not compatible with the 3.3 or 3.4 version of the Linux kernel so you must install the ndiswrapper-1.58rc1 which is still in test as of this writing. Next, download the AE2500 Windows XP drivers from the Linksys website ( Link ). Unzip the drivers into a directory and load the bcmwlhigh5.inf file into ndis. Once this is done, you can run the 'ndiswrapper -l' command to verify that it is installed correctly. Finally, run 'modprobe ndiswrapper' to load the driver into the kernel. Once this is complete you should see the wireless USB device come up as wlan0 and ready for use.