CN110807200A - Log encryption method, system, device and medium for Android device - Google Patents

Log encryption method, system, device and medium for Android device Download PDF

Info

Publication number
CN110807200A
CN110807200A CN201911032259.3A CN201911032259A CN110807200A CN 110807200 A CN110807200 A CN 110807200A CN 201911032259 A CN201911032259 A CN 201911032259A CN 110807200 A CN110807200 A CN 110807200A
Authority
CN
China
Prior art keywords
log
ciphertext
encryption
android
write
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
CN201911032259.3A
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.)
Fuzhou Humanpool Bo Information Technology Co Ltd
Original Assignee
Fuzhou Humanpool Bo Information Technology 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 Fuzhou Humanpool Bo Information Technology Co Ltd filed Critical Fuzhou Humanpool Bo Information Technology Co Ltd
Priority to CN201911032259.3A priority Critical patent/CN110807200A/en
Publication of CN110807200A publication Critical patent/CN110807200A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a log encryption method, a log encryption system, log encryption equipment and a log encryption medium for Android equipment, wherein the method comprises the following steps: step S1, obtaining an encryption algorithm by the persistence. Step S2, encrypting the [ log msg ] text in the plaintext format into a ciphertext through the encryption algorithm and the encryption key; and step S3, writing the [ log msg ] text encrypted into the ciphertext into LogBuffer through the socket of/dev/socket/logdw.

Description

