zoukankan      html  css  js  c++  java
  • Hardcore LotusScript snippets

    Approximate string matching
    Binary string operations
    Anonymizing remailer
    Document and response tree archiving
    C API base class
    Send server console commands
    Work with a database design
    Day of Week
    Read an Excel file directly (also demo file open
    dialog)

    Full text searches on more than 5000
    documents

    LEI made easy
    Generate a list of HTTP URLs to audit your web server
    security

    Access the MS XML interface from
    LotusScript

    Misc Notes C API calls, especially multiple
    platforms

    FTP
    HTTP
    Names List!
    Read CSV files
    Remove $V5Actions from design
    elements

    Replica Info
    Server based object variables
    String processing
    Win32Process
    Apigoods.nsf.gz
    Notes database list
    ACLChangeHistory
    AddedToThisFile
    HideDesign
    ServerVersion
    UserActivity

    Approximate string matching
    WuManber.lss
    This is an
    implementation of the Wu-Manber k-difference algorithm from 'Mastering
    Algorithms with Perl' p382. This modifies the original: * It is all LotusScript,
    not perl * All binary ops are on 'bit' strings. This removes the integer limit *
    MAXBITS is set at 64, since there is no match this can be raised arbitrarily
    True/false = Approxim(Text,Pattern,Percent) Text is the text to attempt the
    match with Pattern is the text to match against. This is your 'correct' text
    Percent: a whole number value of 1 - 100. This is how much the text is allowed
    to differ from the pattern. (This is really just matching against the size of
    the pattern and the Levenshtein edit distance)

         CompanyName = "Imation Corporation"
        InCo =
    "Imaton Corporation"
        AllowableDiff = 10 ' 10%

        If
    approxim(InCo, CompanyName, AllowableDiff) Then
             ' Match
       
    Else
             ' mismatch
        End If

    Binary string operations
    binops.lss
    I had to handle
    large binary values for the string matching code. This provies the
    functions:

    binstring =
    newBin()
    binFixUp(binstring,binstring)
    binstring =
    pow2(integer)
    integer = binTrue(binstring)
    string =
    reverse(binstring)
    binstring = shiftLeft(binstring, integer)
    binstring =
    shiftRight(binstring, integer)
    binstring = rotateLeft(binstring,
    integer)
    binstring = rotateRight(binstring, integer)
    binstring =
    onesComplement(binstring)
    binstring =
    binAND(binstring,binstring)
    binstring =
    binOR(binstring,binstring)
    binstring =
    binXOR(binstring,binstring)
    binstring = toBinary(double)
    double =
    fromBinary(binstring)

    Anonymizing remailer
    Anon_Penet_Fi.lss
    An
    anonymizing remailer. Domino does not normally allow e-mail address spoofing;
    this does the job.

    Create a new database and grant -default- depositor
    access. This should be mail.box-like. This code goes into an agent that runs
    when documents are created or modified. You may want to create some views to
    look at pending requests, this is just the core engine. The net effect is that
    users may put documents into this database through backend coding and the
    messages are remailed under a different name. You must place your spoofed
    address into the Principal field and the agent should be signed by a non-mail
    user.

         Dim S as New NotesSession
        Dim Db as
    NotesDatabase
        Dim Doc as NotesDocument

        Set Db =
    S.GetDatabase("Server","admin\penet.nsf")
        Set Doc =
    Db.CreateDocument
        With Doc
             .SendTo =
    "josh@greentechnologist.org"
             .Subject = "anonymous mail"
           
    .Body = "Nothing"
             .Principal =
    "hexenmeister@greentechnologist.org"
             .Save(True, True, True)
       
    End With





    Document and response tree archiving
    Archive.lss
    This will move a
    document and all of it's response documents to another database. The response
    heirarchy will be maintained.

         Dim S as New NotesSession
        Dim Db as
    NotesDatabase
        Dim ArcDb as NotesDatabase
        Dim DC as
    NotesDocumentCollection
        Dim Doc as NotesDocument
        Dim DT as new
    NotesDateTime ("12/30/1899")
        Dim i as Integer

        Set Db =
    S.GetDatabase("Server","source.nsf")
        Set DC = Db.Search("Archive=""1""",
    DT, 5000)

        Set ArcDb = S.GetDatabase("Server","archive.nsf")

     
      For i = 0 to DC.Count
            Set Doc = DC.GetNthDocument(i)
    If Not Doc
    Is Nothing then
          If Not Doc.Created < 1/1/1900 Then
             
    Call ArchiveDocument(Doc, Nothing, ArcDb, "")
          End If
    End If
       
    Next





    C API base class
    CAPI.lss
    This is sort of a
    service class for use by other things such as ConsoleCMD.lss and Win32Process.
    You should subclass this and just use it indirectly. This provides the utility
    function GetZString and GetCAPIErrorMessage. GetZString takes a handle to a
    memory object and copies a null terminated string out to a String variable.
    GetCAPIErrorMessage takes an error code and attempts to get a useful error
    message.

    Class Something As CAPI
    %REM
      Do
    things
    %ENDREM
    End Class





    Send server console commands
    ConsoleCMD.lss
    This allows a
    client or server-side script to send console commands to the server. It should
    read the output but that isn't reliable. It is good about actually sending the
    results.

    Dim Console As RemoteConsole
    Dim Command as String
    Dim
    Msg as String

    Set Console = New
    RemoteConsole("Server01/Something")
    Results = Console.Exec("tell http
    q")
    ' .... wait until the httpd stops (and check for it exlicitl)
    Result =
    Console.Exec("load http")





    Work with a database design
    DbDesign/
    This is mostly the
    original DbDesign from notes.net. I added the additional properties .title,
    .template, .inheritTemplate, .categories. Some of those were already available
    in the LotusScript class system. This is a full read/write implementation. I
    also added the methods .Unprotect and .Refresh(Server). I used this code to set
    a design's template, unprotect all the design elements and then refresh the
    design. The original code is in DbDesign.lss, my alterations are in
    DbDesign2.lss.

    Dim S as New NotesSession
    Dim Db as NotesDatabase
    Dim
    Design as DatabaseDesign

    Set Db = S.CurrentDatabase
    Set Design =
    createDatabaseDesign(Db)

    Db.template = "R50StdMail"
    Call
    Db.Unprotect
    Call Db.Refresh(Db.Server)





    Day of Week
    DayOfWeek.lss
    This is
    supposed to calculate the day of the week. The code is obviously wrong and
    doesn't even appear to be correct. The 'bug' is that I've declared Weekday twice
    and I assign to it twice. This was supposed to calculate the Julian and
    Greggorian calenders but it doesn't return the right results. Mail me if you
    know how to get the day of the week.





    Read an Excel file directly (also demo file open
    dialog)

    ExcelExport.lss
    This uses a
    Windows File Open dialog to select an Excel file. It reads the file directly
    using the Excel COM object. This is a full working sample script so I'm not
    providing and example. The file dialogs were written by another person
    (attribution inline).





    Full text searches on more than 5000
    documents

    FTUnlimited
    I didn't write
    this and haven't tried it. It uses a few C API calls to work with the FT index
    directly. Very cool. If you know how to work with FT indexes on multiple
    databases please let me know. From the code: This function will execute multiple
    paged searches on a query and populate a given folder with the results. Input:
    the full text query string, the destination folder (it must already exist), and
    the server and file path to the database. Returns: "" if everthing is OK,
    otherwise a text message explaining which functions bombed and why.





    LEI made easy
    LEI.lss
    This automates most
    of the hard and barely documented LEI lsx API.
    Stick this in a script library
    and include it as nessessary. It will initialize an LC session automatically.
    Outside of the main LEIConnection class it provides the convenience functions
    LCLogEvent and LCLogError. You should use those functions insider your LEI
    related LotusScript to relay errors back up the LEI log. The LEIConnection class
    handles all the hard work for actually using the LEI class system and executing
    activities from LotusScript (as opposed to just using the logging
    functions)

    Dim S as New NotesSession
    Dim LEI as LEIConnection
    Dim
    R as LCFieldList

    Set LEI = New LEIConnection("OraPRD")
    LEI.Metadata =
    "Tablename"
    LEI.Condition = "EMPLOYEE_TYPE = ""ACTIVE"""
    LEI.FieldNames =
    "EMPLOYEE_NUMBER, EMPLOYEE_TYPE, FIRST_NAME, LAST_NAME"
    LEI.KeyName =
    "EMPLOYEE_NUMBER"

    Set R = LEI.LC_Select
    while not R is nothing
     
    ... do something

      Set R = LEI.Fetch
    Wend





    Generate a list of http URLs to audit your web server
    security

    LinkChecker.lss
    This
    connects directly to a server and generates a static HTML web page for later
    browsing. This is only good for auditing since you must already have an
    authenticated notes connection.





    Access the MS XML interface from
    LotusScript

    MSXML.lss
    This is something
    I just wrote for myself to figure the MS XML libary out. I use the more standard
    Java code instead.





    Misc Notes C API calls, especially multiple
    platforms

    NotesAPI.txt
    Someone else
    wrote this and posted it on Notes.net. It has some examples for calling the
    Notes API on non-Windows platforms.





    FTP
    NotesFTP.lss
    This is the
    standard NotesFTP class from Notes.net.





    HTTP
    NotesHTTP.lss
    I started to
    write a HTTP class for LotusScript. It supports a basic GET method.

    Dim http as NotesHTTPSession
    Dim URL as string
    Dim
    html as string

    Set http = New NotesHTTPSession
    URL = "http://www.notesoss.org/"
    html =
    http.doGet(url)
    Delete http

    messagebox html





    Names List!
    NotesNamesList.lss
    This
    enumerates all the variations of a user's ID and which groups they are a member
    of. I use this for an intranet application to have the server find a person's
    group membership. You *could* just search names.nsf for the same information but
    this happens to be many times faster.

    Dim Username as variant
    Dim Resolver as
    NotesNamesList

    Username = Evaluate("@UserName")
    Set Resolver = New
    NotesNamesList(UserName)
    If
    Resolver.IsAuthorized(Doc.GetItemValue("DocAuthors")) Then
    ' User does have
    access through user, group or role assignment
    Else
    ' User does not have
    access
    End If






    Read CSV files
    ParseCSVFile.vbs
    A code
    snippet for reading CSV properly. I haven't checked it for accuracy and I didn't
    write it.

    >




    Remove $V5Actions from design elements
    RemoveR5Fields.lss
    This will
    remove the $V5Actions and $DesignerVersion fields from a specified design
    element. If you haven't already noticed, if you modified a 4.x design element
    with a R5 client the actions are copied from $ACTIONS into $V5ACTIONS. If you
    edit the same design element with a 4.x designer then the fields will go out of
    sync and remain forever that way. The only way to recover (outside of deleting
    the whole design element) is to remove these fields from the design doc.





    ReplicaInfo.txt
    ReplicaInfo.txt
    This looks
    like someone else's code. It's probably an example but it is only here in
    incomplete form so it just demonstrates opening a database using the C API. The
    major flaw is it doesn't close the database afterward. You *must* clean up after
    yourself when working the C API.





    ServerBasedObjectVariables.lss
    ServerBasedObjectVariables.lss
    This is a collection of global objects that backend oriented scripts
    could use. This is just a standardization thing.





    StringProcessing.lss
    StringProcessing.lss
    This
    has a number of useful 4.x compatible string functions. It also has a kick-butt
    (though not clearly coded) RFC822 compliant e-mail address parser. This is used
    for the anonymizing remailer to detect valid addresses.





    Win32Process.lss
    Win32Process.lss
    This spawns
    a process on a windows box and can detect whether the process has exited or not.
    The script writer has the option to wait until the program exists or terminate
    it early.





    apigoods.nsf.gz
    apigoods.nsf.gz
    This is from
    notes.net. Supposedly it has good stuff in it. I don't know just yet.





    notesdbs.txt
    notesdbs.txt
    This is a list
    of common notes databases to check for when pen-testing a notes server.





    Demos from The View

    ACLChangeHistory.lss
    A
    demonstration on using the Notes C API to extract the ACL change history. This
    is from The View

    AddedToThisFile.lss
    A
    demonstration on how to get the 'added to this file' property for a
    document

    HideDesign.lss
    This is
    supposed to toggle your hidden design flag. I haven't tried it in
    production

    ServerVersion.lss
    ServerVersion.lss
    Query a
    notes server version

    UserActivity.lss
    UserActivity.lss

  • 相关阅读:
    移动端事件
    移动端的三种布局
    bootstrap自定义——栅格列数修改
    less文件的运行
    lessc的安装
    nodejs的安装
    jquery插件之jquery-ui
    指定网卡进行ping操作
    汇编语言从入门到精通-4标识符和表达式
    汇编语言从入门到精通-3操作数的寻址方式
  • 原文地址:https://www.cnblogs.com/hannover/p/2467161.html
Copyright © 2011-2022 走看看