Tuesday, November 10, 2009

Backup/Restore MySQL Databases

BACKUP ALL DATABASES:

#!/bin/sh
#
# SCRIPT TO DUMP ALL THE DATABASES
#
PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/lib:/etc
export PATH

/usr/bin/mysqldump -u root --password=<your mysql root password> --all-databases | gzip > /root/mysqlbackup/databasebackup.sql.gz

RESTORE ALL DATABASES:

/usr/bin/mysql -u root -p < databasebackup.sql.gz

enter your root password when prompted

Monday, August 24, 2009

US Debt Clock

WHY ARE WE STILL SPENDING MONEY WE DON'T HAVE????????


This is a view of the website US Debt Clock.org

Saturday, April 18, 2009

Rsync, scp, and ssh without passwords

A great writeup about this is here.
Whenever you need to use scp to copy files, it asks for passwords. Same with rsync as it (by default) uses ssh as well. Usually scp and rsync commands are used to transfer or backup files between known hosts or by the same user on both the hosts. It can get really annoying the password is asked every time. I even had the idea of writing an expect script to provide the password. Of course, I didn’t. Instead I browsed for a solution and found it after quite some time. There are already a couple of links out there which talk about it. I am adding to it…

Lets say you want to copy between two hosts host_src and host_dest. host_src is the host where you would run the scp, ssh or rsync command, irrespective of the direction of the file copy!

1. On host_src, run this command as the user that runs scp/ssh/rsync

$ ssh-keygen -t rsa

This will prompt for a passphrase. Just press the enter key. It’ll then generate an identification (private key) and a public key. Do not ever share the private key with anyone! ssh-keygen shows where it saved the public key. This is by default ~/.ssh/id_rsa.pub:

Your public key has been saved in <your_home_dir>/.ssh/id_rsa.pub

2. Transfer the id_rsa.pub file to host_dest by either ftp, scp, rsync or any other method.

3. On host_dest, login as the remote user which you plan to use when you run scp, ssh or rsync on host_src.

4. Copy the contents of id_rsa.pub to ~/.ssh/authorized_keys

$ cat id_rsa.pub >>~/.ssh/authorized_keys
$ chmod 700 ~/.ssh/authorized_keys

5. If this file does not exists, then the above command will create it. Make sure you remove permission for others to read this file. If its a public key, why prevent others from reading this file? Probably, the owner of the key has distributed it to a few trusted users and has not placed any additional security measures to check if its really a trusted user. Note that ssh by default does not allow root to log in. This has to be explicitly enabled on host_dest. This can be done by editing /etc/ssh/sshd_config and changing the option of PermitRootLogin from no to yes. Don’t forget to restart sshd so that it reads the modified config file. Do this only if you want to use the root login.  Please note, there seems to be an exception to this addition if your system uses PAM for authentication, so test.

Well, thats it. Now you can run scp, ssh and rsync on host_src connecting to host_dest and it won’t prompt for the password. Note that this will still prompt for the password if you are running the commands on host_dest connecting to host_src. You can reverse the steps above (generate the public key on host_dest and copy it to host_src) and you have a two way setup ready!

Friday, April 10, 2009

Removing SSL Vulnerabilities on Webservers

A great website for reference is here.

IIS CONFIG

Create a sslvulnerabilityremoval.reg file with the following and merge it onto the Windows Server (2003 in my case) and reboot.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\PCT 1.0\Server]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\DES 56/56]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\NULL]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC2 40/128]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC2 56/128]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 40/128]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 56/128]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 64/128]
"Enabled"=dword:0000000

APACHE CONFIG

Here's a basic setup in the httpd.conf file for Apache

<VirtualHost *:443>
ServerName whatever.yourdomain.com
DocumentRoot "/export/web/html"
ErrorLog logs/whatever.yourdomain.com_error_log
CustomLog logs/whatever.yourdomain.com_access_log common

<Directory "/export/web/html">
Options FollowSymlinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

SSLEngine on

SSLProtocol -ALL +SSLv3 +TLSv1
SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM

SSLCertificateFile /etc/httpd/conf/ssl/whatever.yourdomain.com.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl/whatever.yourdomain.com.key
SSLCertificateChainFile /etc/httpd/conf/ssl/intermediate.crt

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]

</VirtualHost>

TESTING

You should receive an error on each of these tests.  If you receive a lot of information, you're vulnerable.

Testing for SSLv2 vulnerabilities

# openssl s_client -ssl2 -connect SERVERNAME:443

Testing for weak ciphers

# openssl s_client -connect SERVERNAME:443 -cipher LOW:EXP

