### ### vim:ts=2 ai si sw=2 sta sm: ### ### A simple httpd module ### ^assign httpd.version $Id: httpd,v 1.20 2004/09/23 16:26:49 sec Exp sec $ alias close { dcc close raw_listen $0 ^on dcc_raw -"% % N $0" } alias httpd { ^assign listen.pnum $listen($0) ^on ^dcc_raw "% % N $0" httpd.win $$0- echo *** Listening on port $listen.pnum ... Finish with /close $0 } alias httpd.win { # echo fd $0 | connect from host $1 to port $3. ^assign httpd.$0.host $1 #state = connected assign http.$0 connect # Incoming Text ^on ^dcc_raw "$0 $1 D *" { ^assign -httpd.line if ([$right(1 $3-)] == [ ]){ ^assign httpd.line $left($rindex( $3-) $3-) }{ ^assign httpd.line $3- } # echo fd $0 < $httpd.line incoming.$http[$0] $0 $httpd.line } # Connection closed by other side. ^on ^dcc_raw "$0 $1 C" httpd.off $$0- # To send something there. ^alias httpd.$0 dcc raw $0 $1 $$0- #\;echo fd $0 > $$0- #close the connection ^alias httpd.off.$0 ^dcc close raw $0\;httpd.off $0 $1\;^alias -httpd.off.$0 } alias httpd.off { echo fd $0 | close. ^alias -httpd.$0 ^on dcc_raw -"$0 $1 C" ^on dcc_raw -"$0 $1 D *" ^assign -http.$0 } alias incoming.connect { ^assign httpd.$0.proto $toupper($1) ^assign -httpd.$0.url ^assign -httpd.$0.auth ^assign -httpd.$0.authraw ^assign httpd.$0.url $left($index(? $2) $2) ^assign -httpd.$0.cgi ^assign httpd.$0.cgi $mid($index(? /$2) 99 $2) if ([$left(2 $httpd[$0.cgi])]==[q=]){ ^assign httpd.$0.cgi $httpdecode($mid(2 99 $httpd[$0.cgi])) } ^assign -httpd.$0.ver ^assign httpd.$0.ver $toupper($3) echo fd $0 | \[$httpd[$0.host]\] $httpd[$0.proto] $httpd[$0.url] $httpd[$0.ver] \(cgi: $httpd[$0.cgi]\) ^assign http.$0 get if ([$httpd[$0.proto]]==[CONNECT]){ ^assign http.$0 connect timer 0 httpd.off.$0 } } alias incoming.get { if ([$1-] == []){ # echo fd $0 | send: $httpd.url ^assign http.$0 send if ([$httpd[$0.host]]==[62.190.92.245]) { echo fd $0 | denied access. httpd.deny $0 }{ if ([$httpd.get[$encode($httpd[$0.url])]]==[1]) { if ([$httpd.open[$encode($httpd[$0.url])]]==[auth]) { if ( rmatch($httpd[$0.auth] $httpd.auth[$encode($httpd[$0.url])])) { echo fd $0 | Authenticated. httpd.head.ok $0 ^assign auth 1 httpd.get.$httpd[$0.url] $0 $httpd[$0.cgi] }{ echo fd $0 | Auth failed. httpd.$0 HTTP/1.0 401 Auth required httpd.$0 WWW-Authenticate: Basic realm="CountEr" httpd.head.rest $0 httpd.$0 Bob says: your password is invalid, enter another. httpd.$0 $httpd.err[$encode($httpd[$0.url])] } }{ ^assign auth 0 if ([$httpd.open[$encode($httpd[$0.url])]]!=[noopen]) { httpd.head.ok $0 } # if ([$httpd[$0.proto]]==[HEAD]){ # timer 0 httpd.off.$0 # }{ httpd.get.$httpd[$0.url] $0 $httpd[$0.cgi] # } } if ([$httpd.close[$encode($httpd[$0.url])]]==[noclose]) { ; }{ if ([$httpd.close[$encode($httpd[$0.url])]]==[form]) { on ^exec_exit "$httpd[$0.url] *" httpd.formoff $0 $httpd[$0.url] }{ timer 0 httpd.off.$0 }} }{ httpd.404 $0 } } }{ # echo someone said(get) $1- on fd $0 if ([$1] == [Referer:]){ echo fd $0 | $1- } if ([$1] == [Authorization:]){ if ([$2] == [Basic]){ if ([$httpd.user.a[$encode($3)]]) { ^assign httpd.$0.auth $httpd.user.a[$encode($3)] ^assign httpd.$0.authraw $3 echo fd $0 | PreAuth as $httpd[$0.auth] }{ ^echo fd $0 | PreAuth failed for $3- } }{ echo fd $0 | PreAuth "Huh??" $1- } } } } alias incoming.send { echo fd $0 | inappropriate Text received $1- } alias httpd.head.common { httpd.$0 HTTP/1.0 $1- httpd.head.rest $0 } alias httpd.head.rest { httpd.$0 Date: $httptime($time()) httpd.$0 Server: ircII/$V, httpd/$word(2 $httpd.version) httpd.$0 Connection: close if ([$httpd.ctype[$encode($httpd[$0.url])]]) { httpd.$0 Content-Type: $httpd.ctype[$encode($httpd[$0.url])] }{ httpd.$0 Content-Type: text/html\; charset=iso-8859-1 } if ([$httpd.lm[$encode($httpd[$0.url])]]) { httpd.$0 Last-Modified: $httptime($httpd.lm[$encode($httpd[$0.url])]) } httpd.$0 } alias httptime { @ function_return = strftime($0 %a, %d %b %Y %H:%M:%S %Z) } alias httpd.head.ok { httpd.head.common $0 200 OK # echo fd $0 | head sent. } alias httpd.404 { httpd.head.common $0 404 NACK httpd.$0 The Page you requested \($httpd[$0.url]\) is not there. httpd.end $0 timer 0 httpd.off.$0 } alias httpd.deny { httpd.head.common $0 404 DENY httpd.$0 Hi $httpd[$0.host],

