CN114637541A - Operation environment determination method and device - Google Patents

Operation environment determination method and device Download PDF

Info

Publication number
CN114637541A
CN114637541A CN202210284330.2A CN202210284330A CN114637541A CN 114637541 A CN114637541 A CN 114637541A CN 202210284330 A CN202210284330 A CN 202210284330A CN 114637541 A CN114637541 A CN 114637541A
Authority
CN
China
Prior art keywords
file
path
application
detected
private directory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210284330.2A
Other languages
Chinese (zh)
Inventor
焦世春
郝征鹏
蒋宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mashang Xiaofei Finance Co Ltd
Original Assignee
Mashang Xiaofei Finance Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mashang Xiaofei Finance Co Ltd filed Critical Mashang Xiaofei Finance Co Ltd
Priority to CN202210284330.2A priority Critical patent/CN114637541A/en
Publication of CN114637541A publication Critical patent/CN114637541A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4406Loading of operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Stored Programmes (AREA)

Abstract

An embodiment of the specification provides an operation environment determination method and an operation environment determination device, wherein the operation environment determination method comprises the following steps: acquiring a private directory path of an application to be detected; acquiring a file descriptor object, wherein the file descriptor object is generated when a preset file is created and started through a private directory path; acquiring an actual file path of the application to be detected according to the file descriptor object; and determining the running environment of the application to be detected according to the comparison result of the private directory path and the actual file path, thereby accurately detecting the virtual running environment of the tampered path.

Description