Tuesday, March 17, 2009

Apache 2.2 SSL Setup including redirect

Usually done in /etc/httpd/conf.d/ssl.conf

I comment out the virtual host in the above file and add the relevant data to my file.

NameVirtualHost 192.168.1.1:80
NameVirtualHost 192.168.1.1:443

<VirtualHost 192.168.1.1:80>
ServerName whatever.yoursite.com
DocumentRoot "/export/web/html"
ErrorLog logs/whatever.yoursite.com_error_log
CustomLog logs/whatever.yoursite.com_access_log common

Redirect / https://whatever.yoursite.com/

</VirtualHost>

<VirtualHost 192.168.1.1:443>
ServerName whatever.yoursite.com
DocumentRoot "/export/web/html"
ErrorLog logs/whatever.yoursite.com_error_log
CustomLog logs/whatever.yoursite.com_access_log common
##LogLevel debug
<Directory "/export/web/html">
Options FollowSymlinks
AllowOverride None
Order allow,deny
Allow from all
AuthName "LDAP Authorization"
AuthType Basic

### The next 2 lines are required in Apache 2.2
AuthBasicProvider ldap
AuthzLDAPAuthoritative off

AuthLDAPBindDN "ldapuser@ad_domain"
AuthLDAPBindPassword "password"
AuthLDAPURL "ldap://AD_Domain_Controller/ou=Users,dc=yoursite,dc=com?sAMAccountName?sub"

### Either use valid-user or ldap-user
#require valid-user
require ldap-user user1 user2 user3 user4
require ldap-user user5 user6 user7 user8

satisfy all
</Directory>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM

SSLCertificateFile /etc/httpd/conf/ssl/yoursite.com.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl/yoursite.com.key
SSLCertificateChainFile /etc/httpd/conf/ssl/bundle.crt

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]

</VirtualHost>

Apache 2.2 ldap setup

NameVirtualHost 192.168.x.x:80

<VirtualHost 192.168.x.x:80>
ServerName whatever.yoursite.com
DocumentRoot "/export/web/html"
ErrorLog logs/whatever.yoursite.com_error_log
CustomLog logs/whatever.yoursite.com_access_log common
##LogLevel debug

<Directory "/export/web/html">Options FollowSymlinks
AllowOverride None
Order allow,deny
Allow from all
AuthName "LDAP Authorization"
AuthType Basic

### The next 2 lines are required in Apache 2.2
AuthBasicProvider ldap
AuthzLDAPAuthoritative off

AuthLDAPBindDN "ldapusername@yourad"
AuthLDAPBindPassword "password"
AuthLDAPURL "ldap://fqdn_of_your_AD_server/ou=Users,dc=yoursite,dc=com?sAMAccountName?sub"

### Either use valid-user or ldap-user
#require valid-user
require ldap-user user1 user2 user3 user4
require ldap-user user5 user6 user7 user8

satisfy all

</Directory>
</VirtualHost>

Sunday, March 15, 2009

Uncle Jay explains Congress

I love this video.  Seriously, why aren't we doing term limits?


Sunday, March 1, 2009

Stop gossiping

Gossips cause distance

  • Proverbs 16:28
    28  A perverse man stirs up dissension, and a gossip separates close friends.


Avoid gossips

  • Proverbs 20:19
    19  A gossip betrays a confidence; so avoid a man who talks too much.


Gossips cause quarrels

  • Proverbs 26:20
    20  Without wood a fire goes out; without gossip a quarrel dies down.


Gossiping accompanies other sins

  • 2 Corinthians 12:20
    20  For I am afraid that when I come I may not find you as I want you to be, and you may not find me as you want me to be. I fear that there may be quarreling, jealousy, outbursts of anger, factions, slander, gossip, arrogance and disorder.

Remove anger

Don't be angry

  • Proverbs 29:8-11
    8  Mockers stir up a city, but wise men turn away anger.
    9  If a wise man goes to court with a fool, the fool rages and scoffs, and there is no peace.
    10  Bloodthirsty men hate a man of integrity and seek to kill the upright.
    11  A fool gives full vent to his anger, but a wise man keeps himself under control.


Anger makes you a fool

  • Ecclesiastes 7:9
    9  Do not be quickly provoked in your spirit, for anger resides in the lap of fools.


Actively remove anger

  • Ephesians 4:31-32
    31  Get rid of all bitterness, rage and anger, brawling and slander, along with every form of malice.
    32  Be kind and compassionate to one another, forgiving each other, just as in Christ God forgave you.

  • Colossians 3:8 8  But now you must rid yourselves of all such things as these: anger, rage, malice, slander, and filthy language from your lips.


