dupa

Author Topic: DOMAIN ADMINISTRATOR HAL: get scripts here..  (Read 4093 times)

spydaz

  • Hero Member
  • *****
  • Posts: 670
    • View Profile
    • http://www.spydazweb.co.uk/
DOMAIN ADMINISTRATOR HAL: get scripts here..
« on: April 11, 2004, 09:11:54 am »
HELLO ZABA WORLD.....

I HAVE BEEN STUDYING FOR MY MCSE (got MCSA now) AND THOUGHT WOULDNT IT BE NICE IF HAL COULD RETRIEVE DATA ABOUT THE CURRENT DOMAIN HE IS RESIDING ON.

IE:
DOMAIN NAME
DOMAIN CONTROLLER IP ADDRESS
DNS ADDRESS
IP ROUTING TABLE
USER GROUPS IN THE ACTIVE DIRECTORY
USERS IN THE ACTIVE DIRECTORY
PERFORMANCE RELATED DATA

THE LIST IS ENDLESS .. YOU COULD PUT A PASSWORD ON THE FUNCTIONS FOR SECURITY.. for home use NOT REALLY NECCESARY.

I HAVE ATTATCHED A COUPLE OF BASICS ... IF SUCESSFULL THE ABOVE SCRIPTS MENTIONED HAVE ALREADY BEEN CREATED....


HAPPY PROGRAMMING...




PS
message for VONSMITH:::::::: COULD YOU POSSIBLY POST A COPY OF THE xtf_topic focus funtion: SEPERATE FROM THE FULL BRAIN SCRIPT :
AS I AM TRYING TO CREATE A BRAIN of my own FROM SCRATCH... but cannot forget YOUR MAJOR KEY FUNCTION ::::: I HAVE TRIED TO SNIP IT OUT OF THE BRAIN BUT IT DOSENT SEEM TO FUNCTION MAYBE IM MISSING CRITICAL BITS NOT CONTAINED IN THE MAIN FUNCTION:::


'------------------------------------------------------
'DOMAIN INFO SCRIPTS
'------------------------------------------------------

'function : DOMAIN CONTROLLER ADDRESS      XSPYDAZ
'------------------------------------------------------
If InStr(1, UserSentence, " DOMAIN CONTROLLER ADDRESS ", 1) > 0 Then
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\rootcimv2")
Set colItems1 = objWMIService.ExecQuery("Select * from Win32_NTDomain",,48)
For Each objItem In colItems1
GetResponse = "DomainControllerAddress: " & objItem.DomainControllerAddress
Next
End If

'function : DOMAIN CONTROLLER SITE NAME      XSPYDAZ
'------------------------------------------------------
If InStr (1, UserSentence, " DOMAIN CONTROLLER SITE NAME ", 1) > 0 Then
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\rootcimv2")
Set colItems2 = objWMIService.ExecQuery("Select * from Win32_NTDomain",,48)
For Each objItem In colItems2
GetResponse = "DcSiteName: " & objItem.DcSiteName
Next
End If            

'function : DOMAIN NAME                  XSPYDAZ
'------------------------------------------------------
If InStr (1, UserSentence, " DOMAIN NAME ", 1) > 0 Then
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\rootcimv2")
Set colItems3 = objWMIService.ExecQuery("Select * from Win32_NTDomain",,48)
For Each objItem In colItems3
GetResponse = "Dc domain Name: " & objItem.DnsForestName
Next
End If

'function : DOMAIN CONTROLLER NAME         XSPYDAZ
'------------------------------------------------------
If InStr (1, UserSentence, " DOMAIN CONTROLLER NAME ", 1) > 0 Then
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\rootcimv2")
Set colItems4 = objWMIService.ExecQuery("Select * from Win32_NTDomain",,48)
For Each objItem In colItems4
GetResponse = "DomainControllerName: " & objItem.DomainControllerName
Next
End If



vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
DOMAIN ADMINISTRATOR HAL: get scripts here..
« Reply #1 on: April 12, 2004, 01:55:24 pm »
spydaz,
The XTF function is just one section within the GetResponse script. However to function it needs several variables that are saved using the CustomMem function and also shares other variables with other functions. Unfortunately the XTF function itself cannot be easily cut and pasted. The functions and variables used by the XTF function are critical parts of the XTF Brain. Generally I suggest cutting and pasting into the XTF Brain .uhp as a foundation. There are several guidelines that must be followed. As I have posted elsewhere the "GetResponseBlock", "BlockSave" and "QuestionPending" flags must be implemented in any added scripts, as a minimum.

If I implement the XTF function as a stand alone function in the future it will be clearer to the user what the affected variables and support functions are. I don't know if I'll have time to do this.


=vonsmith=
« Last Edit: April 12, 2004, 01:56:55 pm by vonsmith »
 

spydaz

  • Hero Member
  • *****
  • Posts: 670
    • View Profile
    • http://www.spydazweb.co.uk/
DOMAIN ADMINISTRATOR HAL: get scripts here..
« Reply #2 on: April 12, 2004, 02:17:57 pm »
I understand the time it takes to create and debug these scripts.

I will put more effort into decyphering the script.

maybe as you say "REVERSE ENGINEER" delete the functions from XTFFULLBRAIN AND REBUILD. when i do that usually i get a bad response block error from the PATTERNS DATABASE.

im not too sure if i understand the CustomMem function ...
NOW I WILL HAVE TO ...

XSPYDAZ

thank you all

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
DOMAIN ADMINISTRATOR HAL: get scripts here..
« Reply #3 on: April 12, 2004, 04:55:37 pm »
spydaz,
Could you explain a little more about this statement?:
"maybe as you say "REVERSE ENGINEER" delete the functions from XTFFULLBRAIN AND REBUILD. when i do that usually i get a bad response block error from the PATTERNS DATABASE."

The use of the CustomMem() function is actually simple. Hal's implementation of VBscript can't save any variables in memory between calls to the GetResponse script. If you want to save variables they have to be passed ByRef from the GetResponse() function so that the variable's value can be saved by the GetResponse() function itself. To save other variables we must use the CustomMem() function. The Encode part of the CustomMem() function encodes a variable's value into the CustomMem string. The value of each variable that is encoded is appended to that string. The CustomMem string is saved by the GetResponse() function since it is passed ByRef. When GetResponse() is called on the next user input the Decode part of CustomMem extracts the variable's value out of the CustomMem string for use in the current call of GetResponse().

The original version of CustomMem written by Zabaware didn't preserve the Type of the variable along with the value. All variable data was decoded as string data. This meant the programmer had to use Cint(), CLng(), or other function to convert the data back into the correct Type. The CustomMem function as used in the XTF Brain preserves the variable Type and Decodes the variable's value back into the original data Type automatically. If you want to look at the CustomMem string in the XTF Brain you can simply write:

'Add the following line to include the CustomMem string in Hal's response to the user. Place this line before the existing line below that is located
'at the bottom of the GetResponse script.
GetResponse = GetResponse & vbCrLf & " CustomMem string:" & CustomMem
'The following line is the existing line in GetResponse(). It is the last line in
'GetResponse that returns the variables to the calling program.
GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, PrevTopic)

The use of CustomMem is relatively easy to understand. Look at the examples in the XTF Brain script for EncodeVar() and DecodeVar(). The only confusing part is how to "initialize" variables saved in CustomMem when Hal is first started. I don't think there is an example in the XTF Brain of how to initialize a CustomMem variable. However, often initialization isn't necessary.


=vonsmith=
« Last Edit: April 12, 2004, 04:59:37 pm by vonsmith »