#19018 - 2002-03-22 08:30 PM
getfileattrib
|
Anonymous
Anonymous
Unregistered
|
why when i use the following code:
if getfileattrib ("c:\winnt\system") & 16
does "16" get redirected to the console? it's my understanding that the above line of code is simply asking if "c:\winnt\system" is a directory.
anyone?
|
|
Top
|
|
|
|
#19021 - 2002-03-22 09:22 PM
Re: getfileattrib
|
Anonymous
Anonymous
Unregistered
|
les_ligetfalvy, how do i get it not to return "16" to the console?
Erik, sorry i mispelled it in my post here. It's spelled correctly in the code. BTW, I would be getting syntax errors if I mispelled it in the script, not a "16".
TIA
|
|
Top
|
|
|
|
#19023 - 2002-03-22 11:07 PM
Re: getfileattrib
|
Anonymous
Anonymous
Unregistered
|
this is weird. your code snippet worked just fine. I'm running Win2k and Kix 4.02 Here is my exact code. It was written to help counter the W32/MyLife.b@MM virus running around right now:
------------------------------------ $FileFound = 0 $DirFound = 0 $Infected = 0
:Mylifeb If Exist (%windir%\system\cari.scr) If GettFileAttr(%windir%\system\cari.scr) & 16 $DirFound = 1 $Result = SetFileAttr(%windir%\system\cari.scr, 5) $Infected = "not infected" Else $FileFound = 1 $Infected = "!INFECTED!" Endif Else Md (%windir%\system\cari.scr) $Result = SetFileAttr(%windir%\system\cari.scr, 5) Goto "Mylifeb" Endif
:Log $Logfile = "\\clariiweb\logs\logon script logs\Mylifeb.csv" If RedirectOutput($Logfile, 0) = 0 ? "@DATE,@TIME,@WKSTA,$OperatingSystem,@DOMAIN,@IPADDRESS0,$Infected" Endif :End $Result = RedirectOutput("") ------------------------------------
Comments?
|
|
Top
|
|
|
|
#19027 - 2002-03-22 11:51 PM
Re: getfileattrib
|
Anonymous
Anonymous
Unregistered
|
i didn't think putting the quotes would help here, but i tried it nonetheless. the script is still spitting "16" out to the console. thanks for the suggestion though!
i guess it's no big deal, but i'd just like to know where it's coming from and how to stop it. thanks to everyone!
|
|
Top
|
|
|
|
#19029 - 2002-03-23 04:52 AM
Re: getfileattrib
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11631
Loc: CA
|
Planet Earth calling Mr. Invisible - 'come in Mr. Invisible.
TTT=(Touch Typing Tutor) comes with a spell checker, or you can download MCA's tools to check those kind of errors.
MCA's place on the Web [ 23 March 2002, 04:56: Message edited by: NTDOC ]
|
|
Top
|
|
|
|
#19033 - 2002-03-23 09:07 PM
Re: getfileattrib
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
LLigetfa, you must be suffering from a case of user error with regard to the "Search By Registered Member Number". It works for me. ![[Wink]](images/icons/wink.gif) [ 23 March 2002, 21:11: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#19036 - 2002-03-25 06:22 AM
Re: getfileattrib
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
We have trace the exact location which returns "16". It is your line 7. A bitwise operation with an unknown function name returns an unexpected result.
Our debugging version:
code:
CLS COLOR C+/N AT (1,1) " " IF RedirectOutput("d:\zszs") ENDIF ? "-"+LCASE(@day)+" "+@date+" "+@time+"- kixtart "+@kix+"/3.01e script starting." ? "-" ? "-curdir: "+LCASE(@curdir) ? "-scriptdir: "+LCASE(@scriptdir) ? "-startdir: "+LCASE(@startdir) ? "-" ? "-userid: "+LCASE(@userid)+"/"+LCASE(@wuserid) ? "-user priv: "+LCASE(@priv) ? "-version: inwin="+@inwin+"/dos="+@dos ? "-"
?"- 1-"+@time+"- @error @serror "? $filefound = 0 ?"- 2-"+@time+"- @error @serror "? $dirfound = 0 ?"- 3-"+@time+"- @error @serror "? $infected = 0 ?"- 4-"+@time+"- @error @serror "? ?"- 5-"+@time+"- @error @serror "? :mylifeb ?"- 6-"+@time+"- @error @serror "? IF Exist (%windir%\system\cari.scr) ?"- 7-"+@time+"- @error @serror "? IF GetFileAttr(%windir%\system\cari.scr) & 16 ?"- 8-"+@time+"- @error @serror "? $dirfound = 1 ?"- 9-"+@time+"- @error @serror "? $result = SetFileAttr(%windir%\system\cari.scr, 5) ?"- 10-"+@time+"- @error @serror "? $infected = "not infected" ?"- 11-"+@time+"- @error @serror "? ELSE ?"- 12-"+@time+"- @error @serror "? $filefound = 1 ?"- 13-"+@time+"- @error @serror "? $infected = "!INFECTED!" ?"- 14-"+@time+"- @error @serror "? ENDIF ?"- 15-"+@time+"- @error @serror "? ELSE ?"- 16-"+@time+"- @error @serror "? MD (%windir%\system\cari.scr) ?"- 17-"+@time+"- @error @serror "? $result = SetFileAttr(%windir%\system\cari.scr, 5) ?"- 18-"+@time+"- @error @serror "? GOTO "Mylifeb" ?"- 19-"+@time+"- @error @serror "? ENDIF ?"- 20-"+@time+"- @error @serror "? ?"- 21-"+@time+"- @error @serror "? :log ?"- 22-"+@time+"- @error @serror "? $logfile = "\\clariiweb\logs\logon script logs\Mylifeb.csv" ?"- 23-"+@time+"- @error @serror "? IF RedirectOutput($logfile, 0) = 0 ?"- 24-"+@time+"- @error @serror "? ? "@DATE,@TIME,@WKSTA,$OperatingSystem,@DOMAIN,@IPADDRESS0,$Infected" ?"- 25-"+@time+"- @error @serror "? ENDIF ?"- 26-"+@time+"- @error @serror "? ?"- 27-"+@time+"- @error @serror "? :end ?"- 28-"+@time+"- @error @serror "? $result = RedirectOutput("")
?"- end-"+@time+"- @error @serror "? ? "-" ? "-"+LCASE(@day)+" "+@date+" "+@time+"- kixtart "+@kix+"/3.01e script ending." ? "-" ;($begin) ; ; mon 25-mar-2002 03:46:36 (kix 4.00 vs 3.01e) ; ;Informative KIXSTRIP: no errors found (input=28 output=28 skip=0). ; ;Informative KIXSTRIP: 3 block_structures found. ;Informative KIXSTRIP: no UDF's found. ;Informative KIXSTRIP: 3 labels found. ;Summary KIXSTRIP: BREAK CALL DEBUG DISPLAY ENDFUNCTION EXECUTE EXIT FUNCTION GET GETS GOSUB GOTO OLExxx PLAY QUIT RETURN RUN SHELL SLEEP THEN USE ;Informative KIXSTRIP: 1 GOTO ; ;($end)
The output of file c:\kixdebug.log is
code:
-monday 2002/03/25 03:47:46- kixtart 4.02/3.01e script starting. - -curdir: d:\ -scriptdir: -startdir: c:\windows - -userid: mca/mca -user priv: guest -version: inwin=2/dos=4.0 - - 1-03:47:46- 0 The operation completed successfully.
- 2-03:47:46- 0 The operation completed successfully.
- 3-03:47:46- 0 The operation completed successfully.
- 4-03:47:46- 0 The operation completed successfully.
- 5-03:47:46- 0 The operation completed successfully.
- 6-03:47:46- 0 The operation completed successfully.
- 7-03:47:46- 0 The operation completed successfully. 16 - 8-03:47:46- 0 The operation completed successfully.
- 9-03:47:46- 0 The operation completed successfully.
- 10-03:47:47- 0 The operation completed successfully.
- 11-03:47:47- 0 The operation completed successfully.
- 15-03:47:47- 0 The operation completed successfully.
- 20-03:47:47- 0 The operation completed successfully.
- 21-03:47:47- 0 The operation completed successfully.
- 22-03:47:47- 0 The operation completed successfully.
- 23-03:47:47- 0 The operation completed successfully.
After modifying this line the output becomes:
code:
-monday 2002/03/25 03:51:44- kixtart 4.02/3.01e script starting. - -curdir: d:\ -scriptdir: -startdir: c:\windows - -userid: mca/mca -user priv: guest -version: inwin=2/dos=4.0 - - 1-03:51:45- 0 The operation completed successfully.
- 2-03:51:45- 0 The operation completed successfully.
- 3-03:51:45- 0 The operation completed successfully.
- 4-03:51:45- 0 The operation completed successfully.
- 5-03:51:45- 0 The operation completed successfully.
- 6-03:51:45- 0 The operation completed successfully.
- 7-03:51:45- 0 The operation completed successfully.
- 8-03:51:45- 0 The operation completed successfully.
- 9-03:51:45- 0 The operation completed successfully.
- 10-03:51:45- 0 The operation completed successfully.
- 11-03:51:45- 0 The operation completed successfully.
- 15-03:51:45- 0 The operation completed successfully.
- 20-03:51:45- 0 The operation completed successfully.
- 21-03:51:45- 0 The operation completed successfully.
- 22-03:51:45- 0 The operation completed successfully.
- 23-03:51:45- 0 The operation completed successfully.
Some remarks about your code - the GOTO structure can create a deadlock situation on W9x systems. in our version we replace this. - we are using the WriteProfileString function to create only a list of workstations which are infected. Clean systems will not add to this list or they will remove from this list. Our version:
code:
$entry=ExpandEnvironmentVars("%windir%")+"\system\cari.scr" :mylifeb $found="no" IF Exist($entry) = 1 IF GetFileAttr($entry) & 16 $result=SetFileAttr($entry,5) ELSE $found="yes" ENDIF ELSE MD $entry $result=SetFileAttr($entry, 5) ENDIF IF ($found = "yes") $infected="!INFECTED!" ELSE $infected="" ; -not infected- ENDIF
:log $logfile = "\\clariiweb\logs\logon script logs\Mylifeb.csv" $loginfo = "@date @time $OperatingSystem @domain @ipaddress0 $infected" IF (Len($infected) <> 0) IF WriteProfileString($logfile,"infected","@wksta",$loginfo) ENDIF ELSE IF WriteProfileString($logfile,"infected","@wksta","") ENDIF ENDIF
greetings. [ 25 March 2002, 07:44: Message edited by: MCA ]
|
|
Top
|
|
|
|
#19037 - 2002-03-25 06:30 AM
Re: getfileattrib
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear NTDOC,
This topic inspires me to extend the kixstrip tool. Undefined or defined functions doesn't inform me about possible problems. The extension will report all names which aren't defined by KiXtart. So above mistyping will also be reported.
Hey Les,
When do you get a new keyboard? Your letter "T" doesn't work great anymore.
greetings. [ 25 March 2002, 06:31: Message edited by: MCA ]
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 764 anonymous users online.
|
|
|