def main(type_, path):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    with Namespace(c, "root\\subscription") as ns:
        for binding in ns.class_("__filtertoconsumerbinding").instances:
            print("binding: ", binding)
            filterref = binding.properties["Filter"].value
            consumerref = binding.properties["Consumer"].value
            filter = ns.get(ns.parse_object_path(filterref))
            consumer = ns.get(ns.parse_object_path(consumerref))

            print("  filter: ", filter)
            try:
                print("    language: ",
                      filter.properties["QueryLanguage"].value)
                print("    query: ", filter.properties["Query"].value)
            except IndexError:
                print("    not found.")

            print("  consumer: ", consumer)
            try:
                if "CommandLineTemplate" in consumer.properties:
                    print("    payload: ",
                          consumer.properties["CommandLineTemplate"].value)
            except IndexError:
                print("    not found.")
def main(type_, path):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    with Namespace(c, "root") as ns:
        test(ns, "cimv2", ObjectPath("localhost", "root\\cimv2", "", {}))
        test(ns, "//./root/cimv2",
             ObjectPath("localhost", "root\\cimv2", "", {}))
        test(ns, "\\\\.\\root\\cimv2",
             ObjectPath("localhost", "root\\cimv2", "", {}))
        test(ns, "//HOSTNAME/root/cimv2",
             ObjectPath("HOSTNAME", "root\\cimv2", "", {}))
        test(ns, "winmgmts://./root/cimv2",
             ObjectPath("localhost", "root\\cimv2", "", {}))

    with Namespace(c, "root\\cimv2") as ns:
        test(ns, "Win32_Service",
             ObjectPath("localhost", "root\\cimv2", "Win32_Service", {}))
        test(ns, "//./root/cimv2:Win32_Service",
             ObjectPath("localhost", "root\\cimv2", "Win32_Service", {}))
        test(
            ns, "Win32_Service.Name='Beep'",
            ObjectPath("localhost", "root\\cimv2", "Win32_Service",
                       {"Name": "Beep"}))
        test(
            ns, "//./root/cimv2:Win32_Service.Name='Beep'",
            ObjectPath("localhost", "root\\cimv2", "Win32_Service",
                       {"Name": "Beep"}))
    print("Tests: OK")
Beispiel #3
0
def main(type_, path):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    tree = Tree(c)
    rec_namespace(tree.root)
Beispiel #4
0
def main(type_, path, pageNum=None):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    p = Printer(c)
    p.printKeys()
def main(type_, path):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    Values = ["FolderPath","ExplorerFileName","FileSize","LastUserName","LastUsedTime","TimeZoneOffset","LaunchCount","OriginalFileName","FileDescription","CompanyName","ProductName","ProductVersion","FileVersion","AdditionalProductCodes","msiVersion","msiDisplayName","ProductCode","SoftwarePropertiesHash","ProductLanguage","FilePropertiesHash","msiPublisher"]
    print("\t".join(Values))

    c = CIM(type_, path)
    try:
        with Namespace(c, "root\\ccm\\SoftwareMeteringAgent") as ns:
            for RUA in ns.class_("CCM_RecentlyUsedApps").instances:
                RUAValues = []
                for Value in Values:
                    try:
                       if Value == "LastUsedTime":
                           Time = str(RUA.properties[Value].value)
                           ExcelTime = "{}-{}-{} {}:{}:{}".format(Time[0:4],Time[4:6],Time[6:8],Time[8:10],Time[10:12],Time[12:14])
                           RUAValues.append(ExcelTime)
                       elif Value == "TimeZoneOffset":
                           TimeOffset = '="{}"'.format(Time[-4:])
                           RUAValues.append(TimeOffset)
                       else:
                           RUAValues.append(str(RUA.properties[Value].value))
                    except KeyError:
                        RUAValues.append("")
                print("\t".join(RUAValues))
    except IndexError:
        raise RuntimeError("CCM Software Metering Agent path 'root\\\\ccm\\\\SoftwareMeteringAgent' not found.")
