Esempio n. 1
0
def insertRetrieveTest():
    n = 1000000
    db = esedb.open(database, 'n', True)
    data = '0123456789ABCDEF'
    timer = Stopwatch.StartNew()
    for i in xrange(n):
        db[i] = data
    timer.Stop()
    print 'Inserted %d records in %s' % (n, timer.Elapsed)
    (k, v) = db.first()
    timer = Stopwatch.StartNew()
    for i in xrange(n):
        data = db[k]
    timer.Stop()
    print 'Retrieved 1 record %d times in %s' % (n, timer.Elapsed)
    timer = Stopwatch.StartNew()
    i = 0
    for (k, v) in db:
        i += 1
    timer.Stop()
    print 'Scanned %d records in %s' % (i, timer.Elapsed)
    keys = db.keys()
    random.shuffle(keys)
    timer = Stopwatch.StartNew()
    for k in keys:
        v = db[k]
    timer.Stop()
    print 'Retrieved %d records in %s' % (len(keys), timer.Elapsed)
    db.close()
Esempio n. 2
0
def testColumnStream():
    print 'Verifying ColumnStream against MemoryStream'
    timer = Stopwatch.StartNew()
    instance = Instance('ColumnStreamTest')
    instance.Parameters.MaxVerPages = 1024
    instance.Parameters.CircularLog = True
    instance.Init()

    bookmark = Array.CreateInstance(System.Byte, 255)

    try:
        session = Session(instance)
        dbid = Api.JetCreateDatabase(session, 'ColumnStream.db', '',
                                     CreateDatabaseGrbit.OverwriteExisting)
        Api.JetBeginTransaction(session)
        tableid = Api.JetCreateTable(session, dbid, 'table', 0, 100)

        columndef = JET_COLUMNDEF(coltyp=JET_coltyp.LongBinary)
        columnid = Api.JetAddColumn(session, tableid, 'LvColumn', columndef,
                                    None, 0)

        Api.JetCloseTable(session, tableid)
        Api.JetCommitTransaction(session, CommitTransactionGrbit.LazyFlush)
        tableid = Api.JetOpenTable(session, dbid, 'table', None, 0,
                                   OpenTableGrbit.None)

        for i in xrange(64):
            runtimer = Stopwatch.StartNew()

            Api.JetBeginTransaction(session)
            Api.JetPrepareUpdate(session, tableid, JET_prep.Insert)
            bookmarksize = Api.JetUpdate(session, tableid, bookmark, 255)
            Api.JetCommitTransaction(session, CommitTransactionGrbit.LazyFlush)
            Api.JetGotoBookmark(session, tableid, bookmark, bookmarksize)

            Api.JetBeginTransaction(session)
            Api.JetPrepareUpdate(session, tableid, JET_prep.Insert)
            streams = [
                MemoryStream(),
                ColumnStream(session, tableid, columnid)
            ]
            randomOperations(64, streams)
            Api.JetUpdate(session, tableid)
            Api.JetCommitTransaction(session, CommitTransactionGrbit.LazyFlush)

            runtimer.Stop()
            print '\t%s' % runtimer.Elapsed

    finally:
        instance.Dispose()
    timer.Stop()
    print '%s' % timer.Elapsed
Esempio n. 3
0
def YaraAll(YaraRules, vtero):
    Vtero.VerboseLevel = 1
    Vtero.DiagOutput = False
    dumptime = Stopwatch.StartNew()
    yall = vtero.YaraAll(YaraRules, True, False)
    print "elapsed " + dumptime.Elapsed.ToString()
    return yall
Esempio n. 4
0
def testMemoryStreams():
    print 'Verifying MemoryStreams'
    stopwatch = Stopwatch.StartNew()
    for i in xrange(64):
        streams = [MemoryStream() for x in xrange(2)]
        randomOperations(128, streams)
    stopwatch.Stop()
    print '%s' % stopwatch.Elapsed
Esempio n. 5
0
def retrieveTest(keys):
    db = esedb.open(database, 'r')
    timer = Stopwatch.StartNew()
    for x in keys:
        data = db[x]
    timer.Stop()
    db.close()
    return timer.Elapsed
Esempio n. 6
0
def insertTest(keys):
    db = esedb.open(database, 'n', True)
    data = 'XXXXXXXXXXXXXXXX'
    timer = Stopwatch.StartNew()
    for x in keys:
        db[x] = data
    timer.Stop()
    db.close()
    return timer.Elapsed
Esempio n. 7
0
def scanTest():
    db = esedb.open(database, 'r')
    timer = Stopwatch.StartNew()
    i = 0
    for (k, v) in db:
        i += 1
    timer.Stop()
    db.close()
    return timer.Elapsed
Esempio n. 8
0
def repeatedRetrieveTest(numretrieves):
    db = esedb.open(database, 'r')
    (key, data) = db.first()
    timer = Stopwatch.StartNew()
    for i in xrange(0, numretrieves):
        data = db[key]
    timer.Stop()
    db.close()
    return timer.Elapsed
Esempio n. 9
0
 def Execute(self, recs):
     sw = Stopwatch.StartNew()
     if self.Name == 'copyto.over':
         copyToRecord(recs, True)
     elif self.Name == 'copyto.new':
         copyToRecord(recs, False)
     sw.Stop()
     t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
     ScriptSupport.SendStatusText(
         'Script took %s to complete. List added to clipboard' %
         t.ToString(), Color.Blue)
Esempio n. 10
0
		def Execute(self, recs):
			from TESVSnip.UI.Hosting import ScriptSupport
			from System.Drawing import SystemColors, Color
			from TESVSnip.UI.Hosting import ScriptSupport
		
			sw = Stopwatch.StartNew()
			print getNPCRaces(recs)
			#p = copyRecords(recs)
			#__plugins__.AddRecord(p)  # add new plugin
			sw.Stop()
			t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)            
			ScriptSupport.SendStatusText('Script took %s to complete' % t.ToString() , Color.Blue)
Esempio n. 11
0
def testFileStream():
    print 'Verifying FileStream against MemoryStream'
    stopwatch = Stopwatch.StartNew()
    for i in xrange(128):
        m = MemoryStream()
        file = Path.GetTempFileName()
        f = FileStream(file, FileMode.Open)
        try:
            streams = [m, f]
            randomOperations(128, streams)
        finally:
            f.Close()
            File.Delete(file)
    stopwatch.Stop()
    print '%s' % stopwatch.Elapsed
Esempio n. 12
0
        def Execute(self, recs):
            from TESVSnip.UI.Hosting import ScriptSupport
            from System.Drawing import SystemColors, Color

            sw = Stopwatch.StartNew()
            str = generateItemList(recs)
            if str:
                sw.Stop()
                t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
                window = ScriptSupport.CreateTextWindow("Script Output")
                if window:
                    window.Focus()
                    window.SetText(str)
                ScriptSupport.SendStatusText(
                    'Script took %s to complete' % t.ToString(), Color.Blue)
Esempio n. 13
0
def test(MemList):
    TotalRunTime = Stopwatch.StartNew()
    TotalSizeAnalyzed = 0
    for MemoryDump in MemList:
        print " ++++++++++++++++++++++++++++++ ANALYZING INPUT [" + MemoryDump + "] ++++++++++++++++++++++++++++++ "
        if not File.Exists(MemoryDump):
            print "Can not find dump to analyze: " + MemoryDump
            continue
        copts.FileName = MemoryDump
        vtero = ScanDump(MemoryDump, copts)
        TotalSizeAnalyzed += vtero.FileSize
        print " ++++++++++++++++++++++++++++++ DONE WITH INPUT [" + MemoryDump + "] ++++++++++++++++++++++++++++++ "
    print " ++++++++++++++++++++++++++++++ ALL DONE... Please explore! ++++++++++++++++++++++++++++++"
    print "TOTAL RUNTIME: " + TotalRunTime.Elapsed.ToString() + " (seconds), TOTAL DATA ANALYZED: " + TotalSizeAnalyzed.ToString("N") + " bytes."
    print "SPEED: " + ((TotalSizeAnalyzed / 1024) / ((TotalRunTime.ElapsedMilliseconds / 1000)+1)).ToString("N0") + " KB / second  (all phases aggregate time)"
    return vtero
Esempio n. 14
0
        def Execute(self, recs):
            sw = Stopwatch.StartNew()
            str = None
            if self.Name == 'listweight':
                str = listNPCWeights(recs)
            if self.Name == 'modweight':
                str = modifyNPCWeights(recs)

            if str:
                sw.Stop()
                t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
                toClipboard(__window__, str)
                window = ScriptSupport.CreateTextWindow("Script Output")
                if window:
                    window.Focus()
                    window.SetText(str)
                ScriptSupport.SendStatusText(
                    'Script took %s to complete. List added to clipboard' %
                    t.ToString(), Color.Blue)
Esempio n. 15
0
import startup
import shared.util as util
gameDir = util.getGameDirectory()

import System
from System.Diagnostics import Stopwatch
from System import TimeSpan

