Knowledge Sharing - Want to participate in the discussion?
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
SELECT COUNT(DISTINCT ID) FROM
7 May
Introduction
Tar and Gzip are command line utilities usually associated with Unix systems, so why would you want to backup the data on your Windows machine with these tools.
Well there are several reasons why you might want to choose a command line utility as part of your backup strategy, the first being that you don’t need to install a Windows program onto a new machine to restore your files. You can simply insert your CD-ROM containing your latest backup (and a copy of the command line utilities) and restore the files you need in a matter of seconds.
(more…)
2 May
Ever go to get on a computer and the user is logged out, and you don’t know the windows password? Or do you have some access, but not access to a users private files, and you want access to those files?
This quick tutorial will show you the steps to change and reset any user password on a windows computer, and also show you how to protect your computer from people doing this to you!
![]()
I never use windows, but when I do, I re-install the OS on a clean harddrive, and take steps to secure it before I connect it to the net for windows and antivirus upgrades.
One of the first things I do is give the Administrator a password. I also disable the guest account, and give the guest username a password.
Next I uninstall all networking components except TCP/IP. Next I disable netbios in the TCP/IP component settings.
Then I disable some services from running, use ‘net user username /DELETE’ to delete the “SUPPORT” and helpdesk usernames totally, and do a bunch of other stuff.
Caveats: If you are on a pc that does not allow you to boot into safe mode, you can get around this. They aren’t disabling the safe mode from the OS, they are just not allowing it from startup by pressing a function key. All you need to do is reboot, and then when windows is still loading, before the login screen, turn off the computer by holding down the power button for 5 seconds. Then turn it back on and you should have safe mode available. You can try this at many different stages to get to a safe mode.
If you have administrator rights, you can modify your boot.ini file to automatically boot into safe mode, or, preferably, you can modify your boot.ini file to give you a choice of booting into safe mode every single time you reboot. I have a custom boot.ini on every windows I run.
You could also use a linux “live cd” such as knoppix to edit your boot.ini file. But if you are going to do that, why not just use a live cd to reset the password, or retrieve the hashes and crack them with saminside?
See available boot.ini switch options at microsoft support boot.ini switch options
This is meant to be for beginners so don’t give me any grief for how easy or simple this is. Not all of us even use windows. Questions/Comments welcome.
25 Apr
This article is dedicated to the task of securing MySQL client-server connection using functionality provided by the Secure Shell (SSH) protocol. To be exact, the SSH tunneling concept is utilized. We will review the steps needed to build secure MySQL client applications and implement a sample one ourselves.
MySQL traffic is not the only kind of data that can be tunneled by the Secure Shell. SSH can be used to secure any application-layer TCP-based protocol, such as HTTP, SMTP and POP3. If your application needs to secure such a protocol by tunneling it through a protected SSH connection, this article will be useful to you.
Background
Let’s imagine that we are developing an enterprise application that needs to send requests to a number of SQL servers all over the world and get responses from them (let’s imagine that it’s a super-powerful bank system that stores information about millions of accounts).
All the data between the application and SQL servers are transferred via the Internet “as is”. As most protocols used by SQL servers do not provide data integrity and confidentiality (and those that do, do it in a quite nontransparent way), all the transferred requests and responses may (and be sure, they will!) become visible to a passive adversary. An active adversary can cause much more serious problems - he can alter the data and no one will detect it.
SSH (Secure Shell) is a protocol that may help in solving this problem. One of its outstanding features is its ability to tunnel different types of connections through a single, confident and integrity-protected connection.
Now you do not have to worry about securing the data transferred over the Internet - SSH will handle this for you. In particular, SSH will take care of the following security aspects:
Strong data encryption according to the latest industry-standard algorithms (AES, Twofish)
Authentication of both client and server computers
Data integrity protection
Stability with regard to different kinds of network attacks
Compression of the data being tunneled
Complete independence of the operating system and network specifics
Tunneling (or forwarding) works in the following way:
SSH client opens a listening port on some local network interface and tells the SSH server that he wishes to forward all connections accepted on this port to some remote host.
When another connection is accepted on the listening port, the SSH client informs the SSH server about this fact and they together establish a logical tunnel for it. At the same time, the SSH server establishes a new TCP connection to the remote host agreed upon in step 1.
The SSH client encrypts all the data it receives from the accepted connection and sends it to the SSH server. The SSH server decrypts the data received from the SSH client and sends it to the remote host.
Please note, that the SSH client acts as a TCP server for the connections it accepts, and the SSH server acts as a TCP client for the connections it establishes to the remote host.
A single SSH connection can tunnel as many application layer connections as needed. This means that you can defend your server by moving all the listening ports (e.g., database and application server ports) to a local network, leaving only the SSH port open. It is much easier to take care of a single port, rather than a dozen different listening ports.
Into the Fire
Let’s develop a small application that illustrates the use of SSH forwarding capabilities. We will consider an important task of securing a connection between a MySQL client application and a MySQL server. Imagine that we need to get information from the database server, which is located a thousand miles away from us, in a secure way.
SecureMySQLClient is the application we are planning to implement. It includes the following modules:
SSH client-side module with forwarding capabilities
MySQL client-side module
User interface for configuring application settings and displaying query results.
The SSH server runs in a remote network and is visible from the Internet. The database (MySQL) server runs in the same network as the SSH server and may not be visible from the Internet.
The process of performing secure data exchange between SecureMySQLClient and the Database server goes as follows:
The SSH client module negotiates a secure connection to the SSH server and establishes forwarding from some local port to the remote MySQL server.
The MySQL client module connects to the listening port opened by the SSH client module.
The SSH client and server set up a logical tunnel for the accepted connection.
The MySQL client sends SELECT to the port opened by the SSH client module, which encrypts it and sends it to the SSH server. The SSH server decrypts the request and sends it to the MySQL server.
The SSH server receives a response from the MySQL server, encrypts it and sends it back to the SSH client, which decrypts it and passes it to the MySQL client module.
Looks too complex? Implementing this is easier than you think.So, let’s go and do it.
We will need the following products installed on the computer before creating the application:
Microsoft Visual Studio .NET 2003, 2005 or 2008.
EldoS SecureBlackbox (.NET edition). Can be downloaded from
http://www.eldos.com/sbbdev/download.php.
MySQL .NET Connector. Can be downloaded from
http://www.mysql.com/products/connector/net/.
Let’s now open Microsoft Visual Studio .NET (we will use the 2005 version) and try to build such an application from scratch.
After the GUI design has been finished, we can go on with the business logic code itself. First, adding references to the following assemblies to our project:
SecureBlackbox
SecureBlackbox.PKI (only in SecureBlackbox 5. SecureBlackbox 6 doesn’t have this assembly)
SecureBlackbox.SSHClient
SecureBlackbox.SSHCommon
MySql.Data
SSHForwarding notifies us about certain situations via its events, so we need to create handlers for some of them:
OnAuthenticationSuccess - Is fired when the client authentication process has been completed.
OnAuthenticationFailed - Is fired if the client was unable to authenticate using particular authentication method. In general, this does not mean that the authentication process completely failed – the client may try several authentication methods consequently and one of them may succeed.
OnError - Is fired if some protocol error occurs during the session. Usually this leads to a connection closure. The exact error can be detected via the error code passed to it.
OnKeyValidate - Is used to pass the received server key to the application. Please note that incorrect handling of this event may result in a serious security breach. The handler of this event should verify that the passed key corresponds to the remote server (and warn the user if it does not). If the key is valid, the handler should set the Validate parameter to true. The sample does not perform key checkup for the sake of simplicity.
OnOpen - Is fired when the SSH connection is established and the component is ready to tunnel data. We will use the handler of this event to kick the MySQL client component.
OnClose - Is fired when the SSH connection is closed.
OnConnectionOpen - Is fired when a new tunnel is created. The corresponding tunneled connection object is passed as parameter.
OnConnectionClose - Is fired when an existing tunnel is closed.
Implementing two core methods, SetupSSHConnection() and RunQuery(). The first one initializes the SSHForwarding object and establishes an SSH session to the remote server by calling its Open() method, and the second one sends the query to the MySQL server.
The code of the SetupSSHConnection() method is pretty simple:
private void SetupSSHConnection()
{
// Specifying address and port of SSH server
Forwarding.Address = tbSSHAddress.Text;
Forwarding.Port = Convert.ToInt32(tbSSHPort.Text);
// Setting credentials for authentication on SSH server
Forwarding.Username = tbUsername.Text;
Forwarding.Password = tbPassword.Text;
// Specifying network interface and port number to be opened locally
Forwarding.ForwardedHost = “”;
Forwarding.ForwardedPort = Convert.ToInt32(tbFwdPort.Text);
// Specifying destination host where the server should forward the data to.
// Please note, that the destination should be specified according to
// SSH servers point of view. E.g., 127.0.0.1 will stand for
// SSH servers localhost, not SSH clients one.
Forwarding.DestHost = tbDBAddress.Text;
Forwarding.DestPort = Convert.ToInt32(tbDBPort.Text);
// Opening SSH connection
Forwarding.Open();
}
A bit more complex is the code of the RunQuery() method (to be exact, the code of RunQueryThreadFunc() method, which is invoked in a separate thread by the RunQuery() method):
private void RunQueryThreadFunc()
{
MySqlConnection MySQLConnection = new MySqlConnection();
// forming connection string
string connString = “database=” + tbDBName.Text + “;Connect Timeout=30;user id=” + tbDBUsername.Text + “; pwd=” + tbDBPassword.Text + “;”;
if (cbUseTunnelling.Checked)
{
// specifying local destination if forwarding is enabled
connString = connString + “server=127.0.0.1; port=” + tbFwdPort.Text;
}
else
{
// specifying real MySQL server location if forwarding is not used
connString = connString + “server=” + tbDBAddress.Text + “; port=” + tbDBPort.Text;
}
MySQLConnection.ConnectionString = connString;
try
{
// opening MySQL connection
MySqlCommand cmd = new MySqlCommand(tbQuery.Text, MySQLConnection);
Log(”Connecting to MySQL server…”);
MySQLConnection.Open();
Log(”Connection to MySQL server established. Version: ” + MySQLConnection.ServerVersion + “.”);
// reading query results
MySqlDataReader reader = cmd.ExecuteReader();
try
{
for (int i = 0; i < reader.FieldCount; i++)
{
AddQueryColumn(reader.GetName(i));
}
while (reader.Read())
{
string[] values = new string[reader.FieldCount];
for (int i = 0; i < reader.FieldCount; i++)
{
values[i] = reader.GetString(i);
}
AddQueryValues(values);
}
}
finally
{
// closing both MySQL and SSH connections
Log(”Closing MySQL connection”);
reader.Close();
MySQLConnection.Close();
Forwarding.Close();
}
}
catch (Exception ex)
{
Log(”MySQL connection failed (” + ex.Message + “)”);
}
}
And, that’s all But there is one more thing I need to draw your attention to. As both SSH and MySQL protocols run in separate threads and access GUI controls from those threads, we need to handle the GUI access in a special way to prevent a cross-thread problems. I will illustrate this with the example of the Log() method:
delegate void LogFunc(string S);
private void Log(string S)
{
if (lvLog.InvokeRequired)
{
LogFunc d = new LogFunc(Log);
Invoke(d, new object[] { S });
}
else
{
ListViewItem item = new ListViewItem();
item.Text = DateTime.Now.ToShortTimeString();
item.SubItems.Add(S);
lvLog.Items.Add(item);
}
}
Finally, the application is finished, and we may try it in work. So clicking F5 and specifying the following settings in the text fields of the application form:
SSH server location, username and password used to authenticate to it.
Database server address, port, username, password, database name and query. Remember that database server address should be specified as it is visible from the SSH server.
Turning on the “Use tunneling” checkbox.
Now click the Start button and wait for the query results. If all the parameters have been specified correctly, we should get something like this:
Features and requirements
SSH protocol provides (and SecureBlackbox implements) the following features:
Strong data encryption using AES, Twofish, Triple DES, Serpent and many other symmetric algorithms with key lengths up to 256 bits
Client authentication using one or multiple authentication types (password-based, public key-based, X.509 certificate-based, interactive challenge-response authentication)
Server authentication
Strong key exchange based on DH or RSA public key algorithms
Data integrity protection
Compression of tunneled data
Multiplexing several tunneled connections through a single SSH connection
SecureBlackbox provides the following functionality as well:
Comprehensive standards-compliant implementation of the SSH protocol (both client and server sides)
Support for cryptographic tokens as storage for keys and certificates
Windows system certificate stores support
Professional and fast customer support
SecureBlackbox is available in .NET, VCL and ActiveX editions. This means that you can use the components in projects implemented in C#, VB.NET, Object Pascal (Delphi and Kylix), FreePascal, VB6 and C++ languages.
SecureBlackbox (.NET edition) is available for Microsoft .NET Framework 1.1, 2.0, 3.0 and 3.5, and .NET Compact Framework.
| About The Author
Tom Davidge is a senior SFTP NET Compnents developer that has proven experience in .net coding.
|
source: www.articlecity.com
Tags: adding, age, Applications, CLOSED, CLOSING, code, Command Line, components, computer, count, cp, dev, developing, download, error, ESTABLISHED, events, Framework, Free, Hacks, IDE, Integrity, Internet, list, Module, modules, MySql, PHP, ping, proc, process, RAM, Security, SEF, SEM, server, Storage, Timeout, traffic, wait, Windows23 Apr
To construct a “tarball” that contains copies of all the files in a particular directory subtree:
1. Use the cd command to change your current working directory to the parent directory of the root directory of the subtree you want to archive. For example, if you want to build a tarball of a directory whose pathname is /u/gertrude/rain/pics/, you would use this command:
cd /u/gertrude/rain
2. Pick a name for the tarball that ends in .tgz. In the example, we might call the tarball rainpics.tgz.
3. Build the tarball with this command:
tar -cvzf name.tgz subdir
where subdir is the name of the subdirectory you want to save. To continue the example, this command would be:
tar -cvzf rainpics.tgz pics
The -c option tells tar to create an archive. The v option tells it to write out the names of the files on your screen as it saves them, so you can be sure it is including everything you want. The z option specifies that the file should be compressed, to save space. The f option instructs tar to use the next name (in the example, rainpics.tgz) for the tarball it is building.
The last argument is the name of the directory subtree to be saved. You could use an absolute path name here, but it is not recommended, because you may be moving the tarball to a system that has different directories. That’s why we recommend you use a relative path name here.
Once your tarball file is completed, you can move or copy it elsewhere on the system, or to a different system altogether.
Tags: cd, Command Line, option, tarball14 Apr
If you are using a content management system to create a website, it is likely that you will eventually encounter a situation where you need to set up a Cron job. Cron is a program installed on Unix / Linux based servers that allows users to schedule tasks to be run automatically at specific dates or times. The name “Cron” is derived from the Greek word for time - chronos. Since most people use shared hosting, this guide will provide the basics for setting up your own crontab and automating tasks with your web hosting provider on a shared server…
I will be using Drupal as an example for setting up Cron because Cron is an integral part of the Drupal core. If you have downloaded and installed the new Drupal 5 CMS, you will notice that there is an error in the administrative log when you first sign in with your administrative account.
One or more problems were detected with your Drupal installation. Check the status report for more information.
When you look at the status report you can go ahead and click the link “run cron manually” and this will remove the error. However, you will eventually want to set up a Cron job to do this. Having the Cron maintenance run regularly on an automatic schedule is important for keeping your site indexed. If this is not done, new content that is added will not be included in search results. Cron can also perform other tasks in Drupal, such as cleaning up log files. Also, some of the contributed modules require that Cron maintenance is run regularly.
With the Drupal 5 installation package, there is a script included for Cron and it is called cron.php. This file is located in the root directory of your Drupal installation. You can actually run Cron maintenance by entering, for example, the URL “http://www.yourwebsite.com/cron.php” into a web browser. But we want to get this done automatically, so we need to call on the help of the Lynx browser. Lynx is a text browser that is often installed on servers. You will need to contact your hosting provider to make sure that they have Lynx installed (most probably do).
Once you know that Lynx is installed, you will need to find the configuration panel for setting up a Cron job in your hosting account. If your web host uses Cpanel, you will probably see something like this:

The first thing to do is enter the command. The following example is the command I use to make Lynx run cron.php:
lynx -source */30 * * * * lynx -source www.yourwebsite.com/cron.php
00 1 * * 0 lynx -source www.yourwebsite.com/cron.php
00 0 01 * * lynx -source www.yourwebsite.com/cron.php
00 1 * * 0
/usr/local/bin/php /home/yourusername/public_html/administrator/components/com_feedgator/cron.feedgator.php >> /dev/null
Tags: age, CMS, Command Line, download, Drupal, image, Joomla, Linux, Module, PHP, serverWordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
SELECT COUNT(DISTINCT ID) FROM