Log encryption method, system, device and medium for Android device
Technical Field
The invention relates to the field of information encryption, in particular to an Android device information encryption method, system, device and medium.
Background
The adb port of the existing android device is easy to open, and log information often contains sensitive information, such as an account number, a password, a position, a contact person, a short message and the like. As long as the adb port of the Android device is opened, others can acquire log information of the Android mobile phone through the adb logcat related instruction. If the POS equipment of the android, the bank APP and the like are sensitive to user information, the information can be easily leaked out through log.
The reason is that:
1. first, the Android log get common instruction is publicly known, i.e., Logcat is an instruction used by an Android device to get the Android log.
adb logcat-b<buffer>,
Such as adb logcat-b radio,
the radio buffer correlation log is output.
Logcat Command List:
Figure BDA0002250499620000011
Figure BDA0002250499620000021
Figure BDA0002250499620000031
2. secondly, the log output actual format is relatively fixed and is a plaintext format:
the general default output log FORMAT FORMAT _ BRIEF: [ time ] [ log priority ]/[ tag ] [ pid ] [ logmsg ].
Such as: log:
08-10 08:47:12.878D/RILD(298):**RIL Daemon Started**
then:
[time]:08-10 08:47:12.878
[log priority]:D
[tag]:RILD
[pid]:298
[log msg]:RIL Daemon Started*
note that PID: process ID is a process ID.
3. And the interface function of the Android log frame directly writes the plaintext into the LogBuffer through the/dev/socket/logdw socket.
As shown in fig. 1, the Android log system framework is roughly divided into three parts:
(1) upper layer interfaces such as ALOGD, log.d, etc.
(2) A liblog library;
(3) logd service.
In the Android frame, files such as log, java and the like provide an interface used by an upper layer application, interfaces such as macro interface ALOGD and ALOGE defined in system \ core \ end \ log \ log.h are used in native or jni code, and the two interfaces respectively call Android _ log _ buf _ write () functions (calls of log, java, rlog.java) and __ Android _ log _ write () functions (calls of ALOGD) of log _ write.cpp files in the liblog, but both the two functions finally call the write _ to _ log () function. And then writing into LogBuffer through/dev/socket/logdw socket.
According to the three points, the Log of the existing android device is in a plaintext state, so once the adb port is opened, others can acquire the Log through a logcat instruction, and information of the android device is leaked.
Disclosure of Invention
The technical problem to be solved by the invention is to provide a method, a system, equipment and a medium for encrypting the Android device log, so as to encrypt the log information of the Android device and effectively protect the privacy information in the log information.
In a first aspect, the invention provides a log encryption method for an Android device, which includes:
step S1, after the android _ log _ buf _ write () function and __ android _ log _ write () call the write _ to _ log () function, obtaining an encryption algorithm through persistence.
Step S2, encrypting the [ log msg ] text in the plaintext format into a ciphertext through the encryption algorithm and the encryption key;
and step S3, writing the [ log msg ] text encrypted into the ciphertext into LogBuffer through the socket of/dev/socket/logdw.
In a second aspect, the present invention provides a log encryption system for an Android device, including:
an obtaining module, after the android _ log _ buf _ write () function and the __ android _ log _ write () call the write _ to _ log () function, for obtaining an encryption algorithm through persistence.
The encryption module is used for encrypting the [ log msg ] text in the plaintext format into a ciphertext through the encryption algorithm and the encryption key;
and the socket module is used for writing the [ log msg ] text encrypted into the ciphertext into the LogBuffer through/dev/socket/logdw.
In a third aspect, the present invention provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of the first aspect when executing the program.
In a fourth aspect, the invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of the first aspect.
One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages:
according to the method, the device, the equipment and the medium, after the android _ log _ buf _ write () function and the __ android _ log _ write () function call the write _ to _ log () function, the encryption algorithm and the encryption key are obtained; encrypting a [ log msg ] text in a plaintext format into a ciphertext; therefore, the Android log obtained by the application or the adb port through logcat is in a ciphertext format, and the log information safety is protected. In addition, the embodiment of the application also enhances the convenience, safety and reliability of the ciphertext by customizing the ciphertext format; by adding ciphertext head and tail: the starting position and the ending position of the ciphertext can be distinguished more easily, on one hand, the analysis is convenient, on the other hand, the safety can be enhanced, so that the log is not easy to decrypt under the condition that other people do not know the format; and by adding the check bit, whether the ciphertext is lost in the transmission process is conveniently identified, and the reliability of text transmission is enhanced.
Drawings
The invention will be further described with reference to the following examples with reference to the accompanying drawings.
Fig. 1 is a schematic diagram of a framework of a conventional Android log system.
FIG. 2 is a schematic diagram of a framework of an Android log system of the present invention.
Fig. 3 is a flowchart of a log encryption method for an Android device in an embodiment of the present invention.
Fig. 4 is a structural block diagram of a log encryption system of an Android device in the second embodiment of the present invention.
Fig. 5 is a schematic structural diagram of an electronic device according to a third embodiment of the invention;
fig. 6 is a schematic structural diagram of a medium according to a fourth embodiment of the present invention.
Detailed Description
According to the method, the device, the equipment and the medium provided by the embodiment of the application, the [ log msg ] text in the plaintext format is encrypted into the ciphertext; therefore, the Android log obtained by the application or the adb port through logcat is in a ciphertext format, and the log information safety is protected.
The technical scheme in the embodiment of the application has the following general idea:
acquiring an encryption algorithm and an encryption key after the android _ log _ buf _ write () function and the __ android _ log _ write () call the write _ to _ log () function; encrypting a [ log msg ] text in a plaintext format into a ciphertext; and writing the socket into a LogBuffer through the socket of/dev/socket/logdw.
Before the specific embodiment is introduced, a frame of an Android log corresponding to the method of the embodiment of the application is introduced. In various write log methods of the Android device, log texts are finally written into a LogBuffer through a/dev/socket/logdw socket. The encryption process for log text needs to be preceded by a write logdwsocket. Therefore, the framework of the traditional Android log system is modified as follows, and as shown in fig. 2, the modified framework of the Android log system specifically includes the following aspects:
(1) in the Android frame, files such as log, java and the like provide an interface used by an upper layer application, interfaces such as macro interface ALOGD and ALOGE defined in system \ core \ include \ log \ log.h are used in native or jni code, the two interfaces respectively call __ Android _ log _ buf _ write () functions (calls of log, java, rlog. java) and __ Android _ log _ write () functions (calls of ALOGD) of log _ write. cpp files in the liblog,
(2) both functions eventually call the write _ to _ log () function.
(3) Obtaining encryption key and encryption algorithm, executing encryption, changing plaintext into ciphertext
(4) And then writing into LogBuffer through/dev/socket/logdw socket.
Example one
The embodiment provides a log encryption method for an Android device, which may be specifically described as the following process:
step S1, after the android _ log _ buf _ write () function and __ android _ log _ write () call the write _ to _ log () function, obtaining an encryption algorithm through persistence. The invention supports a plurality of encryption algorithms such as SHA1, MD5, HMAC, AES, RC4, Rabbit, Base64 and the like. As values obtained for persist. 1-7, the specific meanings are as follows 1: SHA1, 2: MD5, 3: HMAC, 4: AES, 5: RC4, 6: rabbit, 7: base 64; and a string of 8-bit numbers of the encryption key;
step S2, encrypting the [ log msg ] text in the plaintext format into a ciphertext through the encryption algorithm and the encryption key; the default output log FORMAT is generally the FORMAT _ BRIEF [ time ] [ log priority ]/[ tag ] [ log msg ], so only the string of text is encrypted, and only the string of information contains private information.
Then customizing a ciphertext format; the ciphertext format is: header + Length + ciphertext + check bit + End;
wherein the content of the first and second substances,
header is start bit 0x 0A;
length is the ciphertext Length;
the algorithm of the check bit is as follows: carrying out XOR calculation on the data one by adopting ciphertext XOR sum;
end is the End bit 0x 0B.
And step S3, writing the [ log msg ] text encrypted into the ciphertext into LogBuffer through the socket of/dev/socket/logdw.
Based on the same inventive concept, the application also provides a device corresponding to the method in the first embodiment, which is detailed in the second embodiment.
Example two
In this embodiment, a log encryption system of an Android device is provided, including:
an obtaining module, after the android _ log _ buf _ write () function and the __ android _ log _ write () call the write _ to _ log () function, for obtaining an encryption algorithm through persistence.
The encryption module is used for encrypting the [ log msg ] text in the plaintext format into a ciphertext through the encryption algorithm and the encryption key; the default output log FORMAT is generally the FORMAT _ BRIEF [ time ] [ log priority ]/[ tag ] [ log msg ], so that only the string of text [ log msg ] needs to be encrypted, since only this string of information will contain private information.
Also for customizing the ciphertext format; the ciphertext format is: header + Length + ciphertext + check bit + End;
wherein the content of the first and second substances,
header is start bit 0x 0A;
length is the ciphertext Length;
the algorithm of the check bit is as follows: carrying out XOR calculation on the data one by adopting ciphertext XOR sum;
end is the End bit 0x 0B.
And the socket module is used for writing the [ log msg ] text encrypted into the ciphertext into the LogBuffer through/dev/socket/logdw.
Based on the same inventive concept, the application provides an electronic device embodiment corresponding to the first embodiment, which is detailed in the third embodiment.
EXAMPLE III
The embodiment provides an electronic device, specifically an Android device, and as shown in fig. 5, the electronic device includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and when the processor executes the computer program, any one of the embodiments may be implemented.
Since the electronic device described in this embodiment is a device used for implementing the method in the first embodiment of the present application, based on the method described in the first embodiment of the present application, a specific implementation of the electronic device in this embodiment and various variations thereof can be understood by those skilled in the art, and therefore, how to implement the method in the first embodiment of the present application by the electronic device is not described in detail herein. The equipment used by those skilled in the art to implement the methods in the embodiments of the present application is within the scope of the present application.
Based on the same inventive concept, the application provides a storage medium corresponding to the fourth embodiment, which is described in detail in the fourth embodiment.
Example four
The present embodiment provides a computer-readable storage medium, as shown in fig. 6, on which a computer program is stored, and when the computer program is executed by a processor, any one of the embodiments can be implemented.
In summary, the invention has the following advantages: according to the invention, through log encryption, the Android log obtained by the application or adb port through logcat is in a ciphertext format, so that the information security of the log is protected. The invention also enhances the convenience, safety and reliability of the ciphertext by customizing the ciphertext format; by adding ciphertext head and tail: the starting position and the ending position of the ciphertext can be distinguished more easily, on one hand, the analysis is convenient, on the other hand, the safety can be enhanced, so that the log is not easy to decrypt under the condition that other people do not know the format; and by adding the check bit, whether the ciphertext is lost in the transmission process is conveniently identified, and the reliability of text transmission is enhanced.
Although specific embodiments of the invention have been described above, it will be understood by those skilled in the art that the specific embodiments described are illustrative only and are not limiting upon the scope of the invention, and that equivalent modifications and variations can be made by those skilled in the art without departing from the spirit of the invention, which is to be limited only by the appended claims.