sw = Stopwatch.StartNew()

import TESVSnip.Domain
import ListItems
plugins = TESVSnip.Domain.Model.PluginList.All

excludeList = 'RGDL;CLDC;PWAT;SCOL;SCPT;HAIR;REGN;NAVI;WRLD;DIAL;CELL;IMAD;WTHR'.Split(
    ';')
filter = System.Func[str, bool](lambda x: x not in excludeList)

pluginList = util.loadMasterPluginIndex()
from System import Random
rand = Random()
pluginName = pluginList.items()[rand.Next(0, len(pluginList) - 1)][0]
plugins.AddRecord(TESVSnip.Domain.Model.Plugin(gameDir + pluginName, filter))
#plugins.AddRecord(TESVSnip.Domain.Model.Plugin(gameDir + 'skyrim.esm', filter))
print ListItems.generateItemList(plugins)

import ModWeight
print ModWeight.listNPCWeights(plugins)
print ModWeight.modifyNPCWeights(plugins)

sw.Stop()
Esempio n. 16
0
from inVtero.net import *
from inVtero.net.ConsoleUtils import *
from System.IO import Directory, File, FileInfo, Path
from System.Diagnostics import Stopwatch

# Basic option handling
copts = ConfigOptions()
copts.IgnoreSaveData = True
copts.FileName = "C:\\Users\\files\\VMs\\Windows 10 x64-PRO-1703\\Windows 10 x64-PRO-1703-40599dd1.vmem"  
copts.VersionsToEnable = PTType.GENERIC
# To get some additional output 
copts.VerboseOutput = True
copts.VerboseLevel = 1


TotalRunTime = Stopwatch.StartNew()

# since we are not ignoring SaveData, this just get's our state from
vtero = Scan.Scanit(copts)

# Global
CollectKernel = False
newdir = copts.FileName + ".dumped.latest"
topDir = Directory.CreateDirectory(newdir)
Vtero.DiagOutput = False

proc_arr = vtero.Processes.ToArray()
low_proc = proc_arr[0]
for proc in proc_arr:
    if proc.CR3Value < low_proc.CR3Value:
        low_proc = proc
Esempio n. 17
0
def ScanDump(MemoryDump, copts):
    MemoryDumpSize = FileInfo(MemoryDump).Length
    copts.FileName = MemoryDump
    # Check StopWatch
    runTime = Stopwatch.StartNew()
    # since we are not ignoring SaveData, this just get's our state from
    # the underlying protobuf, pretty fast
    vtero = Scan.Scanit(copts)
    proc_arr = vtero.Processes.ToArray()
    low_proc = proc_arr[0]
    for proc in proc_arr:
        if proc.CR3Value < low_proc.CR3Value:
            low_proc = proc
    proc = low_proc
    print "Assumed Kernel Proc: " + proc.ToString()
    vtero.KernelProc = proc
    #vtero.CheckpointSaveState()
    proc.MemAccess = Mem(vtero.MemAccess)
    #swModScan = Stopwatch.StartNew()
    # by default this will scan for kernel symbols
    if vtero.KVS is None:
        kvs = proc.ScanAndLoadModules()
        vtero.KVS = kvs
        vtero.CheckpointSaveState()
    else:
        proc.LoadSymbols()
    #apply some setup
    kMinorVer = proc.GetSymValueLong("NtBuildNumber") & 0xffff
    Console.ForegroundColor = ConsoleColor.Cyan
    print "kernel build: " + kMinorVer.ToString()
    # Use dynamic typing to walk EPROCES
    logicalList = vtero.WalkProcList(proc)
    print "Physical Proc Count: " + proc_arr.Count.ToString()
    #for pproc in proc_arr:
    #    print pproc
    if logicalList is not None:
        print "Logical Proc Count: " + logicalList.Count.ToString()
        for proc in logicalList:
            # This is due to a structure member name change pre win 8
            if proc.Dictionary.ContainsKey("VadRoot.BalancedRoot.RightChild"):
                proc.VadRoot = proc.Dictionary[
                    "VadRoot.BalancedRoot.RightChild"]
            print proc.ImagePath + " : " + proc.Dictionary[
                "Pcb.DirectoryTableBase"].ToString(
                    "X") + " : " + proc.VadRoot.ToString(
                        "X") + " : " + proc.UniqueProcessId.ToString("X")
        Console.ForegroundColor = ConsoleColor.Green
        print "checking that all logical processes exist in the physical list."
        # Miss list mostly bad for yellow printing
        for proc in logicalList:
            found = False
            for hwproc in proc_arr:
                if proc.Dictionary[
                        "Pcb.DirectoryTableBase"] == hwproc.CR3Value:
                    found = True
                    #print "Found logical proc[" + hwproc.CR3Value.ToString("X") + "] in physical array"
            if found == False:
                Console.ForegroundColor = ConsoleColor.Yellow
                if proc.VadRoot == 0:
                    Console.ForegroundColor = ConsoleColor.Green
                    print "An expected, ",
                print "Logical miss for " + proc.ImagePath + " : " + proc.Dictionary[
                    "Pcb.DirectoryTableBase"].ToString(
                        "X") + " : " + proc.VadRoot.ToString(
                            "X") + " : " + proc.UniqueProcessId.ToString("X")
        print "Checking that all physical processes exist in the logical list"
        for hwproc in proc_arr:
            found = False
            for proc in logicalList:
                if proc.Dictionary[
                        "Pcb.DirectoryTableBase"] == hwproc.CR3Value:
                    found = True
                    #print "Found physical proc[" + proc.Dictionary["Pcb.DirectoryTableBase"].ToString("X") + "] in logical array"
            if found == False:
                Console.ForegroundColor = ConsoleColor.Yellow
                hwmiss.append(hwproc)
                print "physical miss for " + hwproc.ToString()
    Console.ForegroundColor = ConsoleColor.White
    print "PART RUNTIME: " + runTime.Elapsed.ToString(
    ) + " (seconds), INPUT DUMP SIZE: " + MemoryDumpSize.ToString(
        "N") + " bytes."
    print "SPEED: " + ((MemoryDumpSize / 1024) /
                       ((runTime.ElapsedMilliseconds / 1000) + 1)).ToString(
                           "N0") + " KB / second  (all phases aggregate time)"
    return vtero
