Password
Make sure to use a strong password for the user root
Combination of Upper Lower Numbers & Special Characters
(Note: ony the first 8 characters are recognized)
Change Local Time Zone (Default is PST)
rm /private/var/db/timezone/localtime
cd /private/var/db/timezone/
ln -s /usr/share/zoneinfo/Canada/Eastern localtime
Note replace Canada/Eastern with your time zone
To find your time zone cd /usr/share/zoneinfo/ ls
Network Info
Check All Open Ports
SSH netstat - n (AppleTV 2G netstat is installed)
apt-get install netstat (for iPhone Touch & iPad)
View Data Sent & Received Every 5 Seconds
SSH netstat -I en1 5 (wireless)
SSH netstat -I en0 5 (ethernet)
Typical Open Ports
TCP port 22 SSH/SFTP
TCP port 80 Web Server (lighttpd)
UDP port 123 network time
TCP port 3689 iTunes Library Sharing feature (daap)
UDP port 5353 Finding computers using Bonjour (mdns)
UDP port 53 DNS
Web Server Logs
Add a Log Rotator Script (See the one in Extras)
How to
check your logs for hack attempts
Check logs for "friendly" bots and crawlers
SSH grep "bot" /private/var/log/lighttpd/access.log
SSH grep "crawler" /private/var/log/lighttpd/access.log
SSH grep "robot" /private/var/log/lighttpd/access.log
SSH grep "spider" /private/var/log/lighttpd/access.log
View realtime Lighttpd log stats
SSH tail -f /var/log/lighttpd/access.log (AppleTV 2G)
Download tail here for the iPhone Touch & iPad
SFTP tail /private/var/stash/bin SSH chmod + tail
Block Apple Updates
(This will prevent iOS updates and call home traffic)
SSH nano /private/etc/hosts
Add these lines
127.0.0.1 mesu.apple.com
127.0.0.1 2gactivation.apple.com
127.0.0.1 a1.v.phobos.apple.com
127.0.0.1 a568.phobos.apple.com
127.0.0.1 ab2-so.apple.com
127.0.0.1 albert-so.apple.com
127.0.0.1 albert.apple.com
127.0.0.1 appldnld.apple.com
127.0.0.1 appldnld.apple.com.edgesuite.net
127.0.0.1 apple.ca
127.0.0.1 apple.com
127.0.0.1 apple.com.edgesuite.net
127.0.0.1 ax.itunes.apple.com
127.0.0.1 ax.phobos.apple.com
127.0.0.1 ax.phobos.apple.com.edgesuite.net
127.0.0.1 ax.search.itunes.apple.com
127.0.0.1 ax.sidebar.itunes.apple.com
127.0.0.1 ax.su.itunes.apple.com
127.0.0.1 buy.itunes.apple.com
127.0.0.1 buyiphone.apple.com
127.0.0.1 c.itunes.apple.com
127.0.0.1 click.linksynergy.com
127.0.0.1 deimos.apple.com
127.0.0.1 deimos2.apple.com
127.0.0.1 deimos3.apple.com
127.0.0.1 gdata.youtube.com
127.0.0.1 genius.itunes.apple.com
127.0.0.1 indigo-edge.apple.com
127.0.0.1 indigo01.apple.com
127.0.0.1 ips.apple.com
127.0.0.1 itunes.apple.com
127.0.0.1 itunes.apple.com.edgesuite.net
127.0.0.1 itunes.com
127.0.0.1 metrics.apple.com
127.0.0.1 metrics.mzstatic.com
127.0.0.1 my.itunes.apple.com
127.0.0.1 myapp.itunes.apple.com
127.0.0.1 mzstatic.com
127.0.0.1 mzsupport.apple.com
127.0.0.1 nwk-unbrick3.apple.com
127.0.0.1 phobos.apple.com
127.0.0.1 sc.itunes.apple.com
127.0.0.1 search.itunes.apple.com
127.0.0.1 secure.me.com
127.0.0.1 sidebar.itunes.apple.com
127.0.0.1 storepreview.apple.com
127.0.0.1 su.itunes.apple.com
127.0.0.1 support.mac.com
127.0.0.1 trailers.apple.com
127.0.0.1 userpub.itunes.apple.com
127.0.0.1 www.apple.ca
127.0.0.1 www.apple.com
127.0.0.1 www.atdmt.com
127.0.0.1 www.atlassolutions.com
127.0.0.1 www.google.com
127.0.0.1 www.itunes.com
SSH killall lighttpd to activate changes
404 Errors (Page Not Found) logging
SSH mkdir /private/var/www/IDS
lighttpd.conf
Change server.error-handler-404 = "404error.html" to server.error-handler-404 = "/IDS/404error.php"
Add these lines
$HTTP["remoteip"] == "127.0.0.1" {
url.access-deny = ( "" )
}
$HTTP["url"] =~ "/\IDS/" {
url.access-deny = ( "" )
}
404error.php (/private/var/www/IDS/404error.php)
<html>
<head>
<title>Page Not Found</title>
<meta http-equiv="refresh" content="1;url=/">
</head>
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$pagina = $_SERVER['REQUEST_URI'];
$visitorSpecs =
"<center><BR><BR><BR>".
"<h2><b>Page Not Found";
echo $visitorSpecs;
$datum = date("d-m-y / H:i:s");
$invoegen = $datum . " - " . $ip . " - " . $pagina . "<br />";
$fopen = fopen("404IPs.html", "a");
fwrite($fopen, $invoegen);
fclose($fopen);
?>
</html>
SSH Access
If you want to use SSH from outside the firewall
Change the SSH port to prevent SSH brute force attacks.
1) The simplist way with no changes on the web server
On the firewall port forward a different port number to port 22 on the web servers IP
(NOTE: SSH to that port on the firewalls IP from outside the firewall & SSH to port 22 on the web servers IP inside the firewall)
Or
2) Change the SSH port on the web server (Two possible mehods)
2A) SSH nano /private/etc/services
Add the line
unknown 225/tcp # secret SSH port (225 or any free non standard port)
nano /Library/LaunchDaemons/com.openssh.sshd.plist
Change
<key>SockServiceName <key>
<string>ssh</string>
To
<key>SockServiceName</key>
<string>unknown</string>
reboot
2B) SSH nano /etc/ssh/ssh_config
Change this line
# Port 22
To
Port 225 (225 or any free non standard port - remove #)
reboot
NOTE: Re 2A) & 2B) Don't forget to port forward the new SSH port on the firewall