Have you ever thought of modifying a laptop? This is quite common (not really) for people with EEEPC’s, since they want more harddrives, inbuilt modems and even touchscreens. Is it hard? Well, I guess it’s not for amateurs, but it look’s like a handy guy can make some of the work done.
This guy has made several tweaks for his EEEPC, like:
USB hub
Bluetooth
GPS module
SDHC reader
Touch screen
FM transmitter
Flash drive
Temperature sensor
He describes it very well and this is well worth a visit!
http://beta.ivancover.com/wiki/index.php/Eee_PC_Internal_Upgrades
In this article, guide or tutorial (call it whatever you want), you will se what the hosters and developers should do to avoid the major security risks when using a *nix system and PHP + MySQL. This do cover the basics of PHP and MySQL security and will tell you methods to avoid the most used hacking attempts.
Safe_mode
Safemode activates a couple of settings that will:
* Force PHP to check UID permission before opening files.
* Prevent some calls, such as system(), from working. This is unless safe_mode_exec_dir is set.
* Set open_basedir to allow hosters to force file access to stay within a virtual directory.
There are though ways around safe_mode. Most PHP exploits use methods to get around the safe_mode restrictions.
One tips for the hosters is to not just turn on safe_mode without knowing what the actions are. You are not safe just because you turned on safe mode.
Safe Mode has also been removed totally in PHP 6.0.
Magic quotes and addslashes()
Lot’s of people recommend the use of addslashes(). This is however a prety poor advice today when connecting to a mysql database.
To prevent SQL injections, the best thing to do is to use a combination of methods. However, the best method is definately to use PDO or mysql_real_escape_string(). As a hoster, you should quickly upgrade to the latest PHP version to encourage safer and more secure functions for the users and their software.
So - how do I know if I’m vulnerable?
If the users can do remote code execution, you are in fact lucky if you’re still alive.
How do you see if you allow this then?
One thing could be if you check if this works on your site:
$file = $_POST[‘file’]; include $file; </php> or this <pre lang="php"> $txt = $_POST[‘txt’]; eval(“echo $txt”);
Other functions that can be dangerous are fopen, fsockopen, popen and system. The last two functions are direct command execution and allows remote attackers to execude code on the system.
If you want to protect yourself against this you can as a DEVELOPER:
Control that all your $_POST and $_GET arrays are secure and that file operations such as includes/requires, eval statements and every type of file operation is validated before use.
When you write new software you should limit the use of dynamic inputs as this is the most common security whole in php scripts.
As a HOSTER you should, to provide security, disable allow_url_fopen in the php.ini, enable safe_mode and set open_basedir restrictions.
Another huge and commonly used security whole is XSS or Cross-site scripting.
This refers to HTML injections or user agent injections which can effect all types of servers. This doesn’t hurt the server itself but makes the site leak information and the users that access the website can bring their information to wrong parts, such as their credit card or password.
An insecure output can look like this:
echo $_POST['text'];
While, if you want to be atleast quite secure, you can use the function htmlentities.
Developers
* Switch off register_globals and make sure that all the variables are properly initialized.
* Take user input from correct location, ie $_POST or $_GET, rather then relying on register_globals or $_REQUEST.
* Validate user input for syntax, length and type.
* Text can only be visable after using HTML entities.
* Variables that are sent back should be URL encoded using urlencode().
Hosters
Hosters can’t configure the server to be XSS (cross site scripting) safe but can remove all applications that have XSS attacks in their history. This means that the developers has to have XSS protection or their software will not be used at all.
SQL Injections
The most common and widely used hacking attempt is to use a SQL injection.
What can the developer do to protect the site and server from any SQL injection then?
* Validate the data when having dynamic SQL queries.
* Use PDO (Included in PHP 5.1 and later)
* At least use functions like mysql_real_escape_string().
Nowadays every developer should migrate to PHP 5.1 and use PDO since it has a SAFE SQL interface wich avoid all these issues.
addslashes() is not enough to avoid injections.
The php magic quotes, which automatically adds slashes to input data on the basis of database destination, is not enough as a security method either.
Developers
* Migrate to PHP 5.1 and use PDO.
* Use mysql_real_escape_string()
* Validate the data!
* Have a .htaccess file to ensure that register_globals and magic_quotes are forced off to provide properly initialization anv validation for the inputs.
Hosters
Provide PHP 5.1 and PDO for their clients. Configure MySQL to be the most secure as possible. Users should not be granted admin privileges and the database should be running in a chroot environment to avoid as much damage as possible if a successful attack has reached.
PHP Configuration
It is quite suprising that there is no real secure PHP configuration by default. Here’s a list of settings that should be set:
* register_globals (off by default in modern PHP, should be set off)
* allow_url_fopen (enabled by default, should be set off)
* magic_quotes_gpc (on by default, should be set off)
* magic_quotes_runtime (off by default, should be set off)
* safe_mode and open_basedir (disabled by default, should be enabled and configured correctly. But be aware that safe_mode isn’t really safe and can be totally useless)
Developers should during installation test using ini_get() for common hosting mistakes such as allowing things usch as register_globals or magic_quotes_gpc.
What can the developers and hosters then do to make sure they are safe towards hacking? It’s not possible to be bulletproof in this business, but if you keep your software up to date and make sure all the common mistakes are undone you will in general be safe. Here’s a compilation of what the developers and hosters should think of when securing their scripts and systems.
Developers
* Ensure that all variables are properly initialized before use.
* Ensure that the users only can affect file operations to the degree you had in your mind creating the function.
* Ensure that your scripts are totally compatible with safe mode restrictiongs and will work under things such as suPHP.
* Move the secrets and logs out of the web roots if scripts are supposed to work on a shared hosting environment.
* Use PDO for MySQL queries.
* Validate the data with length, type and every kind of method you can think of.
Hosters
* Enable safe_mode (be aware that it though isn’t really safe and can be useless)
* Use open_basedir restrictions!
* Make sure that users have a place outside web root to store logs and secrets.
* Run PHP under a least privilege model, as a user or via use of PHPsuExec or suPHP.
Tavis Ormandy is the guy from the Google Security Team who “makes it happend”.
He’s a researcher on the Google Security Team and faces the unpleasent responsibility of passing all googles products pass the security tests. Tavis is also an open-source contributer, working as a co-lead of the Gentoo Security Team as well. He is one of the faces that should make the Linux Gentoo distribution safe.
In September 2006, Tavis reported vulnerabilities in the gunzip decompressor on behalf of Google. Here is the link to the report made by Tavis: http://www.scary.beasts.org/security/tavis_gzip.txt
He has also discovered lot’s of other vulnerabilities such as PCRE (Perl Compitable Regular Expressions) and Perl Unicode Regular Expression buffer overflow. Links to these hacks can be found here: (PCRE) (UNICODE)
Summary: We should be glad of Tavis work since he’s making the web and the servers safer by contributing and telling the software creators before making the exploits public.
Here’s some collected links that can be interesting:
Tavis Ormandy’s blog
Secwatch profile
Milw0rm profile
The computer science portal csdir.org has published another good tutorial. This one is about hacking and tells us what an exploit is, how to compile one and how to use it. This hacking tutorial is of great use for newbies and avarage users. This site also has a couple of other great tutorials;
The bash tutorial which is a complete guide of how to use bash to script useful scripts. This tutorial is probably the best in the area.
It can be found here: http://csdir.org/tutorials/bash-tutorial/
The third tutorial they offer is the Ansi C tutorial which is a great starting tutorial for programmers that want to know more about the C programming language. The ANSI part is just meaning the American National Standards Institute.
We on cdsrc really recommend those three tutorials.
Video has arrived to Linux with Skype 2.0 beta!
Skype is a software created by the entrepreneurs Niklas Zennström and Janus Friis.
Skype allows users to make telephone calls from their computer to other Skype users free of charge, or to landlines and cell phones for a fee. Additional features include instant messaging, file transfer, short message service, video conferencing and its ability to circumvent firewalls.
For a time the video part has been available for windows versions, but never on a linux version, but now that limit is gone!
Happy news for all cam-geeks!
The free implementation of Windows on Unix, Wine, has released a newer version.
So, Whats new in this version?
- Many copy protection fixes.
- GLSL is now the default for Direct3D.
- Lots of memory errors fixed thanks to Valgrind.
- Support for TOPMOST windows.
- Beginnings of an inetcomm dll implementation.
- Lots of bug fixes.
Let’s be happy of this new release!
Here’s a good portal for compuer science resourses; the Computer Science directory.
The site is a strong site which has been featured at lifehacker and has a couple of tutorials that are great for both beginners and advanced programmers and scripters.
Check it out!
Linux has finally bypassed Windows 98.
According to W3counter which has a report of 33,640,022 unique visitors (2007/09/06), Linux has 1.34% of the market share, while Windows 98 is just slightly below it. Windows Vista has yet only 3.46%, while the big leader, Windows XP, has 83.48%. Mac OS X is still bigger than Vista with their 3.73% of the market.
The most common screen resolution is 1024*767 (49.54%) backed up by 1280×1024 (17.24%), 1280×800 (9.10%) and 800×600 (8.34%).
The most common web browser is still Internet Explorer 6.0, but IE 7.0 is climbing towards that spot.
Firefox X.X has about 25% of the market share, while IE has a total of 66.2%. On the third place comes Safari with about 1.75%.