mIRC Home    About    Download    Register    News    Help

Print Thread
Secure DCC File Transfers aka DCC SSEND #240129 27/12/12 08:14 PM
Joined: Dec 2012
Posts: 6
G
gfeg Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Dec 2012
Posts: 6
Would be nice having secure file transfers implemented like for instance kvirc does. It shouldnt be hard since apparently u already have most of the functions and structures already in mirc that would be necessary to make it work.

I wrote a small .mrc wrapper to hack ssl dcc gets into mirc myself, but for obvious reasons, it wouldnt work with outgoing sends but only gets(since you cant socklisten on a port with ssl but connect to one).



For those that want to use my mirc dccl ssl wrapper,
either use the code above or the code on pastebin:
http://pastebin.com/9HARqLB8

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Mirc SSL DCC Gets Script By Sanchez 2012 ;
; passive gets not working since you cant /socklisten via ssl ;
; speed is limited to around 100kb/s give or take due slow mirc sockets ;
; no resume support currently, since its just a PoC ;
; Trigger: DCC SSEND filename ip port filesize ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ctcp ^*:DCC SSEND*:{

; load settings + data
; change your dir.
set %ssldir c:\downloads\
var %filename = $3
var %ip = $longip($4)
var %remoteport = $5
var %filesize = $6
var %win = $+(@,%filename)
var %sn = dcc. $+ %filename

; check user against your trusted dcc user list
var %i = 1
while ($trust(%i)) {
if ($v1 iswm $fulladdress) break
inc %i
}
if ( !$trust(%i) ) {
echo The user $fulladdress was trying to send you %filename $+ , but he doesnt match your trusted dcc user list.
return
}


; check if already running or file complete
if ($sock(%sn)) {
echo Transfer %filename still running. Aborting.
return
}
else if ( $file($+(%ssldir,%filename)).size == %filesize ) {
echo Transfer already complete. Aborting.
return
}

; connect to remote host and pass arguments
/sockopen -e %sn %ip %remoteport
sockmark %sn $+(%filename,$chr(9),$nick,$chr(9),$ctime,$chr(9),%filesize,$chr(9),0)

; open transfer window
if (!$window(%win)) /window %win
else {
/window -c %win
/window %win
}
/aline %win Starting transfer...
haltdef
}
on *:sockclose:dcc.*: {

var %sn = $sockname
var %sm = $sock(%sn).mark
var %filename = $strip($gettok(%sm,1,9),burc)
var %win = $+(@,%filename)
var %nick = $gettok(%sm,2,9)
var %filesize = $gettok(%sm,4,9)
var %size = $gettok(%sm,5,9)


if (%filesize != %size) {
echo DOWNLOAD: %filename from %nick incomplete.
if ($window(%win)) /aline %win %filename from %nick incomplete.
}
}

on *:sockopen:dcc.*:sockwrite -nt $sockname 0
on *:sockread:dcc.*: {

var %sn = $sockname
var %sm = $sock(%sn).mark
var %filename = $strip($gettok(%sm,1,9),burc)
var %nick = $gettok(%sm,2,9)
var %time = $gettok(%sm,3,9)
var %filesize = $gettok(%sm,4,9)
var %win = $+(@,%filename)

var %sockbr = 0
var %size = $gettok(%sm,5,9)
if ($sockerr > 0) return


:nextread
sockread 16384 &x

var %readbytes = $sockbr
inc %size %readbytes

; no new data
if (%readbytes == 0) {

;TODO: send constant acks and check if its gonna be any faster
;if ( %size >= 65536) {
;sockwrite -nt $sockname $base(%deltasize, 10, 16)
;}

/rline %win 1 %filename - %size from %filesize downloaded ( $+ $round($calc( %size * 100 / %filesize),0) $+ %), at $round($calc( %size / (($ctime - %time) * 1000) ),2) kb/s.
return
}
else {
; append data to file
/bwrite %ssldir $+ %filename -1 &x
}

; update current filesize
sockmark $sockname $puttok(%sm,%size,5,9)

; file complete, send ack and have the remote host close the socket
if (%filesize == %size) {
echo DOWNLOAD: %filename from %nick completed after $duration($calc($ctime - %time))
/rline %win 1 %filename - %size from %filesize downloaded (100%), at $round($calc( %size / (($ctime - %time) * 1000) ),2) kb/s.
sockwrite -nt $sockname $base(%size, 10, 16)
}

goto nextread

}