httpd.$0 You are using some sort of automatism which I don't like.
httpd.$0 I am a reasonable guy. We can surely work out an easier way
httpd.$0 for both of us to get you the data you want.

httpd.$0 In any case, mail me to regain access.

httpd.$0 -- Sec timer 0 httpd.off.$0 } alias httpd.title { httpd.$0 httpd.$0 $1- httpd.$0 httpd.$0 httpd.$0 httpd.$0

} alias httpd.title3nc { httpd.$0 httpd.$0 $1- httpd.$0 httpd.$0 httpd.$0 } alias httpd.title4 { httpd.$0 httpd.$0 $1- httpd.$0 httpd.$0 httpd.$0 httpd.$0
} alias httpd.title4l { httpd.$0 httpd.$0 $1- httpd.$0 httpd.$0 httpd.$0 httpd.$0
} alias httpd.title.rss { httpd.$0 httpd.$0 httpd.$0 httpd.$0 $1-http://utfe.net/ httpd.$0 dewebsec@42.org } alias httpd.end { httpd.$0

$N[$line.vers], by Stefan `Sec` Zehl
} eval assign httpd.get.$encode(/) 1 alias httpd.get./ { httpd.title4 $0 The $line.chan-$N httpd.$0 Hi user from $httpd[$0.host], this is the web-interface of the $N\.

httpd.$0 Here you can choose between:
httpd.$0 httpd.$0
httpd.$0 Information about $line.chan,
    httpd.$0
  • Check when I last saw a specific person httpd.$0
  • List the URLs mentioned. httpd.$0
  • See the current and past topics. httpd.$0
  • Activity graph by Hour. httpd.$0

and about the local IRC network:

Some local databases:
    httpd.$0
  • Expand a top level domain. httpd.$0
  • Expand an acronym. httpd.$0
  • Expand a german KFZ. httpd.$0
  • Check the AVON (german telephone prefix) Database httpd.$0
  • Spell a word or phrase httpd.$0
  • Translate a word from or to morse code httpd.$0
  • Generate a senseless mangement statement. httpd.$0
  • Lookup an Ethernet OUI (ethercode). httpd.$0
  • Lookup a german BLZ (postcode). httpd.$0

httpd.$0 Please remember that this is still an IRC bot, so all this information can also be accessed via the ctcp interface.
httpd.$0 The ctcp-interface also contains gateways to the following data sources:

httpd.$0 If you want some background information about all this, look here. httpd.end $0 } eval assign httpd.get.$encode(/seen) 1 alias httpd.get./seen { httpd.title $0 Seen if ([$1]) { ^assign -account ^assign account $redir[$encode($1)] if ( [$account] != [$encode($1)]) { httpd.$0 $1 is aliased to $decode($account)
} if ([$seen[$account]]) { httpd.$0 I last saw $decode($account) as $word(2 $seen[$account]) at $stime($word(0 $seen[$account]))\.
@ line.tdiff = time() - word(0 $seen[$account]) httpd.$0 This was$hms.do($line.tdiff) ago. }{ httpd.$0 Sorry, I didn't see $1 at all.

Nb. This query is case-sensitive. } }{ httpd.$0 Please enter the Nickname to look up } httpd.end $0 } eval assign httpd.get.$encode(/tla) 1 alias httpd.get./tla { httpd.title $0 TLA-Lookup if ([$1]) { if ([$tla[$1]]) { httpd.$0 $1 expands to $tla[$1] }{ httpd.$0 Sorry, I don't know what $1 means. } }{ httpd.$0 Please enter the TLA to look up } httpd.end $0 } eval assign httpd.get.$encode(/country) 1 alias httpd.get./country { httpd.title $0 Country-Lookup if ([$1]) { ^assign DOM $strip(. $1) if ([$country[$dom]]) { httpd.$0 .$dom is $country[$dom] }{ httpd.$0 Sorry, I don't know .$dom } ^assign -DOM }{ httpd.$0 Please enter the Country to look up } httpd.end $0 } eval assign httpd.get.$encode(/kfz) 1 alias httpd.get./kfz { httpd.title $0 KFZ-Lookup if ([$1]) { ^assign DOM $toupper($strip(.- $1)) if ([$kfz[$dom]]) { httpd.$0 $dom is $kfz[$dom] }{ httpd.$0 Sorry, I don't know $dom } ^assign -DOM }{ httpd.$0 Please enter the KFZ-City-Code to look up } httpd.end $0 } eval assign httpd.get.$encode(/morse) 1 alias httpd.get./morse { httpd.title $0 Morse translation if ([$1]) { httpd.$0 $1-
translates to
$morse($httpmorse($1-)) }{ httpd.$0 Please enter the Plaintext, or morse characters to convert } httpd.end $0 } alias httpd.form { httpd.$0

httpd.$0 httpd.$0 httpd.$0
httpd.end $0 timer 0 httpd.off.$0 } alias httpd.formoff { httpd.$0 $_.post httpd.form $0 $1 on exec_exit -"$1 *" } eval assign httpd.get.$encode(/avon) 1 alias httpd.get./avon { httpd.title $0 "AVON: Amtliches Verzeichniss der OrtsNetzkennzahlen" if ([$1]==[]) { ^assign _.post Search for a number prefix: ^exec -name /avon true }{ httpd.$0 AVON-1999 resolves this to:
		^assign _.post 
Do another Search: ^exec -name /avon -msg /httpd.$0 /home/sec/.irc/bin/avon '$strip(<>;`'" $1)' } } eval assign httpd.close.$encode(/avon) form eval assign httpd.get.$encode(/oui) 1 alias httpd.get./oui { httpd.title4l $0 "Ethernet OUIs" if ([$1]==[]) { httpd.$0 The OUI (Ethernet MAC / Ethercode) Database
^assign _.post Search for Name or 3-byte code: ^exec -name /oui true }{ httpd.$0 The OUI Database contains:
		^assign _.post 
Do another Search: ^exec -name /oui -msg /httpd.$0 /home/sec/.irc/bin/oui -html '$strip(<>;`'" $1)' } } eval assign httpd.close.$encode(/oui) form eval assign httpd.get.$encode(/blz) 1 alias httpd.get./blz { httpd.title $0 "Bankleitzahlen, Deutschland" if ([$1]==[]) { ^assign _.post Search for Name or 8-digit code:
Try: "Dresdner Bank, muenchen" or "70010080"
^exec -name /blz true }{ httpd.$0 The BLZ Database contains:
		^assign _.post 
Do another Search: ^exec -name /blz -msg /httpd.$0 /home/sec/.irc/bin/blz -http '$strip(<>;`'" $1-)' } } eval assign httpd.close.$encode(/blz) form eval assign httpd.get.$encode(/spell) 1 alias httpd.get./spell { httpd.title $0 Spell a word if ([$1]) { httpd.$0 $1-
is spelled
$spell($1-) }{ httpd.$0 Please enter the word or phrase you want to be spelled } httpd.end $0 } eval assign httpd.get.$encode(/motd) 1 alias httpd.get./motd { httpd.title $0 My version History... ^assign _.motd Start httpd.$0
	while ( [$_.motd] != [$line.vers] ){
	    ^assign _.motd $ver[$encode($_.motd)][next]
	    httpd.$0 $fix(HTML $ver[$encode($_.motd)][txt])
	}
	httpd.$0 
httpd.end $0 } eval assign httpd.get.$encode(/hrstat) 1 alias httpd.get./hrstat { httpd.title $0 Hourly overview httpd.$0 Lines said per Hour on $line.chan:
httpd.$0 httpd.$0 foreach hrlines ii { @ _.col = [#000000] if (ii == hr){@ _.col = [#0000ff]} httpd.$0 }{ httpd.$0
TimeLines
$ii:00 - $ii:59$hrlines[$ii] @ _.col = [#00ff00] @ _.val = hrlines[$ii] * 2 if (hrlines[$ii] > 15){@ _.col = [#ffff00]} if (hrlines[$ii] > 55){@ _.col = [#ff0000]} if (hrlines[$ii] > 0){ httpd.$0
 \; \;
 \;
} } httpd.$0 httpd.$0 Busiest Hour so far was $hrlinesmax.d with $hrlinesmax Lines. httpd.end $0 } eval assign httpd.get.$encode(/bs) 1 alias httpd.get./bs { httpd.title $0 Management directives... httpd.$0 Here's a list of 10 phrases, pick any one you like.
httpd.$0
	exec -name bs -msg /httpd.$0 /home/sec/.irc/bin/bullshit 10
	alias bs.off {
	    httpd.$0 
httpd.end $0 timer 0 httpd.off.$0 on exec_exit -"bs *" } on ^exec_exit "bs *" bs.off $0 } eval assign httpd.close.$encode(/bs) noclose # oder auch /BNet-Map eval assign httpd.get.$encode(/map) 1 alias httpd.get./map { httpd.title $0 BNet-Map httpd.$0

Map of Blafasel-Net (BNet)

on ^005 "*" httpd.$0 $$1- on ^007 "*" map.off $0 alias map.off { on 005 -* on 007 -* on 251 -* on 252 -* on 253 -* on 254 -* on 255 -* httpd.$0 httpd.end $0 timer 0 httpd.off.$0 } on ^251 * httpd.$0 $$1-
on ^252 * httpd.$0 $$1-
on ^253 * httpd.$0 $$1-
on ^254 * httpd.$0 $$1-
on ^255 * httpd.$0

	lusers
	quote map
}
eval assign httpd.close.$encode(/map) noclose

eval assign httpd.get.$encode(/list) 1
alias httpd.get./list {
	httpd.title $0 Channel-List
	if ([$1]) {
#		httpd.$0 

Channel #$1

# httpd.$0 on ^raw_irc "% 352 % *" map.line $0 $$3- on ^324 "*" map.mode $0 $$2- on ^329 "*" map.date $0 $$2- on ^315 "*" map.off $0 assign -tt assign t2 firsttime assign -t3 alias map.mode { assign tt \($1-\) } alias map.date { assign t3 Created: $stime($1-) } alias map.line { if ([$t2]) { httpd.$0

Channel $1 $tt

--$t3
httpd.$0
assign -t2 } if ([$redir[$encode($5)]] == [DMGJGHGOGPHCGFDO]){ httpd.$0 }{ httpd.$0 } } alias map.off { on ^raw_irc -"% 352 % *" on 315 -* on 324 -* on 329 -* httpd.$0
$5$6$2
-utfe
@$3$8-
httpd.end $0 timer 0 httpd.off.$0 } mode #$1 who #$1 }{ httpd.$0

All (visible) Channels

on ^321 "*" httpd.$0 on ^322 "*" map.line $0 $$1- on ^323 "*" map.off $0 alias map.line { ^assign chan $1 if (index( $3-)>-1){ ^httpd.$0 }{ if ([$1]==[*]){ ^assign chan Prv. }{ if ([$1]==[#blafaselX]){ ^assign chan Prv. }{ ^assign chan $1 } } httpd.$0 } } alias map.off { on 321 -* on 322 -* on 323 -* httpd.$0
$$1$$2$$3-
$chan$2$fix(HTML $3-)
httpd.end $0 timer 0 httpd.off.$0 } list >2 } } eval assign httpd.close.$encode(/list) noclose eval assign httpd.get.$encode(/status) 1 alias httpd.get./status { httpd.title4 $0 Checking... httpd.$0 ircII-Version: $V
httpd.$0 Channel: $line.chan
httpd.$0 Server: $S
httpd.$0 Your host: $httpd[$0.host]
@ line.tdiff = time() - max.uptime httpd.$0 Running for $tdiff($line.tdiff)
httpd.$0 User-Database since $stime($line.start)
httpd.$0 CountEr-Version: $line.vers
httpd.$0 HttpD-Version: $httpd.version
@ account = platz.lines.nr[1] httpd.end $0 } eval assign httpd.get.$encode(/info) 1 alias httpd.get./info { httpd.title $0 What am I? httpd.$0 I am the CountEr.

I have been written by Sec. httpd.$0 I'm a small utility-bot originally written Oct 97 to keep some statistics on our Channel. httpd.$0 I am entirely written in ircIIscript, the native language of ircII an open source irc-client (and yes, this includes this httpd server). httpd.$0 This has some advantages, as it makes almost everything easily runtime-modifyable so upgrades and development can be done without restarting me. httpd.$0
httpd.$0 As every usual bot, I can be accessed via /ctcp from inside irc. httpd.$0 You are now using the http interface which only gives access to a restricted set of features. httpd.$0
The current source ist here as is the httpd module and the urlcatcher module (unfortunately without documentation). httpd.$0
[Back to the main menu] httpd.end $0 } alias httpdecode { @ rep = 0 @ repe = rindex($right(1 $0) q$0) ^assign -fr while (rep < [$repe]) { @ c = mid($rep 1 $0) if ([$c] == [+]){ @ fr = fr ## [ ] }{ if ([$c] == [%]){ @ rep = rep + 1 @ fr = fr ## hextochar[$mid($rep 2 $0)] @ rep = rep + 1 }{ @ fr = fr ## [$c] } } # echo $rep: $c @ rep = rep + 1 } ^assign -rep ^assign -repe @ function_return = fr } assign hextochar.3a : assign hextochar.2c , eval assign httpd.get.$encode(/sec) 1 eval assign httpd.open.$encode(/sec) auth eval assign httpd.auth.$encode(/sec) % alias httpd.get./sec { httpd.title $0 Auth test... httpd.$0 If you can read this, you're successfully authenticated

httpd.$0 I think of you as $httpd[$0.auth].

httpd.$0 To log out, you may use this link.

httpd.$0 /url-a should now recognice you. httpd.end $0 } eval assign httpd.get.$encode(/no) 1 eval assign httpd.open.$encode(/no) auth eval assign -httpd.auth.$encode(/no) alias httpd.get./no { httpd.title $0 Checking... httpd.$0 If you can read this, you found a bug.

httpd.$0 I think of you as $httpd[$0.auth]. httpd.end $0 } alias httpd.clearuser { foreach httpd.user.u jj { ^assign -httpd.user.u.$jj } foreach httpd.user.a jj { ^assign -httpd.user.a.$jj } } alias httpd.useradd { if ([httpd.user.u[$encode($0)]]) { # echo $0 was already assigned, deleted him... ^assign -httpd.user.a.$encode($httpd.user.u[$encode($0)]) } ^assign httpd.user.u.$encode($0) $1 ^assign httpd.user.a.$encode($1) $0 } #httpd.clearuser #httpd.useradd Sec c2VjOnNlYw== eval assign httpd.get.$encode(/connect) 1 alias httpd.get./connect { httpd.title $0 Reconnect httpd.$0

Triggered

timer 5 server irc } # The fix function. See modules below. alias fix { ^assign -str ^assign str $1- ^assign -out @ pos = index($fix[$0] $str) while ( pos > -1 ) { @ char = mid($pos 1 $str) @ out = out ## left($pos $str-) ## fix[$0]($char) @ pos = pos + 1 @ str = mid($pos 999 $str) @ pos = index($fix[$0] $str) } @ function_return = out ## str } alias fix.XML { @ function_return = fix[XML][$encode($0)] } eval assign fix.XML.$encode(&) &\; eval assign fix.XML.$encode(<) <\; eval assign fix.XML.$encode(>) >\; assign fix.XML &<> alias fix.HTML { @ function_return = fix[HTML][$encode($0)] } eval assign fix.HTML.$encode(&) &\; eval assign fix.HTML.$encode(<) <\; eval assign fix.HTML.$encode(>) >\; assign fix.HTML &<> alias fix.URL { @ function_return = fix[URL][$encode($0)] } eval assign fix.URL.$encode(&) &\; assign fix.URL &