Anger isn't holy

  • James 1:20
    20  for man's anger does not bring about the righteous life that God desires.

Contentment

Lean on God

  • Philippians 4:11-13
    11  I am not saying this because I am in need, for I have learned to be content whatever the circumstances.
    12  I know what it is to be in need, and I know what it is to have plenty. I have learned the secret of being content in any and every situation, whether well fed or hungry, whether living in plenty or in want.
    13  I can do everything through him who gives me strength.


Be honest, stop arguing, and be content

  • James 4:1-3
    1  What causes fights and quarrels among you? Don't they come from your desires that battle within you?
    2  You want something but don't get it. You kill and covet, but you cannot have what you want. You quarrel and fight. You do not have, because you do not ask God.
    3  When you ask, you do not receive, because you ask with wrong motives, that you may spend what you get on your pleasures.

Budgeting/Planning

Lack of planning leads to ruin

  • Luke 14:28-30
    28  "Suppose one of you wants to build a tower. Will he not first sit down and estimate the cost to see if he has enough money to complete it?
    29  For if he lays the foundation and is not able to finish it, everyone who sees it will ridicule him,
    30  saying, 'This fellow began to build and was not able to finish.'

  • Proverbs 21:5
    5  The plans of the diligent lead to profit as surely as haste leads to poverty.


Plan ahead

  • Proverbs 13:16
    16  Every prudent man acts out of knowledge, but a fool exposes his folly.


Comments

  • "Trying" doesn't cut it.  You plan for success.

Debt talking points

Debt is evil

  • Psalm 37:21a
    21  The wicked borrow and do not repay


Debt isn't normal

  • Isaiah 5:20
    20  Woe to those who call evil good and good evil, who put darkness for light and light for darkness, who put bitter for sweet and sweet for bitter.


Debt is slavery

  • Proverbs 22:7
    7  The rich rule over the poor, and the borrower is servant to the lender.


Owe nothing

  • Romans 13:7-8
    7  Give everyone what you owe him: If you owe taxes, pay taxes; if revenue, then revenue; if respect, then respect; if honor, then honor.
    8  Let no debt remain outstanding, except the continuing debt to love one another, for he who loves his fellowman has fulfilled the law.


Don't cosign

  • Proverbs 22:26-27
    26  Do not be a man who strikes hands in pledge or puts up security for debts;
    27  if you lack the means to pay, your very bed will be snatched from under you.

  • Proverbs 11:15
    15  He who puts up security for another will surely suffer, but whoever refuses to strike hands in pledge is safe.

  • Proverbs 17:18
    18  A man lacking in judgment strikes hands in pledge and puts up security for his neighbor.


Actions, actions, actions ... not words

  • Ecclesiastes 5:5-7
    5  It is better not to vow than to make a vow and not fulfill it.
    6  Do not let your mouth lead you into sin. And do not protest to the temple messenger, "My vow was a mistake." Why should God be angry at what you say and destroy the work of your hands?
    7  Much dreaming and many words are meaningless. Therefore stand in awe of God.


Don't make excuses,  be honest about the situation

  • Galatians 6:7
    7  Do not be deceived: God cannot be mocked. A man reaps what he sows.


Comments

  • Debt is evil.  You're a slave to the lender and are responsible for paying things back.  If you are spending money you don't have, you are following the non-righteous (evil) path.

Get out of debt

The debt problem

  • Habakkuk 2:7
    7  Will not your debtors suddenly arise? Will they not wake up and make you tremble? Then you will become their victim.


Proper method

  • Romans 13:7-8
    7  Give everyone what you owe him: If you owe taxes, pay taxes; if revenue, then revenue; if respect, then respect; if honor, then honor.
    8  Let no debt remain outstanding, except the continuing debt to love one another, for he who loves his fellowman has fulfilled the law.


Comments

  • Debt causes you to live in a state of fear.  The Bible clearly states that we are to pay people what we owe them.  Don't fool yourself into believing debt is ok.

Things to do and think about

How we are to think

  • Philippians 4:8
    8  Finally, brothers, whatever is true, whatever is noble, whatever is right, whatever is pure, whatever is lovely, whatever is admirable--if anything is excellent or praiseworthy--think about such things.


What our life should show

  • Galatians 5:22-23
    22  But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness,
    23  gentleness and self-control. Against such things there is no law.


