Archive

Archive for the ‘Mac OS X’ Category

Run Installer (.pkg or .mpkg) without user dialog (silentmode) from console on OS X

09:23 AM No comments

Very often, software for OS X is provided as .pkg or .mpkg bundles (the difference is, that .mpkg bundles are more customizable than the .pkg-installers). If you want to install them without clicking through the GUI-user-dialog, you can do this by running the installer from the console in silent mode:

sudo installer -pkg your_installer_file.pkg -target /

The installer will run without showing something on the GUI. You will have to enter your system-administrators password, if the installer needs the rights. You can (but shouldn’t) give the password with the command line (so you can install .pkg in an automated way):

echo <password> | sudo installer -pkg your_installer_file.pkg -target /

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Attention: Your password will be stored among other files in the bash_history!

You shouldn’t use this unless you really know what you are doing!

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Post to Twitter Tweet This Post

Bypass a firewall Part II – Secure Tunnel through the firewall

05:40 PM No comments
*WOW* – the resonse to my last article is overwhelming! The article is just a week old, but my mailbox is already full of emails asking me, if there is a way to use SOCKS over a secure connection like SSH.
To prevent my mailbox from several hundrets of further emails: YES THERE IS A WAY!

Building a SOCKS Proxy over SSH

All you need to realize a SOCKS5 tunnel over SSH is an openSSH on your “SOCKS-Server” and the already used “Proxifier”, as well as PuTTY on Windows-based systems.

First of all, you need to build up the secure tunnel (type the command into your OS X console):

ssh -2 -N -D 8080 user@<ip of your SOCKS5-Host>

for example:

ssh -2 -N -D 8080 myuser@192.168.1.11

On Windows, the configuration of PuTTY is the following:

Add the Hostname (for example: 192.168.1.11 – you need to add your SSH/SOCKS-Server IP there) under Tab “Sessions”
Then go to Tab “Tunnels” and enter Source Port 8080
Select “Dynamic” from the Destination Port
Click Open to buildup the tunnel

Now start the Proxifier and add the following Setting:

Proxifier Setting for SSH SOCKS tunnel

I find it usefull (but it is not neccessary) to add a rule to the Proxification Rules:

Proxification Rules for ssh tunnel

That’s all: openSSH has an integrated SOCKS-Proxy. Proxifier sends all traffic through the SSH-Tunnel (which is encrypted) and the SOCKS-proxy in openSSH on the other side sends the traffic to the destination hosts and returns incomming traffic to you.

Post to Twitter Tweet This Post

Break through a firewall – SOCKS (dante) tunnel and OS X

12:37 PM No comments
New customers, new problems: I am used to get internet-access over the Intranet of my customers and can build up a VPN connection or SSH/SSL connections, so I can reach my IMAP-Mailbox in a secure way. This time I got completely blocked – only port 80 was allowed – and for me being without emails is like living without breathing. So my first plan here was to break through this firewall and get my connections through it.
I did something similar a couple of years before on our university-network, when the admins there decided to block the traffic of the dorm and limit it to port 21/80. So my first idea was a SOCKS-tunnel.

Providing the SOCKS-Tunnel

After asking google for SOCKS I found a recommended implementation of SOCKS5: Dante
There is a very nice overview of SOCKS-implementations on wikipedia: http://en.wikipedia.org/wiki/SOCKS

Installation

Installation was quite easy: On SuSE it is a rpm you simply install, on FreeBSD you find it in the ports (cd /usr/ports/net/dante/; make; make install ). More interesting got the configuration of Dante, and that is what I want to explain today (since I did not find a howto and had to read the documentation):

Configuration

The config-file can be found in /etc/sockd.conf (/usr/local/etc/sockd.conf on FreeBSD). This you have to edit in the following way:

#define the logfile for dante
logoutput: /var/log/dante.log

#define the IP/Port Dante should listen for connections
internal: <IP address of your dante server> port = 80

#define the IP/interface Dante should use for outgoing connections
# Check the name of your interface using ifconfig
external: eth0
#Alternative: >external: <IP address that should be used>

#authentication: deactivated, since I will use a static IP-adress – that is auth enough now!
method: username none

#unprivileged user for Dante
user.notprivileged: nobody

Ok – that was the basic stuff – now the interesting part:

#Who can access this SOCKS Tunnel?
client pass {
from: <your ip here>/32 port 1-65535 to: 0.0.0.0/0
}

#Loopback may also access the tunnel
client pass {
from: 127.0.0.0/8 port 1-65535 to: 0.0.0.0/0
}

#Block all others
client block {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect error
}

# Once connected, who may be connected then?
# block connections from anywhere to loopback
block {
from: 0.0.0.0/0 to: 127.0.0.0/8
log: connect error
}

# Allow connections from anywhere to client
pass {
from: <your ip here>/32 to: 0.0.0.0/0
protocol: tcp udp
}

pass {
from: 127.0.0.0/8 to: 0.0.0.0/0
protocol: tcp udp
}

#Block the rest
block {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect error
}

Please note: this example will limit the access to one IP (/32), you can also allow more IPs. If you are not firm to subnetting, use the Subnet Cheat Sheet

Starting up Dante

After this simple configuration, your Dante-server should start without any problems, by typing:

/etc/rc.d/sockd start

(On FreeBSD first add sockd_enable=”YES” to your /etc/rc.conf, then type: /usr/local/etc/rc.d/sockd start ). Now you can watch your logfile under /var/log/dante.log to see what is going on.

Now let’s come to the complicated part: Make OSX work with the SOCKS5 tunnel we created.

Making OSX using the SOCKS5 tunnel

