Go Back   FlashFXP Forums > >

Programming Need help with C/C++/Delphi? Ask here and make us all laugh.

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 11-01-2003, 08:40 AM   #1
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default iTCL morons.. read this

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)
darkone is offline  
Old 11-01-2003, 08:58 AM   #2
MaistroX
Senior Member
FlashFXP Registered User
ioFTPD Registered User
 
Join Date: Jul 2002
Posts: 221
Thumbs up

WOOOW, sounds GREAT, thou I understand NADA of what u were talking about above !
MaistroX is offline  
Old 11-01-2003, 09:10 AM   #3
kraxdaz
Member
ioFTPD Foundation User
 
Join Date: Jun 2003
Posts: 86
Default

Me too
kraxdaz is offline  
Old 11-01-2003, 10:56 AM   #4
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

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.
darkone is offline  
Old 11-01-2003, 02:02 PM   #5
bounty
Senior Member
ioFTPD Scripter
 
Join Date: Aug 2002
Posts: 529
Default

the moron say THX AND LONG LIVE TO D1

bounty
bounty is offline  
Old 11-02-2003, 03:52 PM   #6
ViNcE
Junior Member
 
Join Date: May 2003
Posts: 25
Thumbs up

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
ViNcE is offline  
Old 11-02-2003, 04:18 PM   #7
bounty
Senior Member
ioFTPD Scripter
 
Join Date: Aug 2002
Posts: 529
Default

D1 this request roxx

thx vince
bounty is offline  
Old 11-02-2003, 04:23 PM   #8
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

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>se rvice<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 is offline  
Old 11-02-2003, 06:06 PM   #9
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

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 is offline  
Old 11-03-2003, 06:52 AM   #10
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

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 is offline  
Old 11-03-2003, 08:20 AM   #11
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

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
darkone is offline  
Old 11-03-2003, 11:56 AM   #12
b>d>>s
Senior Member
 
Join Date: Feb 2003
Posts: 488
Default

nm, figured out mount :L
b>d>>s is offline  
Old 11-24-2003, 06:53 PM   #13
b>d>>s
Senior Member
 
Join Date: Feb 2003
Posts: 488
Default

how does "STATUS" work in the who info returned via itcl ?
b>d>>s is offline  
Old 11-25-2003, 02:39 AM   #14
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

Experiment.. it retusn 0,1,2,3

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

could be wrong
darkone is offline  
Old 11-25-2003, 12:50 PM   #15
b>d>>s
Senior Member
 
Join Date: Feb 2003
Posts: 488
Default

well i could exeperiment, but when i get different output from itcl compared to standard io SITE WHO, its a bit hard.

thx
b>d>>s is offline  
Closed Thread

Tags
ascii, converts, groupfile, open, userfile

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:09 PM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)