Category Archives: Mac OS X

Where is PrntScrn?

One of the questions I get asked by a lot of Mac newbies is “Where is the Print Screen button?”. The answer, is that there isn’t one. So how do you perform a screen capture in Mac OS X. The answer is that there are two ways, you can use the Grab Utility found under Applications -> Utilities, or you can use the shortcut key: cmd+shift+4.

I find the shortcut key much easier to use. Pressing the key changes the cursor to a target showing the co-ordinates of the cursor. In this mode, you can select and area of the screen you wish. When you release the mouse button, the screen capture is automatically saved to your Desktop as “Picture 1″

To grab a full window, use the same shortcut key and then press the spacebar. The cursor will now change to a camera and the window under the cursor will be highlighted. One click and the captured image is saved to your Desktop. Easy peasy, when you know how!

Using Automator to Create an Archive Folder

One of the great things about Mac OS X is how easy it is to automate tasks, either using AppleScript or Automator. I’ve been laid up for a few days, so I had some time to play around with Automator.

If you’ve never used Automator before you’re missing out on a whole aspect of your Mac that makes life so much easier. Automator is simply a method for creating your own automated tasks and saving these tasks as applications and plug-ins. The purpose of this post is to show you how to create a plug-in using Automator that can be attached to a folder.

Before we start, you need to be aware of a couple of the terms that will crop up when you use Automator:

  • Actions: Actions are the sequence of steps used to achieve the task you want to complete. Actions are categorised according to the Mac OS Application that they work with, for example, Finder Actions work with Files and Folders, iCal Actions with calendar events etc.
  • Workflow: An Automator Workflow is a collection of Automator Actions grouped to achieve the task in mind.

Now that we have the jargon sorted out, we can start working on our Automator workflow. First of all, you can find Automator in the Applications folder. When you open Automator, you’ll be prompted for your starting point: Custom, Files & Folders, Music & Audio, Photos & Images and Text. For the purposes of this mini-tutorial, we’ll be starting with Custom.

The next thing to note is the layout of the Automator window. On the left hand side of the screen you’ll see the list of available actions, while on the right you’ll see just blank space. This will be the canvas for creating your Workflow.

Empty Automator Workflow

Empty Automator Workflow

Click to see the full size image.

As an example task, we’re going to create a Folder on our Desktop. When files are added to this Folder, they’ll automatically zipped and the .zip file will be placed on our Desktop, and the folder will be emptied.

Now is the time to create the folder on the Desktop: Cmd-Click or Right Click and create a New Folder. Call it “Make Archive”. Back to Automator.

As I said, the left hand side contains the library of available actions. The first action we’re going to use is “Get Specified Finder Items”. You’ll find it in the “Files & Folders” library on the left. Drag the action to the Workflow space on the right.

Get Specified Finder Items

Get Specified Finder Items

Click for full size image

You’ll notice that there is an “Add” button. Using this button we’ll add the “Make Archive” folder that we previously created on the Desktop.

Next, we tell Automator that we want to get the contents of that folder. Happily there is an action for that, and it’s called “Get Folder Contents”. Drag this action to the Workflow. Within this action, there is a tick box to “Repeat for each subfolder found”. Tick it.

Get Folder Contents

Get Folder Contents

Click for full size image

With this Action, Automator knows the contents, of the folder, now it’s just a matter of doing something with that information. As we want to create a ZIP archive, we need an action to do this, and once again Automator obliges with “Create Archive”. Drag this to the Workflow:

Create Archive

Create Archive

Click for full size image

With this action, we need to give the created archive a name and a location to save to. Enter your own personal preferences here.

That’s the basic functionality in place. Now we need to test it. Copy a file to your “Make Archive” folder. When you have that completed, click the “Run” button in the top right corner of Automator. If everything is working, you should see a green tick and “Workflow Completed” in the Automator status bar. If you don’t, re-read the above instructions.

You’ll notice that we had to manually run the Automator Workflow for anything to happen. Now I’ll show you how to attach the Workflow to the “Make Archive” folder so that it runs automatically anytime you add files to the folder.