The first (and unsuccessfull) idea was, to configure it in in the network setup in the System Preferences. (Go to the Network preference pane, then click on further options and go to the “Proxies” tab. Enable SOCKS Proxy and fill in the IP of your server and the correct port, save the changes and activate the setting). Unfortunatly, this setting only works only for Cocoa and WebKit-based applications (and since not all of these applications use the System Preferences, you are covered only by 95% there too).

Screenshot Systempreferences network german

Screenshot Systempreferences network german

Thunderbird and Firefox for example doe not use the System preferences. You can both configure them to make them use the SOCKS tunnel, but to be honest: I do not want to reconfigure my applications on every new place. So I looked for a general SOCKS-Proxy.

After some search I found Proxifier – a commercial product, that is easy to setup easy to use and does everything you need with just a few clicks. There is also a version for Windows, that I did not check out, but I’m sure it will work as good as the OS X-version does.

The SetUp is easy and does not need the really good documentation that is provided on the Proxifier-homepage. If you feel better by watching the dosumentation, here you will find it: http://www.proxifier.com/mac/documentation/ProxifierHelp.html

After starting and configuring Proxifier, I got back online to the world, bypassing the firewall of my customer over port 80.

ATTENTION: Dante and SOCKS may not be confused with VPN, even if it is the same feeling! The data is send clear-text and my be visualized with any Packet-Sniffer!

Post to Twitter Tweet This Post

How to mirror (“steal”) a complete website with OS X

11:52 AM 1 comment

Anyone of you already know this situation: You found a really great and helpfull site on the internet, put a bookmark on it, and when you need the site and check back to it, it is discontinued and closed.

For me, this is a reason to mirror helpful and (to me) important websites locally to my computer. I usually used a tool called “WebDevil”, that had a view problems, but worked fine. Unfortunatly, this project now seems to be discontinued, since I was not able to get an actual copy of the program. So I began a search for a new application and found:

WebGrabber

WebGrabber is published under the GPL (“OpenSource Freeware”) by Eric Peyton of epicware Inc. and has everything you need to mirror a single website, or the complete internet to your local machine and many more features:

Any thinkable option can be set: ignoreing the robots.txt, rewriting the local saved version, rewriting the links (to get independent from the website), limit the mirroring to one website or even to the same directory on the website, syncing of the actual version of the website and your saved copy, resuming stopped downloads and many more. You can set the download-depth, the sleep time between the documents, max. transfer rates and even the buffer sizes.

Additionally, you can define a set of filters what to download and what not. WebGrapper is definitely the best and compfortable mirroring-tool for the Mac I’ve seen up to now.

Download Link: http://www.epicware.com/webgrabber.html

Since the website was several times not available for me and links in the readme are not longer valid, I’ll mirror this cool project here, since it seems to be discontinued too: webgrabber07tar

The sourcecode of this project (XCode) is included.

Post to Twitter Tweet This Post

Categories: Mac OS X Tags: , , , ,

Converting Windows characters to Mac and vice versa – Filter for BBEdit

06:27 PM No comments

When working with scripts written in perl or php, the encoding of special german characters like “ü” (ue), “ö” (oe) and “ä” (ae) can’t be set correctly, since the file-encoding needs to be set to “Mac OS Roman” with “Unix Linefeeds (LF)”. So these special characters, called “Umlaute” gets mapped to untypable characters in the ASCII-table.

Due to the simple and effective integration of perl into BBEdit, there is an easy solution for this problem: A trivial perl script with some Regular Expressions, that replace all characters within a selection by the correct character.

The script for converting Windows to Mac looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/perl -w
 
while(<>) {
	my $line = $_;
	$line =~ s/ƒ/Ä/g;
	$line =~ s/÷/Ö/g;
	$line =~ s/‹/Ü/g;
	$line =~ s/fl/ß/g;
	$line =~ s/‰/ä/g;
	$line =~ s/ˆ/ö/g;
	$line =~ s/¸/ü/g;
	print $line;
}

And verci versus: the script for Mac to Windows looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/perl -w
 
while(<>) {
	my $line = $_;
	$line =~ s/Ä/ƒ/g;
	$line =~ s/Ö/÷/g;
	$line =~ s/Ü/‹/g;
	$line =~ s/ß/fl/g;
	$line =~ s/ä/‰/g;
	$line =~ s/ö/ˆ/g;
	$line =~ s/ü/¸/g;
	print $line;
}

You can also download the two scripts here: Download the scripts for free

Installation:

Copy the two files into your BBEdit “Application Support”-folder, located in your userfolder at:

~/Library/Application Support/BBEdit/Unix Support/Unix Filters/

Unix Filters directory after installation

Unix Filters directory after installation

So your “Unix Filters”-directory will now look something like this, as showed in the picture right standing.

If you create the scripts yourself, please keep in mind that the linefeed format of the file must be set to “Unix (LF)” for the scripts to work properly.

Here you find your new Filter

Here you find your new Filter

After you installed the script, you have to restart BBEdit. To use the filter, simply select the text you want to change. Then select the Filter you want to apply from the “#!” menu to do the conversion.

Additionally characters can be added to this example. Please keep in mind, that you may not break the Regular Expression. A good reference for Regular Expressions can be found at http://de.selfhtml.org.

This is an easy way to deal with a correct ISO-Latin 1 (ISO 8859-1) under BBEdit, using the Mac Roman encoding without having any trouble.

Example:

Here you can see an example of the result of the Filter:

A text in Mac-Roman, selected for conversion

A text in Mac-Roman, selected for conversion

After selecting “Konv Mac>Win.pl”:

The characters within the selection got converted

The characters within the selection got converted

Post to Twitter Tweet This Post