Operation environment determination method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for determining an operating environment.
Background
With the development of electronic technology, users increasingly have rich operating requirements for applications on electronic devices. In order to meet part of user requirements, some electronic devices or applications provide a user with an application multi-open function, so that the user can install and run multiple same applications on the same electronic device, and an environment of multi-open applications used by the application multi-open function is called a virtual running environment.
In order to achieve the effect of falseness and falseness, the path can be tampered by part of the applications to avoid being detected to run in the virtual running environment, and the running environment detection accuracy of the applications is reduced.
Disclosure of Invention
The embodiment of the application provides a method and a device for determining an operating environment, so as to improve the accuracy of operating environment detection.
In a first aspect, an embodiment of the present application provides an operating environment determining method, including:
acquiring a private directory path of an application to be detected;
acquiring a file descriptor object, wherein the file descriptor object is generated when a preset file is created and started through a private directory path;
acquiring an actual file path of the application to be detected according to the file descriptor object;
and determining the running environment of the application to be detected according to the comparison result of the private directory path and the actual file path.
In a second aspect, an embodiment of the present application provides an operating environment determining apparatus, including:
the private path acquisition module is used for acquiring a private directory path of the application to be detected;
the system comprises a descriptor object acquisition module, a file storage module and a file management module, wherein the descriptor object acquisition module is used for acquiring a file descriptor object, and the file descriptor object is generated when a preset file is created and started through a private directory path;
the actual path acquisition module is used for acquiring an actual file path of the application to be detected according to the file descriptor object;
and the operation environment determining module is used for determining the operation environment of the application to be detected according to the comparison result of the private directory path and the actual file path.
In a third aspect, an embodiment of the present application provides an operating environment determining apparatus, including: a processor; and a memory configured to store computer-executable instructions that, when executed, cause the processor to perform the execution environment determination method of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium for storing computer-executable instructions, which when executed by a processor implement the execution environment determination method according to the first aspect.
It can be seen that, in the embodiment of the present application, a private directory path of an application to be detected is obtained; acquiring a file descriptor object, wherein the file descriptor object is generated when a preset file is created and started through a private directory path; acquiring an actual file path of the application to be detected according to the file descriptor object; according to the comparison result of the private directory path and the actual file path, the operation environment of the application to be detected is determined, so that the operation of the application to be detected in the virtual operation environment can be accurately detected under the condition that the path is tampered by comparing the private directory path which is possibly tampered with the actual file path, and the detection accuracy of the operation environment is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present specification, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts;
fig. 1 is a first processing flow chart of an operating environment determining method according to an embodiment of the present application;
fig. 2 is a second processing flow chart of an operating environment determining method according to an embodiment of the present application;
fig. 3 is a schematic diagram of an operating environment determining apparatus according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an operating environment determining apparatus according to an embodiment of the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments of the present application, shall fall within the protection scope of the present application.
In practical applications, applications running in a virtual running environment are unstable and intrusive. The virtual operating environment is less secure than the native operating environment. For some applications with high requirements on security, for example, banking applications and security applications, information leakage and information tampering are easily caused when the applications run in the virtual running environment, and there are risks of privacy leakage and economic loss. Therefore, the application provides a running environment determination method to detect the real running environment of the application.
Fig. 1 is a first processing flowchart of an operating environment determining method according to an embodiment of the present disclosure, referring to fig. 1, the operating environment determining method according to the embodiment specifically includes steps S102 to S108.
Step S102, obtaining a private directory path of the application to be detected.
The application to be detected can be an application suitable for an Android system (hereinafter, referred to as Android application for short) or an application suitable for other operating systems. The operating system to which the application to be detected is applicable is not particularly limited by the present description.
Some electronic devices or applications provide a user with an application multi-open function so that the user can install and run a plurality of same applications on the same electronic device, and an environment of multi-open applications used by the application multi-open function is called a virtual running environment. The native operating environment is a concept opposite to the virtual operating environment, the native operating environment may be an operating system of the electronic device, and normally, only one application may be installed in the operating system of the electronic device.
No matter the application to be detected is in the virtual operating environment or the native operating environment, the application may be installed and not operated, or may be installed and operated, which is not described in detail below.
For example, the execution environment determination device executing step S102 may adopt the following instructions:
String dataDir=context.getDataDir().getAbsolutePath();
wherein dataDir refers to a private directory path of the application to be detected.
The application to be detected is specifically described below by taking the application to be detected as an Android application as an example, and applications suitable for other operating systems are similar to the Android application, and the description of the Android application can be referred to.
The application to be detected may be a native application or may be a virtual application.
The ontology application refers to an application installed and used in an Android system, namely an application located in a native operating environment. The virtual application refers to an application installed and used in an Android virtual running environment, namely an application located in the virtual running environment.
When the ontology applications are installed in the Android system, each ontology application has a corresponding private directory, and the private directory is only accessible to the corresponding ontology application. The private directory path of the ontology application refers to the location of the private directory to which the ontology application corresponds.
The private directory of the ontology application may be referred to as a canonical directory, and a private directory path of the ontology application satisfies a predetermined canonical path format, for example, "/data/user/0/package name/". Wherein, "/data/user/0/" is fixed and invariable, and the "package name" can be changed according to the application package name of the ontology application.
For example, if the application package name of the ontology application 1 is "xyz", the private directory path of the ontology application 1 may be "/data/user/0/xyz/", and the application package name of the ontology application 2 is "abc", the private directory path of the ontology application 2 may be "/data/user/0/abc/".
When the virtual applications are installed in the Android virtual running environment, each virtual application has a corresponding private directory, and the private directory is only accessible to the corresponding virtual application. The private directory path of the virtual application refers to the location of the private directory to which the virtual application corresponds.
The private directory of the virtual application is not a canonical directory, nor does the private directory path of the virtual application satisfy a preset canonical path format.
A private directory path for the virtual application, e.g., "/data/user/userId/package name/". Where "/data/user/" is fixed and invariant, "userId" may be a non-zero value, and "package name" may vary according to the application package name of the virtual application.
For example, if the application package name of the virtual application 1 is "xyz", the private directory path of the virtual application 1 may be "/data/user/2/xyz/", and the application package name of the virtual application 2 is "abc", the private directory path of the virtual application 2 may be "/data/user/1/abc/".
The virtual execution environment may include a system-level virtual execution environment and an application-level virtual execution environment. The method for determining the running environment is mainly used for detecting the virtual running environment of the application level.
In the application-level virtual execution environment, a third-party application can be installed, which virtualizes an execution environment for the virtual application to execute. The acquired private directory path of the virtual application may be "/data/user/userId/packet name/" of the third-party application, and the "userId" is a non-zero value, and it may be determined whether the application to be detected is located in the virtual operating environment or the native operating environment by detecting whether the "userId" of the application to be detected is zero. However, in order to achieve the false-false effect, some third-party applications tamper with the path when acquiring the private directory, so as to bypass the detection of the virtual operating environment.
For example, the private directory path of the third-party application is actually "/data/user/2/abc/", but when the operation environment determination device executes the instruction for acquiring the private directory path, the acquired private directory path is the tampered private directory path "/data/user/0/abc/", and then the operation environment determination device determines that the application to be detected operates in the native operation environment according to the "userID", so as to obtain an error detection result. When the application to be detected accesses the files in the private directory path, the files are automatically replaced by the real private directory path "/data/user/2/abc/".
Optionally, after the step S102 is executed, that is, after the private directory path of the application to be detected is acquired, the method for determining the running environment further includes: judging whether the private directory path meets a preset standard path format or not; if not, determining that the running environment of the application to be detected is a virtual running environment; if yes, executing the step of obtaining the file descriptor object.
The private directory path of the application to be detected obtained in step S102 may be a private directory path of the native application, or a private directory path of the virtual application. In the case where the obtained private directory path is a private directory path of the virtual application, the private directory path may or may not be tampered with.
The predetermined canonical path format may be, "/data/user/0/packet name/", for example. Wherein, "/data/user/0/" is fixed and invariable, and the "package name" can be changed according to the application package name of the ontology application. If the obtained private directory path is a private directory path of the virtual application that has not been tampered with, the obtained private directory path may be, for example, "/data/user/userId/package name/", "userId" may be a non-zero value, and "package name" may change according to the application package name of the virtual application.
Whether the private directory path meets the preset standard path format is judged, and whether the userId in the private directory path is 0 is judged.
And if the private directory path does not meet the preset standard path format, determining that the private directory path can be the private directory path of the virtual application which is not tampered, so that the running environment of the application to be detected is determined to be the virtual running environment. In this case, the execution environment of the application to be detected is determined, and it is not necessary to execute step S104 to step S108.
And if the private directory path meets the preset standard path format, determining the private directory path as a private directory path which can be the body application, or a rare directory path of the tampered virtual application. Further, it is necessary to determine the running environment of the application to be detected by executing steps S104 to S108.
Step S104, obtaining a file descriptor object, wherein the file descriptor object is generated when a preset file is created and started through a private directory path.
The preset file may be a blank file, and the file name of the preset file may be preset, for example, "test". The present invention does not particularly limit the file type of the preset file.
The reason why the preset file is created through the private directory path in step S104 is that a file descriptor associated with the private directory path is required to reverse the actual file path. Therefore, the file content and the file type of the preset file have no influence on the invention, and the file descriptor distributed by the kernel for the file can be obtained by starting any one file in the private directory path.
Because the files included in each application to be detected are different, it is difficult to start the same file in the existing files stored in the private directory paths of different applications to be detected. In this step, a new file, i.e. a default file, is created in the private directory path to obtain the file descriptor associated with the private directory path.
Under the condition that the kernel allocates a file descriptor for the preset file, a file descriptor object corresponding to the file descriptor is automatically generated.
It should be emphasized that the "file descriptor" in the present invention refers to a file descriptor allocated by the kernel for the preset file after the preset file is started, and the "file descriptor object" is the same. In case the application to be detected is started: if the preset file is not started, the file descriptor corresponding to the preset file does not exist; if the default file is started, a file descriptor corresponding to the default file exists. The application to be detected is started and is not a trigger condition for triggering the kernel to assign the file descriptor.
In specific implementation, when the private directory path of the application to be detected is obtained, if the application to be detected runs in the native running environment, the real private directory path may be obtained, and if the application to be detected runs in the virtual running environment, the real private directory path may be obtained, and the tampered private directory path may also be obtained. If the private directory path is tampered, the tampered private directory path can be automatically replaced by a real private directory path under the condition that the application to be detected accesses the files in the private directory path.
The following describes the file descriptor specifically:
the concept of fd (File descriptor) is as follows: when an application requests the kernel to open/create a file, the kernel returns a file descriptor for the file that corresponds to the open/created file, with fd essentially a non-negative integer. In effect, it is an index value that points to a table of records that the kernel maintains for each process that the process opens a file. When a program opens an existing file or creates a new file, the kernel returns a file descriptor to the process. In programming, some programming that involves the underlying layers tends to expand around the file descriptors. However, the concept of the file descriptor is usually only applicable to operating systems such as UNIX and Linux, and the Android system is just based on the Linux system.
In other words, each time a file is opened, the kernel returns to the process a corresponding file descriptor, which may be a randomly assigned non-negative integer, e.g., "0", "1", "2" … …, etc. If N files are opened at the same time, the kernel returns N file descriptors with different values to the process, and the N file descriptors can be used for distinguishing the N opened files. For example, when 3 files are opened simultaneously, 3 files include file 1, file 2, and file 3, the kernel returns the corresponding file descriptor "1" to the process when file 1 is started, the kernel returns the corresponding file descriptor "2" to the process when file 2 is started, and the kernel returns the corresponding file descriptor "3" to the process when file 3 is started. Different initiated files correspond to different file descriptors.
Under the condition that no operation for starting the file is executed, the file descriptor does not exist, under the condition that the preset file is created and started, the kernel allocates the file descriptor corresponding to the preset file for the preset file, and the corresponding file descriptor is stored in the specified storage path. The designated memory path may be "/proc/self/fd".
Each file descriptor corresponds to a file descriptor object. The file descriptor object may include a file descriptor and may also include a number of other fields.
Optionally, obtaining the file descriptor object includes: creating a file output stream of the preset file through a private directory path; a file descriptor object is obtained from the file output stream.
Creating the file output stream of the preset file can be regarded as creating and starting the specific implementation operation of the preset file. By creating a file output stream of the preset file, the preset file is started, and the kernel allocates a file descriptor corresponding to the preset file for the preset file, so that a file descriptor object corresponding to the preset file can be acquired.
Illustratively, creating the file output stream may employ the following instructions:
FileOutputStream fos=new FileOutputStream(dataDir+File.separator+"test"
where dataDir refers to a private directory path, file.partner refers to a system default file separator symbol, test is an exemplary file name of a preset file, and fos refers to a file output stream.
When the file output stream is created by the above instruction, the private directory path acquired in step S102 needs to be passed.
The file output stream carries file descriptors and file descriptor objects.
Illustratively, obtaining the file descriptor object may employ the following instructions:
FileDescriptor fileDescriptor=fos.getFD()
wherein, fileDescriptor refers to a file descriptor object, and fos refers to the aforementioned file output stream.
And step S106, acquiring the actual file path of the application to be detected according to the file descriptor object.
The actual file path of the application to be detected may be the location of the private directory of the application to be detected that has not been tampered with.
The position of the private directory of the ontology application is usually not tampered, and the position of the private directory of the virtual application may be tampered or not tampered.
Therefore, the actual file path of the application to be detected may or may not meet the preset standard path format.
Optionally, obtaining an actual file path of the application to be detected according to the file descriptor object includes: obtaining a descriptor field in a file descriptor object through a java reflection mechanism; and acquiring the actual file path of the application to be detected according to the descriptor field.
In the running state, for any one class, all the properties and methods of the class can be known; any method and attribute of any object can be called; this dynamically acquired information and the functionality of the method of dynamically invoking objects is referred to as the reflection mechanism of the java language.
The file descriptor object can be viewed as a closed box, and the fields inside the file descriptor object cannot be directly obtained from the outside. The field value inside the file descriptor object can be obtained through a java reflection mechanism.
The descriptor field may be a descriptor field in a file descriptor object. The descriptor field is used to store a digital representation of the file descriptor, for example, if the file descriptor is "2", then the field value of the descriptor field in the file descriptor object corresponding to the file descriptor "2" is "2".
Optionally, obtaining an actual file path of the application to be detected according to the descriptor field includes: acquiring a file descriptor path according to the descriptor field; and acquiring an actual file path of the application to be detected according to the file descriptor path.
Illustratively, according to the descriptor field, the file descriptor path is obtained, and the following instructions can be adopted:
String fdPath=String.format("/proc/self/fd/%d",descriptor)
wherein, fdPath is a file descriptor path, and descriptor refers to the aforementioned descriptor field.
For example, according to the file descriptor path, the following instruction may be adopted to obtain the actual file path of the application to be detected:
String realPath=Files.readSymbolicLink(Paths.get(fdPath)).toString()
wherein, the realPath refers to an actual file path of the application to be detected, and the fdPath refers to the aforementioned file descriptor path.
It should be noted that in the virtual operating environment, there is a risk that data is tampered, and only through the file descriptor path, the location of the private directory is taken to be a real location that cannot be tampered, i.e., an actual file path. The file descriptor path may be a file descriptor path associated with a private directory path of the application to be detected, e.g., a file descriptor path corresponding to a preset file created in the private directory path.
Obtaining the location of the private directory by other means has a risk of being tampered, for example, directly obtaining the absolute path new File (dataDir) get Absolute Path () through the obtained private directory path, wherein the dataDir may be the private directory path obtainable through step S102.
Optionally, obtaining a file descriptor path according to the descriptor field includes: filling the descriptor field into a path to be filled of a file descriptor directory to obtain a path of the file descriptor; the file descriptor directory is used for storing file descriptors used by the current process.
A file descriptor directory, e.g., "/proc/self/fd/% d", where "/proc/self/fd/" is fixed and invariant, and "% d" may be considered as where the path of the file descriptor directory is to be filled, and a descriptor field may be filled. For example, if the field value of the descriptor field is "12", this "12" is replaced with "% d", and the path of the file descriptor, "/proc/self/fd/12" is obtained.
The file descriptor directory is used for storing file descriptors used by the current process. In general, when several files are opened currently, several file descriptors are used by the current process, and each file descriptor corresponds to one opened file. For example, if 5 applications are currently opened, 5 file descriptors are stored in the file descriptor directory, and the 5 file descriptors are in one-to-one correspondence with the 5 opened applications.
And step S108, determining the running environment of the application to be detected according to the comparison result of the private directory path and the actual file path.
And if the private directory path meets the preset standard path format, determining the private directory path as a private directory path which can be the body application, or a rare directory path of the tampered virtual application. The operation environment of the application to be detected can be determined by comparing the private directory path that satisfies the preset canonical path format with the actual file path obtained through step S106.
If the private directory path does not meet the preset standard path format, the operation environment to be detected can be determined to be a virtual operation environment, and it is not necessary to compare the private directory path with the actual file path.
Optionally, determining the running environment of the application to be detected according to a comparison result between the private directory path and the actual file path, including: if the private directory path is different from the actual file path, determining that the running environment of the application to be detected is a virtual running environment; and if the private directory path is the same as the actual file path, determining that the running environment of the application to be detected is a native running environment.
For example, if the private directory path is "/data/user/0/abc/", the actual file path is "/data/user/2/abc/", and the private directory path is different from the actual file path, it may be determined that the running environment of the application to be detected is the virtual running environment.
For another example, if the private directory path is "/data/user/0/edf/", the actual file path is "/data/user/0/edf/", and the private directory path is the same as the actual file path, it may be determined that the operation environment of the application to be detected is the native operation environment.
In practical applications, for safety reasons, the timing to trigger the operation environment determination method may be set when the application to be detected is started. Specifically, obtaining a private directory path of an application to be detected includes: and under the condition that the application to be detected is detected to be started, acquiring a private directory path of the application to be detected.
The execution time of steps S102-S108 is short, and the execution environment of the application to be detected can be detected quickly. When the operating environment of the application to be detected is determined to be the virtual operating environment, the operation of the application to be detected can be stopped, for example, an icon of the application X to be detected is clicked on a mobile phone to start the application to be detected, and when the operating environment of the application X to be detected is determined to be the virtual operating environment within 2 milliseconds by the operating environment determining method, the operation of the application X to be detected is stopped, and the application X to be detected is forcibly quitted.
Or, in the case that it is determined that the running environment of the application to be detected is the virtual running environment, prompt information of the running environment of the application to be detected may also be generated and displayed, for example, "there is a security risk in the running environment of the application".
By executing the operation environment determination method under the condition that the application to be detected is detected to be started, an unsafe operation environment can be quickly found before the user uses the application to be detected, so that the operation of the application to be detected is stopped, or a safety prompt of the operation environment is sent to the user, so that the safety risk of the application to be detected in the operation process is reduced. For example, a user can detect that a shopping app runs in a virtual running environment within a few milliseconds after just opening the shopping app, and thus prompt "running environment unstable".
On the other hand, considering that different applications have different security requirements on the operating environment, the applications to be detected may be classified into security levels in advance, and different execution trigger timings are set for the operating environment determination methods respectively according to the different security levels.
Specifically, before the step "obtaining the private directory path of the application to be detected" is executed, the method for determining the running environment further includes: under the condition that the application to be detected is detected to be started, acquiring the security level of the application to be detected; and determining the detection trigger condition of the application to be detected according to the security level. The method for acquiring the private directory path of the application to be detected comprises the following steps: and under the condition that the detection triggering condition is determined to be met, acquiring a private directory path of the application to be detected.
For example, for some news applications, a user only performs reading operation without security risk, so that the security requirement of the news applications is low, and the news applications can be classified into a class 1; for some payment applications, operations such as face recognition or password input may be involved, so that the risk of revealing the privacy of the user exists, some marketing activity interaction functions may be provided, the risk is low, and the marketing activity interaction functions can be classified into class 2; for some office-specific applications, the requirement on safety is extremely high, and the office-specific applications can be classified into class 3; the three levels of security rank are: level 1 is less than level 2 is less than level 3.
And aiming at different security levels, respectively setting different execution trigger opportunities for the operation environment determination method, namely setting the corresponding relation between the security level and the detection trigger condition and storing the corresponding relation. For example, if the security level is level 1, it may be determined that the execution environment determination method does not need to be executed; if the security level is level 2, determining the execution trigger time of the operation environment determination method according to the preset risk operation of 'face recognition', namely setting the operation of 'face recognition' to be performed by the application to be detected as the detection trigger condition of the application to be detected; if the security level is level 3, the application to be detected can be started and set as the detection trigger condition of the application to be detected.
Some applications are not affected by the operating environment, and it is not necessary to execute the operating environment determination method; some sensitive operations of the application have security risks, and other non-sensitive operations are not affected by the operating environment, if a user starts the application and only executes the non-sensitive operations, the operating environment detection method is not needed, and the operating environment detection method is only needed to be executed under the condition that the user executes the sensitive operations, so that the security risks in the operating process of the application to be detected are reduced; some applications have extremely high security requirements and it is necessary to determine the operating environment before use in order to avoid running the application in an unsafe operating environment.
The corresponding relation between the security level and the detection triggering condition is preset, the detection triggering condition is determined according to the security level of the application to be detected, and the operation environment determination method is executed under the condition that the detection triggering condition is determined to be met, so that the security requirements of different types of applications to be detected can be flexibly met. In the embodiment of the method shown in fig. 1, a private directory path of an application to be detected is obtained; acquiring a file descriptor object, wherein the file descriptor object is generated when a preset file is created and started through a private directory path; acquiring an actual file path of the application to be detected according to the file descriptor object; according to the comparison result of the private directory path and the actual file path, the operation environment of the application to be detected is determined, so that the operation of the application to be detected in the virtual operation environment can be accurately detected under the condition that the path is tampered by comparing the private directory path which is possibly tampered with the actual file path, and the detection accuracy of the operation environment is improved.
Based on the same technical concept, in combination with fig. 2, the present specification further provides an embodiment of an operation environment determination method. Fig. 2 is a second processing flow chart of an operating environment determining method according to an embodiment of the present application.
As shown in fig. 2, at step S202, a private directory path is obtained.
Step S204, creating a file output stream.
In step S206, a file descriptor object is acquired.
Step S208, obtaining the descriptor field in the file descriptor object through the java reflection mechanism.
In step S210, a file descriptor path is obtained.
In step S212, an actual file path is obtained through the file descriptor path.
In step S214, it is determined whether the actual file path is the same as the private directory path.
If yes, go to step S216, otherwise go to step S218.
In step S216, the operating environment is determined to be a native operating environment.
In step S218, the operating environment is determined to be a virtual operating environment.
An embodiment of an operating environment determining apparatus provided in this specification is as follows:
in the above embodiments, an operation environment determination method is provided, and correspondingly, an operation environment determination apparatus is also provided, which is described below with reference to the accompanying drawings.
Referring to fig. 3, a schematic diagram of an operating environment determining apparatus provided in the present embodiment is shown.
Since the apparatus embodiments correspond to the method embodiments, the description is relatively simple, and reference may be made to the corresponding description of the method embodiments provided above for relevant portions. The device embodiments described below are merely illustrative.
The present embodiment provides an operation environment determination apparatus including:
a private path obtaining module 302, configured to obtain a private directory path of an application to be detected;
a descriptor object obtaining module 304, configured to obtain a file descriptor object, where the file descriptor object is generated when a preset file is created and started through a private directory path;
an actual path obtaining module 306, configured to obtain an actual file path of the application to be detected according to the file descriptor object;
and the running environment determining module 308 is configured to determine the running environment of the application to be detected according to a comparison result between the private directory path and the actual file path.
An embodiment of an operating environment determining apparatus provided in this specification is as follows:
based on the same technical concept, an embodiment of the present application further provides an operating environment determining device, where the operating environment determining device is configured to execute the operating environment determining method, and fig. 4 is a schematic structural diagram of the operating environment determining device provided in the embodiment of the present application.
An operating environment determining apparatus provided in this embodiment includes:
as shown in fig. 4, the runtime environment determination device may have a relatively large difference due to different configurations or performances, and may include one or more processors 401 and a memory 402, where one or more stored applications or data may be stored in the memory 402. Wherein memory 402 may be transient or persistent. The application program stored in memory 402 may include one or more modules (not shown), each of which may include a series of computer-executable instructions in the operating environment determining device. Still further, the processor 401 may be configured to communicate with the memory 402 to execute a series of computer-executable instructions in the memory 402 on the runtime environment determination device. The operating environment determining apparatus may also include one or more power supplies 403, one or more wired or wireless network interfaces 404, one or more input/output interfaces 405, one or more keyboards 406, and the like.
In one particular embodiment, the execution environment determination device includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the execution environment determination device, and the one or more programs configured to be executed by the one or more processors include computer-executable instructions for:
acquiring a private directory path of an application to be detected;
acquiring a file descriptor object, wherein the file descriptor object is generated when a preset file is created and started through a private directory path;
acquiring an actual file path of the application to be detected according to the file descriptor object;
and determining the running environment of the application to be detected according to the comparison result of the private directory path and the actual file path.
This specification provides one example of a computer-readable storage medium, comprising:
based on the same technical concept, the embodiment of the present application further provides a computer-readable storage medium corresponding to the above-described operating environment determining method.
The present embodiments provide a computer-readable storage medium for storing computer-executable instructions, which when executed by a processor implement the following process:
acquiring a private directory path of an application to be detected;
acquiring a file descriptor object, wherein the file descriptor object is generated when a preset file is created and started through a private directory path;
acquiring an actual file path of the application to be detected according to the file descriptor object;
and determining the running environment of the application to be detected according to the comparison result of the private directory path and the actual file path.
It should be noted that the embodiment of the computer-readable storage medium in this specification and the embodiment of the operating environment determination method in this specification are based on the same inventive concept, and therefore, specific implementation of this embodiment may refer to implementation of the foregoing corresponding method, and repeated details are not described again.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description may take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The description has been presented with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the description. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable operating environment determining apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable operating environment determining apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable execution environment determining apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable execution environment determination device to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Embodiments of the application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present document and is not intended to limit the present document. Various modifications and changes may occur to those skilled in the art from this document. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of this document shall be included in the scope of the claims of this document.

Claims (10)

1. An operating environment determination method, comprising:
acquiring a private directory path of an application to be detected;
acquiring a file descriptor object, wherein the file descriptor object is generated when a preset file is created and started through the private directory path;
acquiring an actual file path of the application to be detected according to the file descriptor object;
and determining the running environment of the application to be detected according to the comparison result of the private directory path and the actual file path.
2. The method of claim 1, wherein obtaining the file descriptor object comprises:
creating a file output stream of the preset file through the private directory path;
and acquiring the file descriptor object from the file output stream.
3. The method according to claim 1, wherein the obtaining the actual file path of the application to be detected according to the file descriptor object comprises:
obtaining a descriptor field in the file descriptor object through a java reflection mechanism;
and acquiring the actual file path of the application to be detected according to the descriptor field.
4. The method according to claim 3, wherein the obtaining the actual file path of the application to be detected according to the descriptor field comprises:
acquiring a file descriptor path according to the descriptor field;
and acquiring the actual file path of the application to be detected according to the file descriptor path.
5. The method of claim 4, wherein obtaining a file descriptor path according to the descriptor field comprises:
filling the descriptor field into a path to be filled of a file descriptor directory to obtain a path of the file descriptor; the file descriptor directory is used for storing the file descriptors used by the current process.
6. The method according to claim 1, wherein determining the operating environment of the application to be detected according to the comparison result between the private directory path and the actual file path comprises:
if the private directory path is different from the actual file path, determining that the running environment of the application to be detected is a virtual running environment;
and if the private directory path is the same as the actual file path, determining that the running environment of the application to be detected is a native running environment.
7. The method according to claim 6, wherein after obtaining the private directory path of the application to be detected, the method further comprises:
judging whether the private directory path meets a preset standard path format or not;
if not, determining that the running environment of the application to be detected is a virtual running environment;
if yes, executing the step of obtaining the file descriptor object.
8. An operating environment determination apparatus, characterized in that the apparatus comprises:
the private path acquisition module is used for acquiring a private directory path of the application to be detected;
a descriptor object obtaining module, configured to obtain a file descriptor object, where the file descriptor object is generated when a preset file is created and started through the private directory path;
the actual path acquisition module is used for acquiring an actual file path of the application to be detected according to the file descriptor object;
and the running environment determining module is used for determining the running environment of the application to be detected according to the comparison result of the private directory path and the actual file path.
9. An operation environment determination device characterized in that the device comprises:
a processor; and a memory configured to store computer-executable instructions that, when executed, cause the processor to perform the execution environment determination method of any of claims 1-7.
10. A computer-readable storage medium for storing computer-executable instructions which, when executed by a processor, implement the execution environment determination method of any one of claims 1-7.
CN202210284330.2A 2022-03-22 2022-03-22 Operation environment determination method and device Pending CN114637541A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210284330.2A CN114637541A (en) 2022-03-22 2022-03-22 Operation environment determination method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210284330.2A CN114637541A (en) 2022-03-22 2022-03-22 Operation environment determination method and device

Publications (1)

Publication Number Publication Date
CN114637541A true CN114637541A (en) 2022-06-17

Family

ID=81950179

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210284330.2A Pending CN114637541A (en) 2022-03-22 2022-03-22 Operation environment determination method and device

Country Status (1)

Country Link
CN (1) CN114637541A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103605674A (en) * 2008-11-10 2014-02-26 谷歌公司 File system access for WEB applications and native code modules
CN110427758A (en) * 2019-08-08 2019-11-08 北京智游网安科技有限公司 Position cheat detecting method, intelligent terminal and storage medium
CN111027054A (en) * 2019-11-15 2020-04-17 武汉极意网络科技有限公司 Method and system for judging running of application program in multi-open environment based on android system
CN111538985A (en) * 2020-01-22 2020-08-14 中国银联股份有限公司 Android application running environment detection method and device
CN112245933A (en) * 2020-11-11 2021-01-22 福建天晴数码有限公司 Method and system for detecting android operation multi-open environment
CN112883370A (en) * 2019-11-29 2021-06-01 北京三快在线科技有限公司 Application program state detection method and device, storage medium and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103605674A (en) * 2008-11-10 2014-02-26 谷歌公司 File system access for WEB applications and native code modules
CN110427758A (en) * 2019-08-08 2019-11-08 北京智游网安科技有限公司 Position cheat detecting method, intelligent terminal and storage medium
CN111027054A (en) * 2019-11-15 2020-04-17 武汉极意网络科技有限公司 Method and system for judging running of application program in multi-open environment based on android system
CN112883370A (en) * 2019-11-29 2021-06-01 北京三快在线科技有限公司 Application program state detection method and device, storage medium and electronic equipment
CN111538985A (en) * 2020-01-22 2020-08-14 中国银联股份有限公司 Android application running environment detection method and device
CN112245933A (en) * 2020-11-11 2021-01-22 福建天晴数码有限公司 Method and system for detecting android operation multi-open environment

Similar Documents

Publication Publication Date Title
RU2727063C1 (en) Service processing method and device
CN109062582B (en) Encryption method and device for application installation package
CN112560022B (en) Method and device for detecting system interface call
CN106897607B (en) Application program monitoring method and device
CN115378735B (en) Data processing method and device, storage medium and electronic equipment
US11709931B2 (en) Shadow stack violation enforcement at module granularity
CN115185534A (en) Data desensitization method and device, readable storage medium and electronic equipment
WO2021146988A1 (en) Method and apparatus for protecting smart contracts against attacks
CN111506500B (en) Memory leakage detection method and device, electronic equipment and readable storage medium
CN114091099A (en) Authority hierarchical control method, equipment and storage medium for business system
CN114327791B (en) Virtualization-based trusted computing measurement method, device, equipment and storage medium
CN114637541A (en) Operation environment determination method and device
CN109976769B (en) Method, device and equipment for determining server identification corresponding to application installation package
CN115659340B (en) Counterfeit applet identification method and device, storage medium and electronic equipment
CN111813460A (en) Access method, device, equipment and storage medium for application program matching file
CN111190692A (en) Monitoring method and system based on Roc processor and readable medium
CN111078435A (en) Service processing method and device and electronic equipment
CN110941443A (en) Method and device for modifying file name in SDK and electronic equipment
CN115935373A (en) Method and apparatus for protecting operating system kernel
CN113220314B (en) APP resource loading and APK generation method, device, equipment and medium
CN110443051B (en) Method for preventing confidential documents from spreading on Internet
CN115828247B (en) Method, device and equipment for detecting abnormality of applet and readable storage medium
CN113312613A (en) Container creation method, container deletion method, device and equipment
CN110569644A (en) Call request processing method, call request processing device, call function calling device and call request calling equipment
CN111090425A (en) Program packaging method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination