Ban Pure-FTPd login attempts by IP after three failures
Mon, Nov 9 2009 at 7:30AM PST • Contributed by: Anonymous
I run an FTP server on my machine, using Pure-FTPd. Lately, I was getting a lot of noise in my logs about unknown people trying to gain access on my FTP server. I wanted to automate the task of looking through the log and banning the bad IPs, so that my logs will be kept clean from all those try/fails attempts.
What I came up with is a bash script executed as a launchd user daemon whenever the file /var/log/ftp.log is being modified. Parts of the code come from , and irc2samus on the #bash channel (IRC on freenode.net) made the rest.
I thought this might help others, too, so here's the code.
[1,844 views]
I use Dropbox to keep files in sync between my work computer (a PC), my MacBook Pro, and an iMac at home. Although Dropbox is great, it keeps the files that it syncs to the cloud in a Dropbox folder. I have my own folder/file organization for projects, which I would prefer to maintain.
I found that I could keep a copy in the place where I usually would and sync with the cloud by creating symbolic links to the folders that I want to sync inside the Dropbox folder. Using this method, the file would be available in both places, without taking up any extra disk space.
To do this, you need to use the Terminal. Since Dropbox allows you to choose where your Dropbox folder resides, there's no "one size fits all" solution, but here's the general syntax (replace username, foldername, and path/to/dropbox with your own values):
ln -s /Users/username/Documents/foldername /Users/path/to/dropbox/Files/
You can also drag the source and destination folders into the Terminal window instead of typing the paths. Note that foldername has no trailing slash ( /), but that Files/ bit does -- this is very important!
With symbolic links in place, you can save files where you normally would, and they'll still automatically sync to the cloud.
[5,454 views]
 I created a Service to send a selected phone number to Google Voice to be dialed. To do this, I actually use two files: The service, which should be installed in your user's Library/Services folder, and the google-voice-dialer php script, which does most of the heavy lifting; install that wherever.
