IRC Tunnel v2 — File Browser
IRCTunnelv2v2.0 / IRCTunnelv2v2.0 / IRCtunnel02.mrc
IRCtunnel02.mrc — 9.75 KB — Download this file
;
; IRC tunnel v2.2008061201
; (tunnel-proxy-bouncer for IRC)
; ------------------------------
; by : xtrapezoid
; using : mEditor 0.3 by RG
; mIRC 6.31 (can be loaded on version 6 or higher)
; email : xtrapezoid@gmail.com
;
; Loading this script enables you be a host PC. Anyone who is allowed to connect
; to your specified ports may connect to any IRC server they desire using your
; IP address or hostname.
;
; This is a rewrite of my test version way back 2004. I wrote this script when
; I had a difficulty connecting to a network when my ISP was blocked due to other
; users who had an abuse on their connections. I emailed my test version to a
; friend and made him a host and I did successfully connected to that network.
;
; I found my test version when I browsed my old files and decided to do a
; rewrite and some bug fixes of it and this is the new rewriten version.
;
; ---------------------------
; What's new to this version?
; ---------------------------
; 1. QUIT command on AUTH
; 2. xconf
; 3. xadduser/xdeluser/xuserlist
; 4. ON LOAD/UNLOAD
; 5. ON EXIT
; 6. Bug fixes on:
; > messages if port is not free
; > duplicate connection IDs
; > clearing values on disconnected IDs
; > server is invalid
; 7. Lots of ;comments :)
;
; -------------------
; How to setup Server
; -------------------
; 1. Copy script to $mircdir (your default mIRC directory)
; 2. Load script to the Remote -> /load -rs IRCtunnel02.mrc
; 3. Set username and password -> /xadduser <username> <password>
; /xadduser mylogin mypassword
; 4. Open listen ports
; a. using default ports -> /modOPENd
; b. using a custom port -> /modOPENp <port>
;
; NOTE: If on a firewall, allow incoming connections to the ports set for
; listening. If connections needs routing, route connections to serving
; computer and to its specific ports. If you're not the Net Admin, then
; ask him/her for assistance on routing incoming connections.
;
; ----------------------------------
; How Clients connect to your server
; ----------------------------------
; 1. Connect to the server -> /server <host.ip> 9988
; 2. When prompted for a login... -> /connect <username> <password> <irc.server>
; $1=color $2=message
alias modECHO {
if (!$window(@tunnel)) { window -e @tunnel }
echo -ct $1 @tunnel $2-
}
; set a configuration value
; $1=variable $2=value
alias xconf { set %conf. [ $+ [ $1 ] ] $2- }
; adds a user
; $1=username $2=password
alias xadduser {
if ($2) {
xconf $+(user.,$1) $2
modECHO ctcp $+(,$1,) has been added as a user.
}
else { modECHO ctcp Insufficient parameters! User not added. }
}
; deletes a user
; $1=username
alias xdeluser {
if ($1) {
if (%conf.user. [ $+ [ $1 ] ]) {
unset %conf.user. [ $+ [ $1 ] ]
modECHO ctcp $+(,$1,) has been deleted from the userlist.
}
else { modECHO ctcp $+(,$1,) does not exist in the userlist. }
}
else { modECHO ctcp Insufficient parameters! No user deleted. }
}
; displays the userlist
alias xuserlist {
var %x $var(%conf.user.*,0), %y 1
modECHO ctcp *** USER LIST ***
while (%y <= %x) {
modECHO own $+([,%y,]) $gettok($var(%conf.user.*,%y),3,46)
inc %y
}
modECHO ctcp *** END USER LIST ***
}
; sets default settings
; NOTE: you may edit the "user" part for security. "default" and "login" are
; users initially intended for testing and example purposes.
alias modDEFA {
xconf setting $true
; listen ports
xconf ports 9988,9989,9990
; hostname to echo to client
xconf host irc.tunnel.net
; idle timeout
xconf idlelog 90
; users: set as %conf.user.[username] = <password>
xconf user.default password
xconf user.login password
}
on *:start: {
; calls modDEFA to set default settings if there is no existing setting found
if (!%conf.setting) { modDEFA }
modECHO ctcp IRC Tunnel v2
modECHO high -
modECHO ctcp To start hosting type either:
modECHO high -> to open default ports: /modOPENd
modECHO high -> to open custom ports : /modOPENp <port>
modECHO high -
modECHO ctcp To add/delete users:
modECHO high -> to add: /xadduser <user> <password>
modECHO high -> to del: /xdeluser <user>
}
; enable default ports for listening
alias modOPENd {
var %n $numtok(%conf.ports,44)
while (%n) {
var %p $gettok(%conf.ports,%n,44)
if ($portfree(%p)) {
socklisten $+(tun,%p) %p
modECHO info * You are now hosting on port %p
}
else { modECHO ctcp * Could not use port $+(%p,!) You may specify another port. }
dec %n
}
}
; enable listening to a custom port
; $1=port
alias modOPENp {
if ($portfree($1)) {
socklisten $+(tun,$1) $1
modECHO info * You are now hosting on port $1
}
else { modECHO ctcp * Could not use port $+($1,!) You may specify another port. }
}
; sends SNOTICE to client
; $1=client $2=message
alias modSNOTICE { sockwrite -tn $1 $+(:,%conf.host) NOTICE * $+(:,$2-) }
; closes a connection
; $1=socket $2=message
alias modKILLc {
modSNOTICE $1- | sockclose $1 | var %r $right($1,-3)
unset %regn. [ $+ [ $+(cli,%r) ] ] %regu. [ $+ [ $+(cli,%r) ] ] %conf.path. [ $+ [ %r ] ]
}
; disconnects an idle attempt connection
; $1=client
alias modKILLi {
if ($sock($1)) {
modECHO info * $sock($1).ip has timed out.
modKILLc $1 Connection timed out!
}
}
; your primary host listen event
on *:socklisten:tun*: {
var %r $r(1000,9999), %c $+(cli,%r)
; avoid duplicate connection id
while ($sock(%c)) || (%conf.path. [ $+ [ %r ] ]) {
%r = $r(1000,9999)
%c = $+(cli,%r)
}
xconf $+(path.,%r) $true
sockaccept %c
modECHO own * $sock(%c).ip is trying to connect
modSNOTICE %c Welcome to my Tunnel $+(,$sock(%c).ip,!)
modSNOTICE %c -
modSNOTICE %c Syntax : /CONNECT <username> <password> <irc.server[:port]>
modSNOTICE %c Example: /CONNECT mylogin mypassword us.undernet.org
modSNOTICE %c -
modSNOTICE %c ***NOTE: By default, you are directed to port 6667 if port is not specified
modSNOTICE %c -
.timerkillidle $+ %c 1 %conf.idlelog modKILLi %c
}
; read commands from connecting client
; %regn = temporarily holds the NICK info of the client
; %regu = temporarily holds the USER info of the client
on *:sockread:cli*: {
if ($sockerr) { return } | sockread %conf.clis
if (!$sockbr) { return }
tokenize 32 %conf.clis
if ($1 == CONNECT) && ($4) {
if (%regn. [ $+ [ $sockname ] ] && %regu. [ $+ [ $sockname ] ]) {
; check if user and password matches
if ($3 === %conf.user. [ $+ [ $2 ] ]) {
modECHO info * $sock($sockname).ip ACCOUNT: $+(,$2,) ID: $+(,$right($sockname,-3),)
var %v $gettok($4,1,58)
; i use the path to store the irc server
xconf $+(path.,$right($sockname,-3)) %v
modSNOTICE $sockname Trying to connect you to $+(,%v,...)
; open a path for irc
sockopen $+(irc,$right($sockname,-3)) %v $iif((: isin $3) && ($gettok($4,2,58) isnum),$v1,6667)
; make a permanent path of client
sockrename $sockname $+(usr,$right($sockname,-3))
}
else { modKILLc $sockname *** AUTH KILL: Invalid Username or Password! }
}
else { modSNOTICE $sockname Please set NICK and USER information before /CONNECT }
}
elseif ($1 == NICK) {
if ($2) { %regn. [ $+ [ $sockname ] ] = $1- }
else { modSNOTICE $sockname NICK not enough parameters. }
}
elseif ($1 == USER) {
if ($5) { %regu. [ $+ [ $sockname ] ] = $1- }
else { modSNOTICE $sockname USER not enough parameters. }
}
elseif ($1 == QUIT) {
modKILLc $sockname *** USER QUIT
}
else { modSNOTICE $sockname AUTH ERROR: Invalid parameters! Please try again. }
}
; if IRC server does not exist...
on *:sockopen:irc*: {
if ($sockerr) {
var %s $+(usr,$right($sockname,-3))
if ($sock(%s)) {
modECHO info * INVALID SERVER: $sock(%s).ip
modKILLc %s *** AUTH ERROR: Could not resolve or connect to $+(,%conf.path. [ $+ [ $right($sockname,-3) ] ],.) It might be a non-existent server.
if ($sock($sockname)) { sockclose $sockname }
}
}
}
; path of client
on *:sockread:usr*: {
if ($sockerr) { return } | sockread %conf.usrs
if (!$sockbr) { return }
sockwrite -n $+(irc,$right($sockname,-3)) %conf.usrs
}
; path of irc
on *:sockread:irc*: {
if ($sockerr) { return } | sockread %conf.ircs
if (!$sockbr) { return }
var %t $+(cli,$right($sockname,-3))
; send NICK and USER info for IRC AUTH
if (%regn. [ $+ [ %t ] ] && %regu. [ $+ [ %t ] ]) {
sockwrite -tn $sockname %regn. [ $+ [ %t ] ]
sockwrite -tn $sockname %regu. [ $+ [ %t ] ]
unset %regn. [ $+ [ %t ] ] %regu. [ $+ [ %t ] ]
}
sockwrite -n $+(usr,$right($sockname,-3)) %conf.ircs
}
; if sockets has closed themselves
on *:sockclose:irc*: { modCLOSEr usr $right($sockname,-3) }
on *:sockclose:usr*: { modCLOSEr irc $right($sockname,-3) }
on *:sockclose:cli*: { modCLOSEr cli $right($sockname,-3) }
; $1=socket
alias modCLOSEr {
if ($1 != cli) { sockclose $+($1,$2) }
modECHO info * $+($1,$2) closed.
unset %conf.path. [ $+ [ $2 ] ]
}
; when the script is loaded...
on *:load: {
if ($version < 6) {
echo -act ctcp * This script only runs on mIRC version 6 and higher
echo -act ctcp * Unloading script...
unload -rs $script
}
else { echo -act info * $nopath($script) has been successfully installed! }
}
; when the script is unloaded...
on *:unload: {
echo -act ctcp * Clearing all variables used...
unset %conf.* %regn.* %regu.*
echo -act ctcp * $nopath($script) has been uninstalled!
}
; when mIRC exits
on *:exit: { unset %regn.* %regu.* }
; end