Be happy, do good, and enjoy your work

  • Ecclesiastes 2:24-26
    24  A man can do nothing better than to eat and drink and find satisfaction in his work. This too, I see, is from the hand of God,
    25  for without him, who can eat or find enjoyment?
    26  To the man who pleases him, God gives wisdom, knowledge and happiness, but to the sinner he gives the task of gathering and storing up wealth to hand it over to the one who pleases God. This too is meaningless, a chasing after the wind.

Stop worrying

Uselessness of worrying

  • Matthew 6:25-27
    25  "Therefore I tell you, do not worry about your life, what you will eat or drink; or about your body, what you will wear. Is not life more important than food, and the body more important than clothes?
    26  Look at the birds of the air; they do not sow or reap or store away in barns, and yet your heavenly Father feeds them. Are you not much more valuable than they?
    27  Who of you by worrying can add a single hour to his life ?


One day at a time

  • Matthew 6:34
    34  Therefore do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of its own.


Don't be anxious

  • Philippians 4:6-7
    6  Do not be anxious about anything, but in everything, by prayer and petition, with thanksgiving, present your requests to God.
    7  And the peace of God, which transcends all understanding, will guard your hearts and your minds in Christ Jesus.


Strength against man

  • Hebrews 13:6
    6  So we say with confidence, "The Lord is my helper; I will not be afraid. What can man do to me?"

Prayer

Prayer is between just God and you - not for showing off to others

  • Matthew 6:5-8
    5  "And when you pray, do not be like the hypocrites, for they love to pray standing in the synagogues and on the street corners to be seen by men. I tell you the truth, they have received their reward in full.
    6  But when you pray, go into your room, close the door and pray to your Father, who is unseen. Then your Father, who sees what is done in secret, will reward you.
    7  And when you pray, do not keep on babbling like pagans, for they think they will be heard because of their many words.
    8  Do not be like them, for your Father knows what you need before you ask him.


An example of prayer from Christ

  • Matthew 6:9-15
    9  "This, then, is how you should pray: "'Our Father in heaven, hallowed be your name,
    10  your kingdom come, your will be done on earth as it is in heaven.
    11  Give us today our daily bread.
    12  Forgive us our debts, as we also have forgiven our debtors.
    13  And lead us not into temptation, but deliver us from the evil one.'
    14  For if you forgive men when they sin against you, your heavenly Father will also forgive you.
    15  But if you do not forgive men their sins, your Father will not forgive your sins.


Once saved, the Holy Spirit helps us in our prayers

  • Romans 8:26
    26  In the same way, the Spirit helps us in our weakness. We do not know what we ought to pray for, but the Spirit himself intercedes for us with groans that words cannot express.


Comments

  • Prayer isn't designed for us to "get" what we want from God.  Its main purpose is to bring us into alignment with God's will.  When you pray, you're talking to God.  There are no special words.  It's just you talking to God.

How to get to heaven

We're sinners

  • Romans 3:23
    23  for all have sinned and fall short of the glory of God


Christ died for our sins

  • 1 Corinthians 15:3-4
    3  For what I received I passed on to you as of first importance : that Christ died for our sins according to the Scriptures,
    4  that he was buried, that he was raised on the third day according to the Scriptures


You must believe Christ died for your sins

  • John 3:16
    16  "For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.


Christ is the only way into heaven

  • John 14:6
    6  Jesus answered, "I am the way and the truth and the life. No one comes to the Father except through me.


Comments

  • Getting to heaven is a simple matter of believing that you're a sinner and Christ died for your sins.  The key here is belief.  Just saying it does nothing.

Wednesday, February 11, 2009

Sonicwall Hidden Administration Page

http(s)://hostname/Diag.html

Tuesday, January 20, 2009

Repairing Windows

You need to get a Windows XP from someone and follow these instructions:
Windows could not start because the following files is missing or corrupt
\WINDOWS\SYSTEM32\CONFIG\SYSTEM or \WINDOWS\SYSTEM32\CONFIG\SOFTWARE

1. Insert and boot from your Windows XP CD.
2. At the first R=Repair option, press the R key
3. Press the number that corresponds to the correct location for the installation of Windows you want to repair.
Typically this will be #1
4. Enter in the administrator password when requested
5. cd \windows\system32\config
6. Depending on which section was corrupted:
ren software software.bad or ren system system.bad
7. Depending on which section was corrupted
copy \windows\repair\system
copy \windows\repair\software
8. Take out the CD ROM and type exit

If that doesn't work or you can't get into the repair console then With the XP disk you choose to install Windows XP and when you choose to install over the current XP installation you will be given the option to repair the current Windows installation and you won't lose all of your data.