Esempio n. 18
0
                    print "An expected, ",
                print "physical miss for " + proc.ImagePath + " : " + proc.Dictionary[
                    "Pcb.DirectoryTableBase"].ToString(
                        "X") + " : " + proc.VadRoot.ToString(
                            "X") + " : " + proc.UniqueProcessId.ToString("X")
    print "PART RUNTIME: " + runTime.Elapsed.ToString(
    ) + " (seconds), INPUT DUMP SIZE: " + MemoryDumpSize.ToString(
        "N") + " bytes."
    print "SPEED: " + ((MemoryDumpSize / 1024) /
                       ((runTime.ElapsedMilliseconds / 1000) + 1)).ToString(
                           "N0") + " KB / second  (all phases aggregate time)"
    return vtero


# Check StopWatch
TotalRunTime = Stopwatch.StartNew()
TotalSizeAnalyzed = 0

for MemoryDump in MemList:
    print " ++++++++++++++++++++++++++++++ ANALYZING INPUT [" + MemoryDump + "] ++++++++++++++++++++++++++++++ "
    if not File.Exists(MemoryDump):
        print "Can not find dump to analyze: " + MemoryDump
        continue
    vtero = ScanDump(MemoryDump)
    TotalSizeAnalyzed += vtero.FileSize
    print " ++++++++++++++++++++++++++++++ DONE WITH INPUT [" + MemoryDump + "] ++++++++++++++++++++++++++++++ "

print "TOTAL RUNTIME: " + TotalRunTime.Elapsed.ToString(
) + " (seconds), TOTAL DATA ANALYZED: " + TotalSizeAnalyzed.ToString(
    "N") + " bytes."
print "SPEED: " + ((TotalSizeAnalyzed / 1024) /
	def __init__(self):
		#self.name = name
		self.time = Stopwatch.StartNew()
		self.time.Start()
Esempio n. 20
0
    sympath = "SRV*http://msdl.microsoft.com/download/symbols"

# Basic option handling
# This script can be pretty chatty to stdout
#
copts = ConfigOptions()
copts.IgnoreSaveData = False
copts.FileName = MemoryDump
copts.VersionsToEnable = PTType.GENERIC
# To get some additional output
copts.VerboseOutput = True
copts.VerboseLevel = 1
Vtero.VerboseOutput = True
Vtero.DiagOutput = True

runTime = Stopwatch.StartNew()

# since we are not ignoring SaveData, this just get's our state from
# the underlying protobuf, pretty fast
vtero = Scan.Scanit(copts)

proc_arr = vtero.Processes.ToArray()
low_proc = proc_arr[0]
for proc in proc_arr:
    if proc.CR3Value < low_proc.CR3Value:
        low_proc = proc

proc = low_proc

swModScan = Stopwatch.StartNew()
# if we have save state we can skip this entirely