PlayTerm — Watch the linux guru at work

Posted by & filed under Linux.

PLAYTERM is intended to raise the skills of terminal CLI users, share their skills and inspire others.
PLAYTERM wants to push forward a new way of education, because terminalsessions are language-independent, extremely educative & entertaining.

Basically, PlayTerm lets you ‘look over’ a guru’s shoulder, helping to learn the concept in the video.

It may sound strange, but eventhough CLI stuff sounds like an isolated environment, it is an extremely social playground. Since the eighties, billions of users have helped eachother improving their skills, to get things done faster.
However, there was never a playground for sharing this live, but only peeking over the shoulder of your neighbour (or a *N*X screen -x session).

PLAYTERM wants to restore the actual ‘live’ feeling, which was once established in the BBS scene. There, the BBS’es system operators could ‘takeover’ a users’s session..and show him the way around, or teach him a new programming language.

www.playterm.org/

Completely remove a apt package

Posted by & filed under Uncategorized.

Today I was dealing with a botched installation. apt-get remove was not enough to remove all files. This command completely wipes out the package and all its settings.

In my case I had already removed the package but it had left behind files that caused a re-install to fail. I simply installed the app (it failed as expected), then ran the purge command:

sudo apt-get –purge remove

Tails — Tor

Posted by & filed under Networking.

Tails relies on the Tor anonymity network to protect your privacy online: all outgoing connections to the Internet are forced to go through Tor.

Tails is a live system: a complete operating-system designed to be used from a CD or a USB stick independently of the computer’s original operating system. It is Free Software and based on Debian GNU/Linux.

Tails is configured with a special care to not use the computer’s hard-disks, even if there is some swap space on it. The only storage space used by Tails is the RAM memory, which is automatically erased when the computer shuts down. So you won’t leave any trace neither of the Tails system nor of what you did on the computer. That’s why we call it “amnesic”.

tails.boum.org/index.en.html

Linux: Find files modified between dates

Posted by & filed under BASH, Linux.

I found a handy technique to find files modified between a specific date. In essence, we touch two temp files, setting the modified dates to the range we want to find:

Note the date is yyymmddtime.

Then we run the find command:

Done!

pfSense Firewall / Router

Posted by & filed under Uncategorized.

pfSense is a free, open source customized distribution of FreeBSD tailored for use as a firewall and router. In addition to being a powerful, flexible firewalling and routing platform, it includes a long list of related features and a package system allowing further expandability without adding bloat and potential security vulnerabilities to the base distribution. pfSense is a popular project with more than 1 million downloads since its inception, and proven in countless installations ranging from small home networks protecting a PC and an Xbox to large corporations, universities and other organizations protecting thousands of network devices.

This project started in 2004 as a fork of the m0n0wall project, but focused towards full PC installations rather than the embedded hardware focus of m0n0wall. pfSense also offers an embedded image for Compact Flash based installations, however it is not our primary focus.

www.pfsense.org/

.htaccess Cheat Sheet

Posted by & filed under Uncategorized.

Here is a simple cheatsheet for the .htaccess file:

Enable Directory Browsing

Options +Indexes
## block a few types of files from showing
IndexIgnore *.wmv *.mp4 *.avi

Disable Directory Browsing

Options All -Indexes

Customize Error Messages

ErrorDocument 403 /forbidden.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /servererror.html

Get SSI working with HTML/SHTML

AddType text/html .html
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
# AddHandler server-parsed .htm

Change Default Page (order is followed!)

DirectoryIndex myhome.htm index.htm index.php

Block Users from accessing the site

order deny,allow
deny from 202.54.122.33
deny from 8.70.44.53
deny from .spammers.com
allow from all

Allow only LAN users

order deny,allow
deny from all
allow from 192.168.0.0/24

Redirect Visitors to New Page/Directory

Redirect oldpage.html www.domainname.com/newpage.html
Redirect /olddir www.domainname.com/newdir/

Block site from specific referrers

RewriteEngine on
RewriteCond %{HTTP_REFERER} site-to-block\.com [NC]
RewriteCond %{HTTP_REFERER} site-to-block-2\.com [NC]
RewriteRule .* – [F]

Block Hot Linking/Bandwidth hogging

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ – [F]

Want to show a “Stealing is Bad” message too?

Add this below the Hot Link Blocking code:

RewriteRule \.(gif|jpg)$ www.mydomain.com/dontsteal.gif [R,L]

Stop .htaccess (or any other file) from being viewed


order allow,deny
deny from all

Avoid the 500 Error

# Avoid 500 error by passing charset
AddDefaultCharset utf-8

Grant CGI Access in a directory

Options +ExecCGI
AddHandler cgi-script cgi pl
# To enable all scripts in a directory use the following
# SetHandler cgi-script

Password Protecting Directories

