Thứ Ba, 15 tháng 1, 2008

Pass Firewall

Cách thứ 2:
Các bạn đều bị vướng firewall khi cần xem một website nào đó. Bạn dùng các free proxy trên Internet đê đi qua nó nhưng ISP lại firewall ngay site đó.
Tốt nhất là chúng ta tự làm lấy.
Các bước thực hiện :

1. Ðiều kiện

Tìm một free webspace có hỗ trợ CGI với dung lượng càng lớn càng tốt (bị popup hay banner không quan trọng).
Vào
http://www.freewebspace.net để tìm với advanced search là support CGI

2. Tạo 2 file startproxy.cgi và anonproxy.cgi có mã nguồn như sau

File startproxy.cgi
#!/usr/local/bin/perl
#
$proxyname= 'anonproxy.cgi' ;

# Read the URL from the query input
($ENV{'QUERY_STRING'}=~ /^URL=([^&]*)/) || &showstartform ;
$URL= $1 ;

# un-encode the URL
$URL=~ s/+/ /g ;
$URL=~ s/%([da-fA-F]{2})/pack("c", hex($1))/ge ;

# Warn the user against FTP or other URL's
($scheme)= $URL=~ /^(.[w+.-]*):/ ;
(($scheme eq '') || ($scheme=~ /^http$/i))
|| &HTMLdie("Sorry, only HTTP browsing is currently supported.") ;

# Support abbreviated URL entries (but only HTTP)
$URL=~ s#^http:##i ;
$URL=~ s#^//##i ;
($host, $port, $path)= ($URL=~ m#([^/:]*)(:?[^/]*)(/.*)?$#) ;
$host= "
www.$host.com" unless $host=~ /./ ;
$path || ($path= "/") ;
$URL= "http://$host$port$path" ;

# Print the Location: header
print "Location: $proxyname/$URLnn" ;

exit ;


# Present entry form
sub showstartform {
print <<EOF ;
Content-type: text/html

<html>
<head>
<title>Start Using CGI Proxy</title>
</head>
<body>

<h1>CGI Proxy</h1>

<p>Start browsing through this CGI-based HTTP proxy by entering a URL
below. Not all functions will work (e.g. cookies), but most pages will
be fine.

<form action="$ENV{'SCRIPT_NAME'}" method=get>
<input name="URL" size=50>
<p><input type=submit value=" Begin browsing ">
</form>
<p>
<hr>
<a href="http://vncracking.tsx.org"><i>NVH(c)- vncracking</i></a>
<p>
</body>
</html>
EOF

exit ;
}
File anonproxy.cgi
#!/usr/local/bin/perl
#

$textonly= 0 ;
# set to 1 to allow only text data, 0 to allow all
# If you have more than 1000 users per day, you should probably
# set to text only to lessen server load.


# Requires Perl 5. To run in Perl 4, or for more speed, remove this line and
# hard-code $AF_INET and $SOCK_STREAM (usually in /usr/include/sys/socket.h
# or /usr/include/linux/socket.h) into &newsocketto().
use Socket ;


$ENV{'SCRIPT_NAME'}=~ s#^/## ;

# Copy often-used environment vars into scalars, for efficiency
$env_accept= $ENV{'HTTP_ACCEPT'} || '*/*' ; # may be modified later

# QUERY_STRING with question mark prepended
$qs_out= $ENV{'QUERY_STRING'} ne '' ? '?' . $ENV{'QUERY_STRING'} : '' ;

# Calculate $thisurl, useful in many places
$portst= $ENV{'SERVER_PORT'}==80 ? '' : ':' . $ENV{'SERVER_PORT'} ;
$thisurl= join('', 'http://', $ENV{'SERVER_NAME'}, $portst,
'/', $ENV{'SCRIPT_NAME'}, '/') ;


#------ parsing of URL and other input ------------------------------------

# Read the URL from PATH_INFO, stripping leading slash
($URL= $ENV{'PATH_INFO'})=~ s#^/## ;

($scheme, $host, $port, $path)=
($URL=~ m#^([w+.-]+)://([^/:]*):?([^/]*)(/.*)?$#i) ;
$port || ($port= 80) ;

# Alert the user to non-HTTP URL, with an intermediate page
&nonHTTPwarning($URL.$qs_out) unless ($scheme=~ /^http$/i) ;

# If path is empty, send back Location: to include the final slash.
# Otherwise, the browser itself will resolve relative URL's wrong.
if ($path eq '') {
print "HTTP/1.0 302 Found012Location: ", $thisurl, $URL, "/012012" ;
exit ;
}


# Exclude non-text if it's not allowed. Err on the side of allowing too much.
if ($textonly) {

$nontext= 'gif|jpeg|jpe|jpg|tiff|tif|png|bmp|xbm' # images
. '|mp2|mp3|wav|aif|aiff|au|snd' # audios
. '|avi|qt|mov|mpeg|mpg|mpe' # videos
. '|gz|Z|exe|gtar|tar|zip|sit|hqx|pdf' # applications
. '|ram|rm|ra' ; # others

&nontextdie if ($path=~ /.($nontext)(;|$)/i) ;

# Then, filter the "Accept:" header to accept only text
$env_accept=~ s#*/*#text/*#g ; # not strictly perfect
$env_accept= join(', ', grep(m#^text/#i, split(/s*,s*/, $env_accept)) ) ;
&nontextdie unless $env_accept ne '' ;
}


$realhost= $host ;
$realport= $port ;
$realpath= $path ;

# there must be a smoother way to handle proxies....
if ($ENV{'http_proxy'}) {
local($dontproxy) ;
foreach (split(/s*,s*/, $ENV{'no_proxy'})) {
last if ($dontproxy= $host=~ /$_$/) ;
}
unless ($dontproxy) {
# could be slightly more efficient in Perl 5
($dummy,$realhost,$realport)=
$ENV{'http_proxy'}=~ m#^(http://)?([^/:]*):?([^/]*)#i ;
$realport= ($realport || 80) ;
$realpath= $URL ;
}
}

&newsocketto(*S, $realhost, $realport) ;

print S $ENV{'REQUEST_METHOD'}, ' ', $realpath, $qs_out, " HTTP/1.0015012",
'Host: ', $host, ':', $port, "015012",
'Accept: ', $env_accept, "015012", # possibly modified above
'User-Agent: Mozilla/4.01 (compatible; NORAD National Defence Network)', "015012" ;

# If request method is POST, copy content headers and body to request. Loop
# to guarantee all is read from STDIN.
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
$lefttoget= $ENV{'CONTENT_LENGTH'} ;
print S 'Content-type: ', $ENV{'CONTENT_TYPE'}, "015012",
'Content-length: ', $lefttoget, "015012015012" ;
do {
$lefttoget-= read(STDIN, $postbody, $lefttoget) ;
print S $postbody ;
} while $lefttoget && length($postbody) ;

# For GET requests, just add extra blank line
} else {
print S "015012" ;
}

vec($rin= '', fileno(S), 1)= 1 ;
select($rin, undef, undef, 60)
|| &HTMLdie("No response from $realhost:$realport") ;


# Support both HTTP 1.x and HTTP 0.9
$status= <S> ; # first line, which is the status line in HTTP 1.x

# HTTP 1.x
if ($status=~ m#^HTTP/#) {
do {
$headers.= $_= <S> ; # $headers includes last blank line
} until (/^(015012|012)$/) ; # lines may be terminated with LF or CRLF

# Unfold long header lines, a la RFC 822 section 3.1.1
$headers=~ s/(015012|012)[ t]/ /g ;

# If we're text only, then cut off non-text responses
if ($textonly) {
$*= 1 ;
if ($headers=~ m#^Content-type:s*([w/]*)#i) {
(close(S), &nontextdie) unless $1=~ m#^text/#i ;
}
}

$/= '>' ;
@body= <S> ;

# HTTP 0.9
} else {
undef $/ ;
$_= $status . <S> ;
$status= '' ;

# split through ">", including "delimiters", and remove (via grep)
# the "actual" matches, which are blank
@body= grep(length,split( /([^>]*>?)/ )) ;
}

close(S) ;


$*= 1 ; # allow multi-line matching

# Set $basehost correctly-- first see if there's a <base> tag, then if
# there's a Location: header; otherwise, use original URL.
# This is part of &fullurl(), placed here for speed.
($_)= grep(/<s*baseb/i, @body) ;
if ( ($basehost) = m#<s*baseb[^>]*bhrefs*=s*"?([w+.-]+://[^/s">]+)#i ) {
} elsif ( ($basehost)= ($headers=~ m#^Location:s*([w+.-]+://[^/s]+)#i) ) {
} else { ($basehost= join('', 'http://', $host, (($port==80) ?'' :":$port") ) ) }

$basehost= $thisurl . $basehost ;


# If we get a 300-level response code, update the Location: header to point
# back through the script, so the browser will retrieve it correctly.
if ($status=~ m#^HTTP/[0-9.]*s*3dd#) {
$headers=~ s/^Location:s*(.*)/'Location: ' . &fullurl($1)/gie ;
$headers=~ s/^URI:s*(.*)/ 'URI: ' . &fullurl($1)/gie ;
}

# Update all URLs in all tags that refer to URLs
# Only update the URLs if it's HTML (or using HTTP 0.9), and if it's not
# empty.

if ( (($headers=~ m#^Content-type:s*text/html#i) || !$headers)
&& ($body[0] ne '') ) {

foreach (@body) {

# Put the most common cases first

s/(<[^>]*bhrefs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*ab/i ;

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*blowsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*blongdescs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*busemaps*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bdynsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*imgb/i ;

s/(<[^>]*bbackgrounds*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*bodyb/i ;

s/(<[^>]*bhrefs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*baseb/i ; # has special significance

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*blongdescs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*frameb/i ;

s/(<[^>]*bactions*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bscripts*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*formb/i ; # needs special attention

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*busemaps*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*inputb/i ;

s/(<[^>]*bhrefs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*areab/i ;

s/(<[^>]*bcodebases*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bcodes*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bobjects*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*barchives*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*appletb/i ;


# These are seldom-used tags, or tags that seldom have URLs in them

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*bgsoundb/i ; # Microsoft only

s/(<[^>]*bcites*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*blockquoteb/i ;

s/(<[^>]*bcites*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*delb/i ;

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*embedb/i ; # Netscape only

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bimagemaps*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*figb/i ; # HTML 3.0

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*h[1-6]b/i ; # HTML 3.0

s/(<[^>]*bprofiles*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*headb/i ;

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*hrb/i ; # HTML 3.0

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*blongdescs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*iframeb/i ;

s/(<[^>]*bcites*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*insb/i ;

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*layerb/i ;

s/(<[^>]*bhrefs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*burns*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*linkb/i ;

s/(<[^>]*burls*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*metab/i ; # Netscape only

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*noteb/i ; # HTML 3.0

s/(<[^>]*busemaps*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bcodebases*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bdatas*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*barchives*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bclassids*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bnames*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*objectb/i ;

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bimagemaps*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*overlayb/i ; # HTML 3.0

s/(<[^>]*bcites*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*qb/i ;

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
s/(<[^>]*bfors*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*scriptb/i ;

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*selectb/i ; # HTML 3.0

s/(<[^>]*bsrcs*=s*"?)([^s">]*)/ $1 . &fullurl($2) /ie,
next if /<s*ulb/i ; # HTML 3.0

} # foreach (@body)


$body[0]= "<title>You are surfing through the ANONYMIZER</title>n"
. $body[0] ;

# Change Content-Length header, since we're changing the content
$headers=~ s/^Content-Length:.*012/ 'Content-Length: '
. (grep($newlength+=length(),@body), $newlength)
. "015012"/ie ;

}

# print the status line, headers, and the entire (modified) resource
print $status, $headers, @body ;

exit ;

sub fullurl {
local($relurl)= @_ ;
$relurl=~ m#^[w+.-]*:#i && return ($thisurl.$relurl) ; # absolute URL
$relurl=~ m#^/# && return ($basehost.$relurl) ; # absolute path, relative URL
return $relurl ; # relative URL
}

sub newsocketto {
local(*S, $host, $port)= @_ ;

# Create the remote host data structure, from host name or IP address
$hostaddr= ($host=~ /^(d+).(d+).(d+).(d+)$/)
? pack('c4', $1, $2, $3, $4) # for IP address
: ( (gethostbyname($host))[4] # for alpha host name
|| &HTMLdie("Couldn't find address for $host: $!") ) ;
$remotehost= pack('S n a4 x8', AF_INET, $port, $hostaddr) ;

# Create the socket and connect to the remote host
socket(S, AF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2])
|| &HTMLdie("Couldn't create socket: $!") ;
connect(S, $remotehost)
|| &HTMLdie("Couldn't connect to $host:$port: $!") ;
select((select(S), $|=1)[0]) ; # unbuffer the socket
}


# Alert the user to non-HTTP URL, with this intermediate page
sub nonHTTPwarning {
print <<EOF ;
HTTP/1.0 200 OK
Content-type: text/html

<html>
<head><title>WARNING: Entering non-anonymous area!</title></head>
<body>
<h1>WARNING: Entering non-anonymous area!</h1>
<h3>This proxy only supports HTTP. Any browsing to a non-HTTP URL will
be directly from your browser, and no longer anonymous.</h3>
<h3>Click the link below to continue to the URL, non-anonymously.</h3>
<blockquote><tt><a href="$_[0]">$_[0]</a></tt></blockquote>
<p>
<hr>
<a href="http://vncracking.tsx.org"><i>NVH(c)-vncracking</i></a>
<p>
</body>
</html>
EOF

exit ;
}


# Return "403 Forbidden" message, with explanatory text
sub nontextdie {
print <<EOF ;
HTTP/1.0 403 Forbidden
Content-type: text/html

<html>
<head><title>Cyber Anonymizer will not download</title></head>
<body>
<h1>Cyber Anonymizer will not download files</h1>
<p>Due to abuse, the Cyber Anonymizer will not download files because of bandwidth considerations. In particular, compressed files, some large graphics files, MP3 files, or ram files. For best results, turn off automatic image
loading if your browser lets you.
<p>If you need access to images or other binary data, route your browser
through a different proxy.
<p>
<hr>
<a href="http://vncracking.tsx.org"><i>NVH(c)-vncracking</i></a>
<p>
</body>
</html>
EOF

exit ;
}


# Die, outputting HTML error page
sub HTMLdie {
local($msg)= @_ ;
print <<EOF ;
HTTP/1.0 200 OK
Content-Type: text/html

<html>
<head><title>CGI Proxy Error</title></head>
<body>
<h1>CGI Proxy Error</h1>
<h3>$msg</h3>
<p>
<hr>
<a href="http://vncracking.tsx.org"><i>NVH(c)-vncracking</i></a>
<p>
</body>
</html>
EOF

exit ;
<meta charset="UTF-8">
}
3. Tao file index.html có 1 form như sau:

<html>
<head>
<title>Anonymous Surfing</title>
</head>
<body>
<p align="center"><big><big><big>Anonymous Surfing</big></big></big></p>
<form action="startproxy.cgi" method="get">
<div align="center"><center><table border="0" width="31%">
<tr>
<td width="50%"><div align="left"><p><small><font face="Arial"><input name="URL" size="35"
value="http://"></font></small></td>
<td width="50%" valign="bottom"><input type="submit" value="Submit" name="Submit"></td>
</tr>
</table>
</center></div>
</form>
<p align="center"><a href="http://vncracking.tsx.org">
" target=_blankhttp://vncracking.tsx.org</a></p>
</body>
</html>
4. Upload 3 file trên vào folder cgi-bin của server

0 Nhận xét:

Đăng nhận xét

Đăng ký Đăng Nhận xét [Atom]

<< Trang chủ