Claims (8)

1. A log encryption method of an Android device is characterized by comprising the following steps: the method comprises the following steps:
step S1, after the android _ log _ buf _ write () function and __ android _ log _ write () call the write _ to _ log () function, obtaining an encryption algorithm through persistence.
Step S2, encrypting the [ log msg ] text in the plaintext format into a ciphertext through the encryption algorithm and the encryption key;
and step S3, writing the [ log msg ] text encrypted into the ciphertext into LogBuffer through the socket of/dev/socket/logdw.
2. The log encryption method for the Android device of claim 1, comprising: in step S2, after encrypting the [ log msg ] text into the ciphertext, the method further includes: and customizing the ciphertext format.
3. The log encryption method for the Android device of claim 2, comprising: the ciphertext format is: header + Length + ciphertext + check bit + End; wherein the content of the first and second substances,
header is start bit 0x 0A;
length is the ciphertext Length;
the algorithm of the check bit is as follows: carrying out XOR calculation on the data one by adopting ciphertext XOR sum;
end is the End bit 0x 0B.
4. The log encryption system of the Android device is characterized in that: the method comprises the following steps:
an obtaining module, after the android _ log _ buf _ write () function and the __ android _ log _ write () call the write _ to _ log () function, for obtaining an encryption algorithm through persistence.
The encryption module is used for encrypting the [ log msg ] text in the plaintext format into a ciphertext through the encryption algorithm and the encryption key;
and the socket module is used for writing the [ log msg ] text encrypted into the ciphertext into the LogBuffer through/dev/socket/logdw.
5. The log encryption system of the Android device of claim 4, wherein: the encryption module is also used for customizing a ciphertext format.
6. The log encryption system of the Android device of claim 4, wherein: the ciphertext format is: header + Length + ciphertext + check bit + End; wherein the content of the first and second substances,
header is start bit 0x 0A;
length is the ciphertext Length;
the algorithm of the check bit is as follows: carrying out XOR calculation on the data one by adopting ciphertext XOR sum;
end is the End bit 0x 0B.
7. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 3 when executing the program.
8. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 3.
CN201911032259.3A 2019-10-28 2019-10-28 Log encryption method, system, device and medium for Android device Pending CN110807200A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911032259.3A CN110807200A (en) 2019-10-28 2019-10-28 Log encryption method, system, device and medium for Android device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911032259.3A CN110807200A (en) 2019-10-28 2019-10-28 Log encryption method, system, device and medium for Android device