Use the .htaccess Password Generator and follow the brief instructions!

Change Script Extensions

AddType application/x-httpd-php .gne

gne will now be treated as PHP files! Similarly, x-httpd-cgi for CGI files, etc.

Use MD5 Digests

Performance may take a hit but if thats not a problem, this is a nice option to turn on.

ContentDigest On

The CheckSpelling Directive

From Jens Meiert: CheckSpelling corrects simple spelling errors (for example, if someone forgets a letter or if any character is just wrong). Just add CheckSpelling On to your htaccess file.

The ContentDigest Directive

As the Apache core features documentation says: “This directive enables the generation of Content-MD5 headers as defined in RFC1864 respectively RFC2068. The Content-MD5 header provides an end-to-end message integrity check (MIC) of the entity-body. A proxy or client may check this header for detecting accidental modification of the entity-body in transit.

Note that this can cause performance problems on your server since the message digest is computed on every request (the values are not cached). Content-MD5 is only sent for documents served by the core, and not by any module. For example, SSI documents, output from CGI scripts, and byte range responses do not have this header.”

To turn this on, just add ContentDigest On.

Enable Gzip – Save Bandwidth

# BEGIN GZIP

# Combine the below two lines – I’ve split it up for presentation
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css
application/x-javascript application/javascript

# END GZIP

Turn off magic_quotes_gpc

# Only if you use PHP

php_flag magic_quotes_gpc off

Set an Expires header and enable Cache-Control


ExpiresActive On
ExpiresDefault “access plus 1 seconds”
ExpiresByType text/html “access plus 7200 seconds”
ExpiresByType image/gif “access plus 518400 seconds”
ExpiresByType image/jpeg “access plus 518400 seconds”
ExpiresByType image/png “access plus 518400 seconds”
ExpiresByType text/css “access plus 518400 seconds”
ExpiresByType text/javascript “access plus 216000 seconds”
ExpiresByType application/x-javascript “access plus 216000 seconds”


# Cache specified files for 6 days

Header set Cache-Control “max-age=518400, public”

# Cache HTML files for a couple hours

Header set Cache-Control “max-age=7200, private, must-revalidate”

# Cache PDFs for a day

Header set Cache-Control “max-age=86400, public”

# Cache Javascripts for 2.5 days

Header set Cache-Control “max-age=216000, private”

MySQL – Monitor live SQL queries as they process

Posted by & filed under Uncategorized.

I have read this can cause adverse performance affects and therefore should only be used for troubleshooting or on a dev box (as is my case)

=> Open your MySQL configuration file, normally it located at /etc/mysql/my.cnf

=> Look for a this line

# log=/var/log/mysql/mysql.log

=> remove the # and save the file

log=/var/log/mysql/mysql.log

=> Now, restart your mysql server to take immediate effect

$ /etc/init.d/mysql restart

=> Now we just tail the log file:

$ tail -f /var/log/mysql/mysql.log

Stream audio over SSH

Posted by & filed under BASH, Linux.

Ok this is sweet:

ssh user@server.com “cat /Torrents/Complete/15\ years\ of\ Essential\ Mix\ Sasha\ \&\ Digweed/Essential\ Mix\ 137\ -\ Sasha\ -\ Live\ @\ radio\ 1\ on\ tour\ from\ Sanctuary\ -\ [30.06.1996].mp3” | mpg123 –

And here is a more advanced version to find multiple files (unworking)
ssh user@server.com “find /Torrents/Complete -wholename \*Essential\*.mp3 -print0 | xargs -0 cat” | mpg123 –

this finds fines in /Torrents/Complete and pipes them to mpg123

Skynet — back to life

Posted by & filed under Linux, Pen Testing, Projects, Security, WiFi.

The other day, I decided to bring my old “Skynet” device back online. The master came right online, but the drone was having some problems. I worked it out, and it’s all working correctly now. w00t. Just waiting on my N-Female to RP-TNC connector and I will be read to rock with the Yagi.

 

kismet_111209

Also, I noticed that Kismet-Newcore is out which has a lot of nice features. There is also a plugin available called “Lorcon” that allows kismet to inject and sniff 802.11 frames. Sweet! I will compile both on the rother when I get time…

DD Goodness

Posted by & filed under Linux.

Well after doing a simple dd backup of my WMBFS formatted usb drive, wiping it out and using it as a Ubuntu Netbook boot disk, I now wanted to recover my WMBFS image. It worked perfectly.

It took a while, but it’s all back!

Monitoring a Linux process by PID and sending a e-mail notification upon failure

Posted by & filed under BASH, Email, Linux, Programming.

One of my clients needs their vendor to be alerted when their Backup Exec service crashes. I wrote the following quick-n-dirty batch script intended to be ran as a cron job.

And the cron line would be something like this: