Hard-core LotusScript snippets

Source: Internet
Author: User

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 the XML interface from
LotusScript

Misc notes c api cils, 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
Implementation of the Wu-manber K-difference algorithm from 'mastering
Algorithms with Perl 'employee. 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
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
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
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 shoshould be mail. box-like. This code goes into an agent that runs
When documents are created or modified. You may be want to create some views
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
Messages are remailed under a different name. You must place your spoofed
Address into the principal field and the agent shoshould be signed by a non-mail
User.

Dim s as new notessession
Dim dB
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

Document and response tree Archiving
Archive. lss
This will move
Document and all of it's response documents to another database. The response
Heirarchy will be maintained.

Dim s as new notessession
Dim dB
Notesdatabase
Dim arcdb as notesdatabase
Dim DC
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
Service class for use by other things such as consolecmd. lss and win32process.
You shoshould subclass this and just use it indirectly. This provides the utility
Function getzstring and getcapierrormessage. getzstring takes a handle to
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
Client or server-side script to send console commands to the server. It shocould
Read the output but that isn' t reliable. It is good about actually sending
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
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
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 obviusly 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
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'ttried it. It uses a few c api callto 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 incluented 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 shocould 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 =
"Maid, maid"
Lei. keyname =
"Maid"

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
Authenticated notes connection.

Access the MS the XML interface from
LotusScript

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

Misc notes c api cils, especially multiple
Platforms

Notesapi.txt
Someone else
Wrote this and posted it on notes.net. It has some examples for calling
Notes API on non-Windows platforms.

FTP
Notesftp. lss
This is
Standard notesftp class from notes.net.

HTTP
Noteshttp. lss
I started
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 * cocould * Just search names. NSF for the same information
This happens to be updated times faster.

Dim username as Variant
Dim resolver
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
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.
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
Cocould 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
Document

Hidedesign. lss
This is
Supposed to toggle your hidden design flag. I haven'ttried it in
Production

Serverversion. lss
Serverversion. lss
Query
Notes server version

useractivity. lss
useractivity. lss

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.