Publications (1)

Publication Number Publication Date
CN110807200A true CN110807200A (en) 2020-02-18

Family

ID=69489380

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911032259.3A Pending CN110807200A (en) 2019-10-28 2019-10-28 Log encryption method, system, device and medium for Android device

Country Status (1)

Country Link
CN (1) CN110807200A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103561045A (en) * 2013-11-21 2014-02-05 北京网秦天下科技有限公司 Safety monitoring system and method for Android system
CN108712363A (en) * 2018-03-22 2018-10-26 新华三信息安全技术有限公司 A kind of daily record encipher-decipher method
CN108833091A (en) * 2018-05-28 2018-11-16 武汉斗鱼网络科技有限公司 A kind of encryption method of journal file, decryption method and device
CN109063011A (en) * 2018-07-11 2018-12-21 Oppo(重庆)智能科技有限公司 Log processing method, electronic device and computer readable storage medium
CN110737910A (en) * 2019-10-16 2020-01-31 福州汇思博信息技术有限公司 Android log decryption management method, device, equipment and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103561045A (en) * 2013-11-21 2014-02-05 北京网秦天下科技有限公司 Safety monitoring system and method for Android system
CN108712363A (en) * 2018-03-22 2018-10-26 新华三信息安全技术有限公司 A kind of daily record encipher-decipher method
CN108833091A (en) * 2018-05-28 2018-11-16 武汉斗鱼网络科技有限公司 A kind of encryption method of journal file, decryption method and device
CN109063011A (en) * 2018-07-11 2018-12-21 Oppo(重庆)智能科技有限公司 Log processing method, electronic device and computer readable storage medium
CN110737910A (en) * 2019-10-16 2020-01-31 福州汇思博信息技术有限公司 Android log decryption management method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN107659632B (en) File encryption and decryption method and device and computer readable storage medium
US10440111B2 (en) Application execution program, application execution method, and information processing terminal device that executes application
WO2016173264A1 (en) Electronic data protection method and device, and terminal device
CN111475824B (en) Data access method, device, equipment and storage medium
US8621189B2 (en) System and method for hardware strengthened passwords
CN112287372B (en) Method and apparatus for protecting clipboard privacy
CN111917540B (en) Data encryption and decryption method and device, mobile terminal and storage medium
CN111897786B (en) Log reading method, device, computer equipment and storage medium
JP2008187608A (en) Data transmission system
CN103294961A (en) Method and device for file encrypting/decrypting
CN111475524B (en) Data processing method and device based on interceptor and computer equipment
WO2022083324A1 (en) Message encryption method and device, message decryption method and device, and mobile terminal
CN107516045A (en) Document protection method and device
US20210034763A1 (en) Splitting Sensitive Data and Storing Split Sensitive Data in Different Application Environments
CN113572743A (en) Data encryption and decryption method and device, computer equipment and storage medium
CN108229190B (en) Transparent encryption and decryption control method, device, program, storage medium and electronic equipment
CN106203141A (en) The data processing method of a kind of application and device
CN115795538A (en) Desensitization document anti-desensitization method, apparatus, computer device and storage medium
JP2006285697A (en) File management method and file management system
CN103605927A (en) Encryption and decryption method based on embedded Linux system
EP2469441A1 (en) System and method for hardware strenghtened passwords
CN110807200A (en) Log encryption method, system, device and medium for Android device
CN110769414A (en) Log encryption method, system, device and medium for Android device
CN110737910B (en) Android log decryption management method, device, equipment and medium
CN114448722A (en) Cross-browser login method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20200218

WD01 Invention patent application deemed withdrawn after publication