def main(type_, path, SQLite_DB_Name):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    Values = [
        "FolderPath", "ExplorerFileName", "FileSize", "LastUserName",
        "LastUsedTime", "TimeZoneOffset", "LaunchCount", "OriginalFileName",
        "FileDescription", "CompanyName", "ProductName", "ProductVersion",
        "FileVersion", "AdditionalProductCodes", "msiVersion",
        "msiDisplayName", "ProductCode", "SoftwarePropertiesHash",
        "ProductLanguage", "FilePropertiesHash", "msiPublisher"
    ]
    #print("\t".join(Values))

    try:
        os.remove(SQLite_DB_Name)
    except:
        print("File does not exist")

    con = sqlite3.connect(SQLite_DB_Name)
    # Create the table
    #con.execute("Pragma journal_mode=wal")
    con.execute(
        "CREATE TABLE IF NOT EXISTS recently_used(FolderPath text, ExplorerFileName text, FileSize text, LastUserName text, LastUsedTime text, TimeZoneOffset text, LaunchCount text, OriginalFileName text, FileDescription text, CompanyName text, ProductName text, ProductVersion text, FileVersion text, AdditionalProductCodes text, msiVersion text, msiDisplayName text, ProductCode text, SoftwarePropertiesHash text, ProductLanguage text, FilePropertiesHash text, msiPublisher text)"
    )

    c = CIM(type_, path)
    try:
        with Namespace(c, "root\\ccm\\SoftwareMeteringAgent") as ns:
            for RUA in ns.class_("CCM_RecentlyUsedApps").instances:
                RUAValues = []
                for Value in Values:
                    try:
                        if Value == "LastUsedTime":
                            Time = str(RUA.properties[Value].value)
                            ExcelTime = "{}-{}-{} {}:{}:{}".format(
                                Time[0:4], Time[4:6], Time[6:8], Time[8:10],
                                Time[10:12], Time[12:14])
                            RUAValues.append(ExcelTime)
                        elif Value == "TimeZoneOffset":
                            TimeOffset = '="{}"'.format(Time[-4:])
                            RUAValues.append(TimeOffset)
                        else:
                            RUAValues.append(str(RUA.properties[Value].value))
                    except KeyError:
                        RUAValues.append("")
                # Fill table
                sql_data = "','".join(RUAValues)
                sql_statement = "insert into recently_used values ('" + sql_data + "')"
                #print (sql_statement)
                con.execute(sql_statement)

                #con.executemany("REPLACE INTO recently_used VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", RUAValues)
                #con.commit()

                #print("\t".join(RUAValues))
        con.commit()
    except IndexError:
        print("Error In Run Exiting")
Beispiel #7
0
def main(type_, path, *s):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    i = Index(c.cim_type, c.logical_index_store)
    for ss in s:
        print("XX_%s\t%s" % (str(i.hash(ss.encode("utf-16le"))), str(ss)))
Beispiel #8
0
def main(type_, path, key):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    k = Key("__." + key)
    sys.stdout.buffer.write(c.logical_data_store.get_object_buffer(k))
    sys.stdout.flush()
Beispiel #9
0
def main(type_, path):
    logging.basicConfig(level=logging.INFO)
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)

    index = Index(c.cim_type, c.logical_index_store)
    object_resolver = ObjectResolver(c, index)
    ctx = Context(c, index, object_resolver)

    app = QApplication(sys.argv)
    screen = CimUiForm(ctx)
    screen.show()
    sys.exit(app.exec_())
Beispiel #10
0
def main(type_, path, namespaceName, className, key_specifier=None):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    index = Index(c.cim_type, c.logical_index_store)
    o = ObjectResolver(c, index)

    cd = o.get_cd(namespaceName, className)
    cl = o.get_cl(namespaceName, className)

    instances = []
    if key_specifier:
        key_values = key_specifier.split(",")
        key = InstanceKey()
        for key_value in key_values:
            if "=" not in key_value:
                raise RuntimeError("Invalid key specifier: " + str(key_value))
            k, _, v = key_value.partition("=")
            key[k] = v
        print(str(key))
        ci = o.get_ci(namespaceName, className, key)
        instances.append(ci)

    else:
        for instance in o.get_cd_children_ci(namespaceName, className):
            ci = o.get_ci(namespaceName, className, instance.instance_key)
            instances.append(ci)

    for instance in instances:
        print("%s" % "=" * 80)
        #print(compute_instance_hash(index, instance))
        try:
            print(
                dump_instance(instance,
                              encoding='ascii',
                              encoding_errors='ignore'))
        except:
            print("ERROR: failed to dump class instance!")
            print(traceback.format_exc())
Beispiel #11
0
def main(type_, path, namespaceName, className):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    i = Index(c.cim_type, c.logical_index_store)
    o = ObjectResolver(c, i)

    while className != "":
        print("%s" % "=" * 80)
        print("namespace: %s" % namespaceName)
        try:
            cd = o.get_cd(namespaceName, className)
        except IndexError:
            print("ERROR: failed to find requested class definition")
            return
        cl = o.get_cl(namespaceName, className)
        try:
            print(dump_definition(cd, cl))
        except:
            print("ERROR: failed to dump class definition!")
            print(traceback.format_exc())
        className = cd.super_class_name
Beispiel #12
0
def main(type_, path, page_number=None):
    if type_ not in ("xp", "win7"):
        raise RuntimeError("Invalid mapping type: {:s}".format(type_))

    c = CIM(type_, path)
    g = Grapher(c)

    root = c.logical_index_store.root_page
    #print(root)
    #print(root.tree())

    #print(root.get_key(0))
    #print(root.get_key(1))
    #print(root.get_child(0))
    #print(root.get_child(1))

    if page_number is None:
        g.graph_index()
    else:
        page_number = int(page_number)
        i = c.logical_index_store
        p = i.get_page(page_number)
        g.graph_index_from_page(p)