Abhishek Gupta

The Sun won’t set at NIT Durgapur !

Posts Tagged ‘server’

Viewing your server(Remote Desktop) with browser using VNC Java Applet

Posted by abhiitechie on May 18, 2009

VNC consists of two components. A server, which runs on the computer you want to remotely access, and a viewer, which runs on the computer you are sitting in front of. There are two important features of VNC:

  • The server and the viewer may be on different machines and on types of computer. The protocol which connects the server and viewer is simple, open, and platform independent.
  • No state is stored at the viewer. Breaking the viewer’s connection to the server and then reconnecting will not result in any loss of data. Because the connection can be remade from somewhere else, you have easy mobility.

So to get started with VNC you need to run a server, and then connect to it with a viewer. First of all, you have to download and install the software on the platforms you want to use.

VNC software requires a TCP/IP connection between the server and the viewer. This is the standard networking protocol on LANs, WANs, broadband and dialup ISP. Each computer has a unique IP address and may also have a name in the DNS. You will need to know the IP address or name of the server when you connect a viewer to it.

The VNC servers also contain a small web server. If you connect to this with a web browser, you can download the Java version of the viewer, and use this to view the server. You can then see your desktop from any Java-capable browser, unless you are using a proxy to connect to the web. The server listens for HTTP connections on port 5800+display number. So to view display 2 on machine ‘snoopy’, you would point your web browser at:


The applet will prompt you for your password, and should then display the desktop.

Posted in java, Personal | Tagged: , , , , , , , , , , , | 3 Comments »

SQL injection vulnerabilities and how to overcome

Posted by abhiitechie on April 27, 2009

SQL injection vulnerabilities and how to overcome.

According to wiki SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another.

Let me give you an example of one of a very basic vulnerability.

Incorrectly filtered escape characters

This form of SQL injection occurs when user input is not filtered for escape characters and is then passed into a SQL statement. This results in the potential manipulation of the statements performed on the database by the end user of the application.
The following line of code illustrates this vulnerability:
statement = “SELECT * FROM users WHERE name = ‘” + userName + “‘;”
This SQL code is designed to pull up the records of the specified username from its table of users.
However, if the “userName” variable is crafted in a specific way by a malicious user, the SQL statement may do more than the code author intended. For example, setting the “userName” variable as a’ or ‘t’=’t renders this SQL statement by the parent language:

SELECT * FROM users WHERE name = ‘a’ OR ‘t’=’t’;

If this code were to be used in an authentication procedure then this example could be used to force the selection of a valid username because the evaluation of ‘t’=’t’ is always true.

While most SQL Server implementations allow multiple statements to be executed with one call, some SQL APIs such as php’s mysql_query do not allow this for security reasons.

This prevents hackers from injecting entirely separate queries, but doesn’t stop them from modifying queries.

The following value of “userName” in the statement below would cause the deletion of the “users” table as well as the selection of all data from the “data” table (in essence revealing the information of every user):

a’;DROP TABLE users; SELECT * FROM data WHERE name LIKE ‘%

This input renders the final SQL statement as follows:

SELECT * FROM users WHERE name = ‘a’;DROP TABLE users; SELECT * FROM DATA WHERE name LIKE ‘%’;

SQL injection is a nasty thing. An SQL injection is a security exploit that allows a hacker to dive into your database using a vulnerability in your code. Since many PHP programs use MySQL databases with PHP, so knowing what to avoid is handy if you want to write secure code.
Here are some SQL injection cheat sheet that has a section on vulnerabilities with PHP and MySQL. If you can avoid the practices the cheat sheet identifies, your code will be much less prone to scripting attacks.

Posted in mysql | Tagged: , , , , , , , , , | 2 Comments »