SSH Tunnel Bypassing Transparent proxy using apache

A feature of the apache webserver is that it allows to to create a SSH connection through a transparent proxy / firewall. This is a stealth technic so no one will see it even in a large company network. Only IPoAC is able to interference this.

If you have internet access to port 80 (http) or 443 (https) you can establish a SSH connection to one of that ports. Proxys want the users to surf the web. most of the proxyes will only let their users through the paths they know safe (or whatever filtering their administrators may have set). In the best scenario, the proxy will not allow one particular HTTP method called CONNECT. This method is the one used for SSL / TLS protocol. It establishes a tunneled connection between the client and a remote server, through the proxy server. Since it is used by SSL / TLS, some proxys will let the CONNECT method free to certain sites, and most probably only on port 443.

Apache plus mod_proxy module will let us set up an HTTP server listening on port 80, and at the very same time an HTTP proxy. The proxying part is done by mod_proxy. This module turns Apache into a fully functional HTTP forward-proxy and reverse-proxy. the exciting feature of mod_proxy is its ability to handle the CONNECT method. It will even handle it if the transparent proxy, at the boundaries of our enterprise network, does not allow the CONNECT method. This, because we will talk GET and POST with Apache, the CONNECT thing happens inside Apache, and outside of the control of the enterprise proxy. The end result: we can use the CONNECT method.

Client side

  • SSH Client
  • Proxyclient

server side

  • apache webserver 2.x

This is an example virtual host configuration which I used for testing this implementation.

<VirtualHost *:80>
ServerName proxy.mydomain.com
ProxyRequests On
AllowCONNECT 22

<Proxy *>
Order deny,allow
Deny from all
</Proxy>

<ProxyMatch (host1|host2)\.mydomain\.com>
Order deny,allow
Deny from all
#Now we allow only our IP to access. Note that this IP must be the  public IP address of the enterprise proxy:
Allow from 222.22.22.100
</ProxyMatch>

# This directive enables DNS lookups so that host names can be logged. The  value Double refers to doing double reverse DNS lookup.
#That is, after a  reverse lookup is performed, a forward lookup is then performed on that  result. At least one of the IP addresses in the forward lookup must  match the original address. It is paranoid but is a good security  measure

HostnameLookups Double

ErrorLog /var/log/apache2/proxy.error.log
CustomLog /var/log/apache2/proxy.access.log common
</VirtualHost>

And now, the final step: configure our browser to use 127.0.0.1 on port 8080 as proxy. Finally we can login to our SSH server and try pointing our browser to any website we know blocked by the enterprise transparent proxy!

I know I left the part setting up apache and proxy, but this isn’t a tutorial for noobs ;-)

This is the BEST part of using Apache. You can set it up as normal web server, serving some webpage. This way whoever point to mydomain.com will see a normal and harmless website, and won’t be able to distiguish it from a non-proxying server.

neues DVD-Rom neue Aktivierung

Heute habe ich bei meinem Media PC mit XP Pro der an dem schönen 32″ Monitor angeschlossen ist das alte IDE DVD-Rom gegen einen SATA DVD Brenner getauscht. Dank des guten Gehäuses eine Sache von maximal 30 Sekunden. Jedoch bekam ich dann die Meldung von Windows, dass sich die Hardware grundlegend geändert hätte und ich solle Windows innerhalb der nächsten 3 Tage bitte neu aktivieren. Ich weiß zwar, dass XP nicht mehr das neuste Betriebssystem ist, aber für 20 Euro immer noch deutlich besser als Windows Virus und deutlich billiger als Fenster 7. Zum Filme gucken vollkommen ausreichend.

Jetzt frage ich mich allerdings, was M$ sich dabei denkt, dass wenn ich nur das DVD Laufwerk tausche ich den PC grundlegend geändert hätte. Hoffentlich wird das wenn ich Fenster 7, dass ich bis jetzt nur auf dem Laptop habe, auch auf dem PC installiere nicht so penetrant, wenn ich mal etwas auswechsel. ARGH!

Changed to worker mpm

Today I changed my server to from prefork mpm to worker mpm.

There are only some issues: in my phpmyadmin I had to set auth from http to cookie. And PHP_ADMIN_VALUE don’t work in the vhosts.

How to install it:

sudo apt-get install apache2-mpm-worker libapache2-mod-fcgid

In the single vhosts

Options Indexes ExecCGI
AddHandler fcgid-script .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php

So that isn’t hard to do.

Well I would like to have a windows server with apache which is also threaded like worker mpm, but there is no cheap hoster for that yet. At home have that server is not an option cause of the small upload I have with my DSL, the coast of energie and where the hell should I put that server in my small apartment to that I still can sleep?

Compile openssl windows 64 bit

Sadly there is no asm available for 64 bit on windows. That makes openssl minimal slower than with asm, but there is the native 64 bit binary :-)

perl Configure VC-WIN64A --prefix=/Apache22 --openssldir=/Apache22/conf enable-camellia disable-idea
ms\do_win64a
nmake -f ms\ntdll.mak
REM remove md2 and idea test
nmake -f ms\ntdll.mak test

Datum in batch umformatieren

Ein einfaches echo %date% gibt zwar das Datum aus, aber nicht gerade in einer schönen Formatierung, vorallem wenn damit Ordner oder Dateien automatisch erstellt werden. Da sortieren der Dateien nach Namen verursacht dann ein ziemliches chaos. Deshalb sollte das Datum eine andere Reihenfolge haben wie: YYYYMMDD

FOR /F "tokens=1,2,3 delims=/. " %%a in ('date /T') do set datum=%%c%%b%%a
echo %datum%

Gleich ein wenig schöner :-)

remove /MACHINE:X86 from make files with php

I use PHP on the command line cause I know it the syntax better than any other scriting language and it works on linux and windows. This is about removing the x86 to be able to build apache in x64 (64 bit) on windows.

<?php
$files=array(
 "srclib/apr/libapr.mak",
 "srclib/apr-iconv/build/modules.mk.win",
 "srclib/apr-iconv/libapriconv.mak",
 "srclib/apr-util/dbd/apr_dbd_freetds.mak",
 "srclib/apr-util/dbd/apr_dbd_mysql.mak",
 "srclib/apr-util/dbd/apr_dbd_odbc.mak",
 "srclib/apr-util/dbd/apr_dbd_oracle.mak",
 "srclib/apr-util/dbd/apr_dbd_pgsql.mak",
 "srclib/apr-util/dbd/apr_dbd_sqlite2.mak",
 "srclib/apr-util/dbd/apr_dbd_sqlite3.mak",
 "srclib/apr-util/dbm/apr_dbm_db.mak",
 "srclib/apr-util/dbm/apr_dbm_gdbm.mak",
 "srclib/apr-util/ldap/apr_ldap.mak",
 "srclib/apr-util/libaprutil.mak"
);
foreach($files as $file){
 if(file_exists($file)){
 echo "Replace in: ". $file ."\n\r";
 file_put_contents($file,str_ireplace(" /MACHINE:X86","",file_get_contents($file)));
 }
 else
 {
 echo "FAILED: ". $file ."\n\r";
 }
}
?>

Posts Tagged windows

Archives by Month: