1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
From: Sebastien Delafond <sdelafond@gmx.net>
Subject: Change shebang to /usr/bin/perl
Ask for command-line parameters
Remove the "accept"part of the listening test
--- SOCKS-0.03.orig/example 1998-05-19 04:49:07.000000000 -0700
+++ SOCKS-0.03/example 2004-09-20 11:29:27.000000000 -0700
@@ -1,19 +1,32 @@
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
use strict;
use Net::SOCKS;
-print "Attempting to connect to 192.168.1.3 at port 79 using the socks\n";
-print "server at 192.168.1.3 port 1080\n";
+sub usage {
+ print "Usage:\n";
+ print "\texample <socks_addr> <socks_port> <target_addr> <target_port>\n";
+ print "to connect to <target_addr>:<target_port> through SOCKS5 at <socks_addr>:<socks_port>\n";
+}
+
+if ($#ARGV != 3) {
+ &usage();
+ exit(1);
+}
+
+my ($socks_addr, $socks_port, $target_addr, $target_port) = @ARGV;
+
+print "Attempting to connect to $target_addr at port $target_port using the socks\n";
+print "server at $socks_addr port $socks_port\n";
-my $sock = new Net::SOCKS(socks_addr => '192.168.1.3',
- socks_port => 1080,
+my $sock = new Net::SOCKS(socks_addr => $socks_addr,
+ socks_port => $socks_port,
#user_id => 'the_user',
#user_password => 'the_password',
#force_nonanonymous => 1,
protocol_version => 5);
-my $f= $sock->connect(peer_addr => '192.168.1.3', peer_port => 79);
+my $f= $sock->connect(peer_addr => $target_addr, peer_port => $target_port);
print "connect status: ",
Net::SOCKS::status_message($sock->param('status_num')), "\n";
@@ -23,29 +36,38 @@
$sock->close();
}
-print "Attempting to listen() using the server at 192.168.1.3 port 1080\n";
+print "Attempting to listen() using the server at $socks_addr port $socks_port\n";
-$sock = new Net::SOCKS(socks_addr => '192.168.1.3',
- socks_port => 1080,
+$sock = new Net::SOCKS(socks_addr => $socks_addr,
+ socks_port => $socks_port,
#user_id => 'the_user',
#user_password => 'the_password',
#force_nonanonymous => 1,
protocol_version => 5);
-my ($ip, $ip_dot_dec, $port) = $sock->bind(peer_addr => "192.168.1.3",
- peer_port => 9999);
+# We expect a connection from $target_addr:9999
+# This is just for the sake of testing that the SOCKS proxy lets us
+# listen: we of course won't initiate a connection from
+# $target_addr:9999 (and in the majoirty of cases, we simply *can not*,
+# since $target_addr is likely to be remote)
+# --Seb
+my ($ip, $ip_dot_dec, $port) = $sock->bind(peer_addr => $target_addr,
+ peer_port => 9999);
print "bind status: ",
Net::SOCKS::status_message($sock->param('status_num')), "\n";
if ($sock->param('status_num') == SOCKS_OKAY) {
print "Listening at the IP of ", $ip_dot_dec, " at port ", $port, "\n";
- $f= $sock->accept();
-}
-print "accept status: ",
- Net::SOCKS::status_message($sock->param('status_num')), "\n";
-if ($sock->param('status_num') == SOCKS_OKAY) {
- while (<$f>) { print }
+# Following is commented out, according to comment above.
+# $f= $sock->accept();
+#}
+#print "accept status: ",
+# Net::SOCKS::status_message($sock->param('status_num')), "\n";
+#
+#if ($sock->param('status_num') == SOCKS_OKAY) {
+# while (<$f>) { print }
+#}
}
$sock->close();
|