PDA

View Full Version : iTCL morons.. read this


darkone
11-01-2003, 08:40 AM
Fancy topic ehh... now have this: :banana: before you'll start drooling...

I'm devoting next version for itcl updates. List of planned updates is below. If you have any suggestions, speak now or wait for ever.

userfile
isopen : Returns id of open userfile, -1 on error
open : Opens userfile
reload : Reloads userfile
lock : Locks userfile
unlock : Unlocks userfile
bin2ascii : Converts userfile to ascii
ascii2bin : Converts ascii to userfile (userfile must be locked at this point)
swapactive : Swaps open userfile with current user's active userfile (if any)

groupfile
isopen : Returns id of open groupfile, -1 on error
open : Opens groupfile
reload : Reloads groupfile
lock : Locks groupfile
unlock : Unlocks groupfile
bin2ascii : Converts groupfile to ascii (groupfile must be locked at this point)
ascii2bin : Converts ascii to groupfile

mountfile
load : Loads mountfile (vfs file)

MaistroX
11-01-2003, 08:58 AM
WOOOW, sounds GREAT, thou I understand NADA of what u were talking about above ! :D

kraxdaz
11-01-2003, 09:10 AM
Me too :D

darkone
11-01-2003, 10:56 AM
I removed the swapactive.. as it's too easy to exploit (if you manage to create exploitable script [= do not use proper parameter checking])


iputs "Opening userfile"
if { [userfile open "darkone"] == 0 } {
iputs "Open!"
iputs [userfile bin2ascii]
}

ascii2bin converts file from bin2ascii form to binary userfile structure. (updates userfile in ioftpd) In another words:

userfile open "darkone"
userfile lock
set foo [userfile bin2ascii]
# do something with $foo
ascii2bin "$foo"
userfile unlock

updates userfile for darkone :) it can't get much easier than that


[17:36:16] [L] 200-Opening userfile
[17:36:16] [L] 200-Open!
[17:36:16] [L] 200-wkup 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[17:36:16] [L] wkdn 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[17:36:16] [L] tagline baz00ka
[17:36:16] [L] ratio 0 3 3 3 3 3 3 3 3 0
[17:36:16] [L] password 89bd21f83054d45f030018f148021306cdcbdb68
[17:36:16] [L] monthup 0 0 0 10 19437 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[17:36:16] [L] monthdn 13 600128 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[17:36:16] [L] limits 1 1 4 2 4
[17:36:16] [L] ips darkone@127.0.0.1 darkone@192.168.1.10 *@debian darkone@spawn
[17:36:16] [L] home /home/darkone
[17:36:16] [L] groups 100
[17:36:16] [L] flags 3HG
[17:36:16] [L] dayup 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[17:36:16] [L] daydn 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[17:36:16] [L] credits 14000 0 0 0 0 0 0 0 0 0
[17:36:16] [L] allup 0 0 0 10 19437 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[17:36:16] [L] alldn 13 600128 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[17:36:16] [L] admingroups 100
[17:36:16] [L] 200 Command successful.

bounty
11-01-2003, 02:02 PM
the moron say THX AND LONG LIVE TO D1 ;)

bounty

ViNcE
11-02-2003, 03:52 PM
Hello dark,

It would be cool if you add some commands to check activity per services/users/groups

examples :

activity <service> :

--> [activity "FTP_Service"] return :

"uid" "gid" "pwd" "ident@ip" "path" "flags" "speed" "idletime" "action (DL/UL/IDLE)"

activity <-user> :

--> [activity "-ViNcE"] return :

"uid" "gid" "pwd" "ident@ip" "path" "flags" "speed" "idletime" "action (DL/UL/IDLE)"

activity <=group> :

--> [activity "=STAFF"] return :

"uid" "gid" "pwd" "ident@ip" "path" "flags" "speed" "idletime (in seconds)" "action (DL/UL/IDLE)"

(don't forget the quotes so we can get info easily)

and return -1 on error if service/user/group doesn't exists or something else... ;)

We can maybe be able to use that too :

activity <-user1 -user2 -user3 ...>
activity <=group1 =group2 =group3 ...>

That's all for me :) maybe a lot for you, but if u want to make a version especially for itcl scripters, make it complete and well :P

Have fun!

ViNcE

bounty
11-02-2003, 04:18 PM
D1 this request roxx ;)

thx vince ;)

darkone
11-02-2003, 04:23 PM
I don't see reason why ioFTPD should do the parsing; I could give you access to list of users online, but that will not have that kind of options => you will get global list, which you may, or may not parse yourself.

Usage could be something like this:

set fh [client who init]