Last edited by gfeg; 27/12/12 08:19 PM.
Re: Secure DCC File Transfers aka DCC SSEND [Re: gfeg] #240148 29/12/12 09:32 PM
Joined: Dec 2012
Posts: 6
G
gfeg Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Dec 2012
Posts: 6
Cute by using older mirc versions like 6.21 instead of the most current 7.27, I get 800kb/s instead of just 70-120kb/s dcc ssl speeds. (Not that I already suspected that, since most functions that i tested in general got dramatically slower moving up from mirc 6 to 7). If anybody wants also resume support drop a message, I will add an updated script, I just didnt want to post more than necessary for the PoC.
PS2 First I tried to wrap dcc gets so they would use mircs dcc gui system, by wrapping dcc ssend calls into dcc send and socklisten on a local port to which mirc would try to connect to, but since i cant change incoming raw ctcp data nor ctcp messages to myself (they wouldnt trigger anything) I decided to make it that way. Apart from that the script works just fine (mirc >= 6.17 + //Echo $sslready )

I however hope this finds its way into the native builds in some way.

Re: Secure DCC File Transfers aka DCC SSEND [Re: gfeg] #240150 29/12/12 10:28 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Originally Posted By: gfeg
Cute by using older mirc versions like 6.21 instead of the most current 7.27, I get 800kb/s instead of just 70-120kb/s dcc ssl speeds. (Not that I already suspected that, since most functions that i tested in general got dramatically slower moving up from mirc 6 to 7).


At first read, this sounds a little bogus to me. First off, the slowdown on mIRC functions from 6-7 is mostly in string functions; you're barely using any, as the bulk of your data processing is going through unfiltered binary variables. Secondly, the benchmarks, while significant, only show a ~2x slowdown in mIRC when using string functions. You're showing over 4x of a slowdown, which leads me to believe your script is not the bottleneck here.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Secure DCC File Transfers aka DCC SSEND [Re: argv0] #240151 29/12/12 10:53 PM
Joined: Dec 2012
Posts: 6
G
gfeg Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Dec 2012
Posts: 6
Over 4 times the slowdown?? I get 800kb instead of 100kbs. Thats like 8x times slower. smile
It's not just that script, I have dozens of other scripts which use various not just string functions which show the same effect. Some scripted functions that I use take up to 30 times as long as on 6.21. Thats why i dont use mirc 7.x wherever I need scripting performance in combination with mirc. Im very well aware of the unicode change, and yet the speed difference is much higher.
I profiled most of my time intensive functions, and e.g. having either 30secs to finish up a task or 1s is def noticeable, but that aint the topic here anyway.
All that matters for this particular posting here is, that I have 800kb with mirc 7.27 on the exact same system while on on 6.21 I get 100kb/s~ by using ssl dcc transfers.
Same at my mates computer, but either way if khaleb should add it natively, that wouldnt matter, since unwrapped native calls would be much more efficient. Which I Hope. At the moment I can only receive ssl transfers via mirc from other sources.
Technically it would be also possible to wrap passive dcc sends..., to have also outgoing sends running, that wouldnt allow mirc to mirc sends but at least mirc to !mirc.

Last edited by gfeg; 29/12/12 11:05 PM. Reason: typo: 6.17 -> 6.21
Re: Secure DCC File Transfers aka DCC SSEND [Re: gfeg] #240154 30/12/12 01:12 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Originally Posted By: gfeg
All that matters for this particular posting here is, that I have [100]kb with mirc 7.27 on the exact same system while on on 6.21 I get [800]kb/s~ by using ssl dcc transfers.


No, that is not what matters. What matters is that mIRC doesn't support SDCC and SSL based /socklisten, not that your script is allegedly slower in 7.x. The claim that it is slower, as I mentioned, is subject to some scrutiny given the numbers you are claiming. I'm guessing something else is at play here. I would test this script but I can't even get it to work with kvirc as the sender, and I don't know any other IRC clients that support SSEND.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Secure DCC File Transfers aka DCC SSEND [Re: argv0] #240156 30/12/12 02:27 AM
Joined: Dec 2012
Posts: 6
G
gfeg Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Dec 2012
Posts: 6
kvirc has a bug in their sendack() routine when its on ssl, it will be fixed sooner or later. If they dont fix it some time, I 'll help them. There are also private irssi scripts floating around to make it work with ssl. Anyhow I have a custom irc client that supports ssl, I practically have the same dcc transfer speeds with ssl as without it. When i use mirc with ssl wrapping im far away from whats possible, but at least using mirc 6.21 allows me to get speeds of almost 1mb/s. Im no rookie, im software developer myself (not just MSL lol).
I let a handful of other people test the script on 7.x and 6.x with simply the same verdict.
If your on IRC, hook me up and I'll come by and give u some working ssl sends if u want.
I tested 2 threads with ssl on 6.21 from the same user which didnt cause any speedloss on the first get. the 2nd get had the same speed as the first one, 800kb/s~.

Re: Secure DCC File Transfers aka DCC SSEND [Re: gfeg] #241063 18/03/13 01:18 AM
Joined: Dec 2012
Posts: 6
G
gfeg Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Dec 2012
Posts: 6
I fixed up dcc ssl sends on kvirc as promised earlier(fullspeed), since apparently waiting for khaleb to add dcc ssl to mirc doesnt seem to happen nor that extended proxy interface that I proposed that other irc clients already have. :S

regards
sanchez

Re: Secure DCC File Transfers aka DCC SSEND [Re: gfeg] #252469 15/04/15 01:55 AM
Joined: Apr 2015
Posts: 1
S
scubadunc Offline
Mostly harmless
Offline
Mostly harmless
S
Joined: Apr 2015
Posts: 1
I'd been keen to get the updated resume script if you have it available?

Originally Posted By: gfeg
Cute by using older mirc versions like 6.21 instead of the most current 7.27, I get 800kb/s instead of just 70-120kb/s dcc ssl speeds. (Not that I already suspected that, since most functions that i tested in general got dramatically slower moving up from mirc 6 to 7). If anybody wants also resume support drop a message, I will add an updated script, I just didnt want to post more than necessary for the PoC.
PS2 First I tried to wrap dcc gets so they would use mircs dcc gui system, by wrapping dcc ssend calls into dcc send and socklisten on a local port to which mirc would try to connect to, but since i cant change incoming raw ctcp data nor ctcp messages to myself (they wouldnt trigger anything) I decided to make it that way. Apart from that the script works just fine (mirc >= 6.17 + //Echo $sslready )

I however hope this finds its way into the native builds in some way.

Last edited by scubadunc; 15/04/15 03:59 AM.