The automation is handled by saving the Workflow as a Folder Action Plug-in. A Folder Action is triggered when a specified folder changes. In Automator, go to “File, Save as Plug-in”. You’ll be prompted for a name and the type of plug-in to save as. Call your plug-in “make_archive”, and the plug-in type should be changed to “Folder Actions”.

When you do this, a third option will become available, “Attached to Folder”. Browse to your “Make Archive” folder on the Desktop. You may be prompted to “Enable Folder Actions”. If you are, tick the box and continue with the save.

Save as Plug-in

Save as Plug-in

Click for full size image

To test your new automatic archiver, copy a file to the folder and watch Automator do it’s magic!

There is one small problem though: when the archive has been created, the original file stays in the “Make Archive” Folder. If you leave this file in place, it will be added to the next archive you create, which is not what we want. The answer lies in creating a new Automator Workflow. In this new Workflow, we use the same first two Actions, but we replace the “Create Archive” Action with “Move Finder Items to Trash”.

Move Finder Items to Trash

Move Finder Items to Trash

Click for full size image

Once again save this Workflow as a Plug-in and attach it to your “Make Archive” folder. Perform another test, and this time the folder should be emptied once the archive is completed.

First Trojan Based on ARDAgent Root Exploit

Secure Mac are reporting that they have found a trojan designed to take advantage of the ARDAgent root exploit that I posted about previously.

The Trojan dubbed “AppleScript.THT” allows the remote attacker full access to the system, steals usernames and passwords, hides by turning off system logging, opening firewall ports and can also be used to install key logging software, take pictures using the inbuilt iSight and to enable file sharing.

The Trojan come as either a compiled AppleScript titled ASthtv05 or as a disc image called ASthtv_06. In both cases, the files have to be downloaded and executed by the user. At the moment, the Trojan does not take advantage of any other Mac vulnerabilities to automatically infect new machines – but that’s probably only a matter of time.

Secure Mac are advising Mac users to use MacScan to protect themselves against the threat. Or you could just stop the ARDAgent service from running scripts as root.

Temporary Fix for ARDAgent Root Privilege Escalation

If you’re worried about the security problem with Apples Remote Desktop Sharing that I posted about yesterday, but still want to use the service, then here’s a quick solution:

Open Terminal and type, all on one line, the following command:

sudo chmod u-s /System/Library/CoreServices/RemoteManagement/
ArdAgent.app/Contents/MacOS/ARDAgent

Now if you use,
osascript -e 'tell app "ARDAgent" to do shell script "whoami"'you should get your own username back.

Mac OS X – Gain Root Privileges Through AppleScript

A serious security hole has been found in Mac OS X – both Leopard and Tiger are affected. The exploit allows someone with physical access to a Mac to run programs as the Root user.

The exploit uses the Apple Remote Desktop, (ARDAgent), application to execute a shell script. When the shell script is executed it is done so as Root. To test this, type the following command in Terminal:

osascript -e 'tell app "ARDAgent" to do shell script "whoami"'

This command works even if Remote Desktop Sharing is disabled and the Root user is disabled in the Directory Utility. However, it will only work if the user is logged into the computer. It will not work if Fast User Switching has been used.

As this is a brand new exploit there is no fix as of yet.

Slow-Mo Mac OS X Expose Shortcut Key

The Function Keys F3 – F9 in Mac OS X gives you access to the various Exposé “views”. For example, pressing F3 on my MacBook shows all open application windows. (Depending on your Mac, the function keys may be mapped differently. Check System Preferences – Exposé & Spaces for a full list.)

While trying to figure out a keyboard shortcut, I happened upon a neat little “feature” of Leopard. By holding down the Shift key while pressing a function key gives a nice little slo-mo version of the Exposé transition.

I know that’s not a great explanation, but give it a try and you’ll see what I mean.

Finally – Mac OS Update 10.5.2 is here

It’s been a long wait for Leopard users, but 10.5.2 is now available from software update or from the Downloads section of the Apple website.