if { $fh != 0 } {
while {[client who fetch $fh] == 0} {
set path [client who virtualpath $virtualpath]
set datapath [client who virtualdatapath $fh]
set status [client who status $fh]
set service [client who service $fh]
set uid [client who uid $fh]
}
client who close $fh
}

Or:

set fh [client who init "path" "virtualpath" "status" "service" "uid"]
if {$fh != 0} {
set loop 1
while { $loop } {
set data [client who fetch $fh]
if { "$data" != "0" }
{
# data is in following format:
#
# path<newline>virtualpath<newline>status<newline>service<newline>
#
# if I have time to study how-to give data back as arrays, you could use lindex to extract data :)
} else {
set loop 0
}
}
}

darkone
11-02-2003, 06:06 PM
I decided to use the second implementation as it's easier to parse & has less overhead (only data you request, is being copied)

if { [client who init "UID" "VIRTUALPATH"] == 0 } {
while { 1 } {
set data [client who fetch]
if { "$data" == "" } {
break
}
iputs "Uid: [lindex $data 0] Path: [lindex $data 1]"
}
}


SITE KILL is something simple as:

set uid [resolve user $args]
if { $uid == -1 } {
iputs "Could not locate user"
return 0
}
# We should check for master flag!
if { [client who init "UID" "CID"] == 0 } {
while { 1 } {
set data [client who fetch]
if { "$data" == "" } {
break
}
if {[lindex $data 0] == $uid]} {
client kill clientid [lindex $data 1]
iptus "Gave death signal to client [lindex $data 1]"
}
iputs "Uid: [lindex $data 0] Path: [lindex $data 1]"
}
}

darkone
11-03-2003, 06:52 AM
Some more cool things added (timers & command to load new mountfile)

## Resolve paths
set pwd "/mnt/d-drive"
iputs "Resolved $pwd to [resolve pwd $pwd]"
if { [mountfile open "d:/ioFTPD/etc/default.vfs"] == 0 } {
iputs "Mountfile read!"
iputs "Resolved $pwd to [resolve pwd $pwd]"
}

## Create timer, interval 5000ms/5s
if { [timer 5000 "TCL ../scripts/tcltimer.itcl $uid"] == 0 } {
iputs "Timer created! It kills user with uid $uid in 5seconds..."
}

darkone
11-03-2003, 08:20 AM
here's the full script that I used to test functions:

#iputs "$args"

iputs "Opening userfile"

if { [userfile open "darkone"] == 0 } {
iputs "Open!"
iputs [userfile bin2ascii]
}

## Fetch who list
if { [client who init "UID" "VIRTUALPATH" "CID" "TRANSFERSIZE"] == 0 } {
while { 1 } {
set data [client who fetch]
if { "$data" == "" } {
break
}
iputs -nobuffer "Uid: [lindex $data 0] Path: [lindex $data 1] Transfered: [lindex $data 3]"
}
}

## Resolve paths
set pwd "/mnt/d-drive"
iputs "Resolved $pwd to [resolve pwd $pwd]"
if { [mountfile open "d:/ioFTPD/etc/default.vfs"] == 0 } {
iputs "Mountfile read!"
iputs "Resolved $pwd to [resolve pwd $pwd]"
}

## Create user, rename it & finally delete (same commands apply to groups)
set name "lamer"
set newuid [user create "$name"]
if { $newuid >= 0 } {
iputs "Created user $name"
if { [user rename "$name" "$name\_delete"] == 0 } {
iputs "Successfully renamed user $name to $name\_delete"
set name "$name\_delete"
} else {
iputs "Failed to rename $name to $name\_delete"
}
if { [user delete "$name"] == 0 } {
iputs "User $name is history!"
} else {
iputs "Could not delete user $name..."
}
}

## Show hashed string
iputs "Hash for \"dungeon\": [sha1 "dungeon"]"

## Create timer, interval 5000ms/5s
if { [timer 5000 "TCL ../scripts/tcltimer.itcl $uid"] == 0 } {
iputs "Timer created! It kills user with uid $uid in 5seconds..."
}

#client kill clientid [lindex $data 2]

set ioerror 0

b>d>>s
11-03-2003, 11:56 AM
nm, figured out mount :L

b>d>>s
11-24-2003, 06:53 PM
how does "STATUS" work in the who info returned via itcl ?

darkone
11-25-2003, 02:39 AM
Experiment.. it retusn 0,1,2,3

0 = no transfer?
1 = upload?
2 = download?
3 = list?

could be wrong :)

b>d>>s
11-25-2003, 12:50 PM
well i could exeperiment, but when i get different output from itcl compared to standard io SITE WHO, its a bit hard.

thx