Download the zip file (78KB), expand it and open the resulting folder, move the Service to your user's Services folder and the php script to wherever you'd like it to reside. Before using this Service, you need to open it in Automator for some editing. Within the AppleScript code in the Run AppleScript Action on the right, scroll through the code and change the following properties: usrnm, psswrd, phnm, myFilePath, and myFileName. Save those changes, and you should be good to go.
To use, select a phone number in any Cocoa application (Safari, Mail, Address Book, etc), Control-click on the selection, then go to Services » gvDialer, and Google Voice will dial the number.
[ robg adds: I haven't tested this one.]
[3,415 views]
If you activate parental control, MSN Messenger is not going to work. Some can argue that you can use other solutions, but your Kids will argue that this what their friends use. To get MSN Messenger working, you need to authorize at least messenger.hotmail.com, but I discovered that Adium is using more Microsoft servers, and as the list is quite long, here is a way to simply authorize MSN Messenger on a managed account with parental controls.
- In the Parental Controls System Preferences panel, go to the Content tab and choose the 'Try to limit ...' option.
- Click on Customize and allow MSN Messenger's server by adding the following addresses: http://messenger.hotmail.com, http://*.*.msn.com, and https://*.*.msn.com.
That should allow full MSN Messenger functionality. However, if you need something more granular and you want to control every address, this Microsoft support page lists all the addresses used by MSN Messenger.
[1,123 views]
 One of the great new features of Snow Leopard is the ability thru Automator (and by extension, AppleScript) to make your own service. Automator can set-up services to accept specific inputs (ie files, images, or text) to act on. If you have selected the appropriate type of input, the service will show up in your context menu.
To create a service which generates a tr.im shortened URL when control-clicking a link in Safari. First, open Automator, and select Create a New Service. Set the Service to receive selected text in Safari.
Find Run AppleScript from the Action library on the left, and drag that over to the right half of the Automator window. In that area, paste in the following:
on run {inText}
tell application "Safari"
activate
set searchTerm to inText
set xNow to do JavaScript "
var x,
z,
i;
x = '" & searchTerm & "';
if (x != null) {
x = x.toLowerCase();
z = document.links;
for (i = 0; i < z.length; ++i) {
if ((z[i].innerHTML && z[i].innerHTML.toLowerCase().indexOf(x) != -1) || z[i].href.toLowerCase().indexOf(x) != -1) {
z[i].style.color = '#2e2e2e !important';
sndT = 'http://tr.im/marklet?url=' + escape(z[i].href);
popup_window = window.open(sndT);
}
}
}
" in document 1
end tell
end run
Save your service, then go to Safari and find a link you want tr.im-ed. Control-click on that link, and you should see your new service at the bottom of the contextual menu.
[ robg adds: I can't get this one to run properly on my machine, so I'm posting it in hopes that the community can figure out the issue -- it looks like it's working, but nothing actually seems to happen. In theory, this could be a very useful hint.]
[3,851 views]
You can download, back up, and upload documents from your Google Docs account using a little Terminal magic.
Prerequisites:
- gdata-python-client 2.0.1 - download page
- gdatacopier 1.0.2 - download page
Installation:
- Download the prerequisites. Decompress each of the downloads.
- Install gdata-python-client:
$ cd gdata-2.0.1<br>
$ sudo python setup.py install
Patch:
The current gdatacopier download has a small bug in it, and it needs to be patched to work properly. Open the file gdatacopier.py in the app's folder, and locate line 555. On that line, change this...
item_list.append({'title': entry.title.text.encode('UTF-8'),
...to this...
item_list.append({'title': entry.title.text,
Save the file and quit the editor.
[3,808 views]
This is slightly hard to describe, but I just randomly stumbled across a nifty little hack, for lack of a better word, involving the viewing of YouTube videos. Of course, YouTube natively supports full-screen viewing of videos, but I personally do not like this as I am completely immersed in the video and can no longer see the other activities on my screen (such as new mail, etc).
So I stumbled across this tweak that allows you to watch a YouTube video maximized in its browser window. Check out the pic in my blog post if my description doesn't make sense.
To do this, paste this code into your browser:
http://www.youtube.com/v/xxxxxxxxxxx&hl=en&fs=1&
Now go back to the desired YouTube video in its normal view, and copy the last 11 alphanumeric string in the URL box on the right side, or in the actual URL you see in the address bar of your browser. This random string is the identifier for that specific video. Now paste that random string in place of the xxxxxxxxxxx in the code above, hit Enter, and you're good to go!
So, for example, if you want to watch a video with this URL ... http://www.youtube.com/watch?v=S6SCc6A6Kck ... the URL to go to is
http://www.youtube.com/v/S6SCc6A6Kck&hl=en&fs=1&.
[8,063 views]
10.5: Take and upload screenshots via Automator
Tue, Jun 16 2009 at 7:30AM PDT • Contributed by: Anonymous
 I often take screenshots and upload them for my friends to see -- especially while working on web projects etc. So I created an Automator workflow that does this automagically!
First the workflow snaps the whole screen and saves it to the desktop. Then a bash script is run wich uses ftp to upload the image to the webserver. It then takes the URL of the image and copies it to the clipboard. Lastly it notifies you of the upload via Growl. It has no error handling or anything. This is my first workflow and bash script ever, but it works for me.
In Automator, create the following steps in a new blank workflow:
- Utilities » Take Screenshot. Use these settings:
- Type: Full Screen, or whatever you prefer.
- Select Main Monitor Only and/or Timed as you desire.
- Set the Save To pop-up menu so that it saves to a file named tmpScreen.png on your Desktop.
- Utilities » Run Shell Script. Set Shell to /bin/bash and Pass Input to to stdin. Enter the following code, noting the lines you need to edit:
#!/bin/sh
# Author: Simon Ljungberg @ www.nimnim.se
# Edit the 5 lines below to fit your configuration
# URL will be copied to your clipboard!
HOST='yourftphost'
USER='yourusername'
PASSWD='yourpassword'
REMOTEFILE='pathtoremotefile(including filename)'
URL='http://yourdomain.com/screens/screenshot.png'
# If you change this you need to change the rm-line too.
# For some reason (I'm new at this) I couldn't get the file
# to disappear when using the variable...
LOCALFILE='~/Desktop/tmpScreen.png'
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
put $LOCALFILE $REMOTEFILE
bye
END_SCRIPT
rm ~/Desktop/tmpScreen.png
echo $URL | pbcopy
- If you have Growl installed, add Utilities » Show Growl Notification. Give it a Title ("Done!") and Description ("Your screenshot has been uploaded") so you'll see a message after the upload is completed.
Alternatively, you could download the script from my server, and then just change the variables in the shell script section of the workflow.
To make this work, you need a web server with FTP access, and note that your username and password are stored in the script. Works for me in 10.5.7; I hope someone can make use of it!
[3,978 views]
 I want to run Apache with virtual sites located outside my user's Sites folder. Instead, I wanted to be able to keep them anywhere within my user's Documents folder. This is because sibling directories of the desired document root may be assets, documentation, various source code, and/or any content related to the project. I do not wish to keep these files in a web-accessible folders, but I do want to keep these directories in the same parent directory.
I scoured the net and it seems that I may be the only one who wishes to do this. Just in case I'm not, though the following is how I figured it out.
The following solution worked for me in OS X 10.5.6 running Apache 2.2.9. Note that if you don't understand any of the following steps, please use caution and Google before proceeding
- Set up your virtual host with ~/Documents/any/sub/folder/ as the document root. (see Apache manual)
- Add yourself to the www group: sudo dscl localhost append /Local/Default/Groups/www GroupMembership _username_ -- replace _username_ with your user's short username.
- chgrp www ~/Documents
- chmod 750 ~/Documents
I'm not entirely comfortable with enabling +rx access to the www group, and therefore the httpd process on my home directory. However, this is a local development machine and I'm stoked to at least maintain my usual linux directory structure and have my vhosts working.
Please, if anyone knows of a better way to allow Apache to use any folder as the document root for a virtual host -- without enabling read/execute access to www group on one's home directory -- do inform.
[5,386 views]
 For some time, I googled and hunted for a solution that would allow me to change the subnet that Internet Sharing (on the Sharing System Preferences panel) uses when sharing onto an Ethernet network -- the default being 192.168.2.0. In my case, this also happens to be a subnet used by my corporate VPN, which is not too convenient.
The solution for Leopard turned out to be extremely straightforward, and can be found in the unix help file for InternetSharing -- just type man InternetSharing to read it in Terminal:
- Copy the plist file /Library » Preferences » SystemConfiguration » com.apple.nat.plist to your home directory, eg: sudo cp /Library/Preferences/SystemConfiguration/com.apple.nat.plist ~.
- Use Xcode's Property List Editor (or any other property list editor) to edit the file in your home directory.
- Add a new key (child) to the NAT dict. Call it SharingNetworkNumberStart. The type should be String, and the value is the IP network you want to use (eg 10.168.2.0). As an example, here's what my edited file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NAT</key>
<dict>
<key>AirPort</key>
<dict>
<key>40BitEncrypt</key>
<integer>1</integer>
<key>Channel</key>
<integer>0</integer>
<key>Enabled</key>
<integer>0</integer>
<key>Extreme</key>
<string></string>
<key>NetworkName</key>
<string>pimpedwifi</string>
<key>NetworkPassword</key>
<data>################</data>
</dict>
<key>Enabled</key>
<integer>1</integer>
<key>PrimaryInterface</key>
<dict>
<key>Device</key>
<string>HUAWEIMobile-Modem</string>
<key>Enabled</key>
<integer>0</integer>
<key>HardwareKey</key>
<string></string>
<key>PrimaryUserReadable</key>
<string>HUAWEI Mobile</string>
</dict>
<key>PrimaryService</key>
<string>C42284CE-6803-42A7-9F54-627DB90321DF</string>
<key>SharingDevices</key>
<array>
<string>en0</string>
</array>
<key>SharingNetworkNumberStart</key>
<string>10.168.2.0</string>
</dict>
</dict>
</plist>
Save your changes.
- Copy the edited file back to the original location. sudo cp ~/com.apple.nat.plist /Library/Preferences/SystemConfiguration/
Now you can (re-)start Internet Sharing, and it will run on your defined subnet. Hopefully some day Apple will add this as a config option in the Sharing System Preferences panel.
[ robg adds: You may want to duplicate the original file first, or make sure you have a backup on Time Machine, just in case something goes wrong.]
[5,889 views]
First | Previous | 1 2 3 4 5 6 7 8 9 10 | Next | Last
|
|
User Functions
Don't have an account yet? Sign up as a New User
Lost your password?
What's New in the Forums?
The Editor's Corner...Here are some of my ( robg) other projects...
The macosxhints PollWhat version of OS X are you running as your main OS?
Other polls | 11,251 votes | 42 comments
|