The full list of fixes contained within the update is available here.

At 180MB the update isn’t as large as originally predicted.

Update: After downloading the 10.5.2 update, there’s another update available via Software Update – Leopard Graphics Update. The update is also available from Apple Downloads here.

Setting Up Movable Type 4 on a MAMP Server

Recently my hosting provider, Blacknight Solutions, requested that bloggers using WordPress use the WP-Cache plugin to reduce the load on their servers. Michele at Blacknight has been somewhat critical of WordPress in the past, mainly due to it’s inefficient SQL and the resultant high number of database queries required to generate even a simple page. Based on this Michele moved over to Movable Type 4, and despite a few teething problems, he seems to be quiet happy with it.

As part of their control panel, Blacknight provide the handy Installatron Script Installer, however, there is no installer available for MT, so users have to manually install it themselves. Unfortunately my upload connection is so bad, that it me takes hours to upload the approximately 20 MB of MT install files. As I use MAMP for local site development, I’d thought I’d have a go at a local install of MT.

Because of where MAMP is installed, it’s not a straightforward process, there are a couple of “gotchas” along the way. So for those of you interested in performing a local install of MT4, here’s a quick HOWTO.

Before you start, you’ll obviously need MAMP Server, and MT4. You can grab MAMP here, and MT4 here.

Part I: Getting Ready To Install Movable Type

  1. Once you have downloaded the MT4 ZIP file, extract the files to a folder of your choice.
  2. Within this folder, you should now have an MTOS-4.1-en folder.
  3. Open this folder and locate the mt-static folder.
  4. Move the mt-static folder to /Applications/MAMP/htdocs/
  5. Open a new Finder window and browse to /Applications/MAMP/cgi-bin/
  6. Create a new folder, and name it mt
  7. Move the remaining files in the MTOS-4.1-en folder to /Applications/MAMP/cgi-bin/mt/

Part II: Create a SQLite Database

Before starting the Movable Type installer, you need to create a database in which to store your blog settings, posts etc. While the MT developers recommend that you use MySQL for your database, an additional Perl Module is required otherwise MT will not recognise your MySQL server. However, as this will be a local install, SQLite should be more than enough for your needs. (If you really need it, the required module is DBD::mysql which can be found here, but be warned installing it is problematic and time consuming).

  1. Start the MAMP application and click the “Open Start Page” button, or alternatively, type http://localhost:8888/MAMP/ into your address bar.
  2. Click the link for the SQLiteManager at the top of the page.
  3. Type in the name of your database, and select Version 3.
  4. The full path to the database file also needs to be provided. In this example, I’ve called my database mt4, but you’re free to call it whatever you wish.
  5. Note that the path to your database will be /Applications/MAMP/db/sqlite/[your database name].db
  6. Click the Save button, and your database will be created.

Part III: Installing Movable Type

Now that you have all the MT4 files in place, and your database has been created, you’re ready to start the Movable Type web-based installer.

  1. Open your browser, and type in the following address: http://localhost:8888/cgi-bin/mt/mt.cgi
  2. The installer will tell you that the mt-static has either been renamed or moved and will request both the Static Web Path and Static File Path to the folder. Enter the following paths:
    • http://localhost:8888/mt-static
    • /Applications/MAMP/htdocs/mt-static
  3. Click the Begin button and the installer will confirm that the paths you have entered are correct.
  4. The next step brings us to the database connection setup page. Here is where we’ll tell Movable Type where our database is and how to connect to it.
  5. You’ll note that the only database connection available to us is the SQLite Database and once again we’re being asked for the path to the database. This is the exact same path that you entered in Step 6 of Part II above:
  6. In order to proceed, you’ll need to Test the Connection.
  7. Once MT can talk to your database, then Continue onto the next step -setting up your email.
  8. From the drop-down, select Sendmail and accept the default Sendmail path. Enter your email address and click the Send Test Email Button.
  9. The next step is to set up the admin user and password.
  10. The final step is to create your first blog!