-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from gdesmar/terminal_block
Adding support for Unknown Extra block and appended data after Terminal block
- Loading branch information
Showing
11 changed files
with
169 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
class LnkParserError(Exception): | ||
... | ||
class LnkParserError(Exception): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import hashlib | ||
from LnkParse3.extra.lnk_extra_base import LnkExtraBase | ||
|
||
""" | ||
TerminalBlock (4 bytes): A 32-bit, unsigned integer that indicates the end of the extra data section. | ||
This value MUST be less than 0x00000004. | ||
No data should be expected or found after the terminal block, but in the rare case where it | ||
does, this class will fulfill the undocumented feature of keeping track of it. | ||
This can be the case with malicious shortcut files trying to hide their payload. | ||
------------------------------------------------------------------ | ||
| 0-7b | 8-15b | 16-23b | 24-31b | | ||
------------------------------------------------------------------ | ||
| <u_int32> BlockSignature == 0x00000000 - 0x00000003 | | ||
------------------------------------------------------------------ | ||
| appended data | | ||
------------------------------------------------------------------ | ||
""" | ||
|
||
|
||
class Terminal(LnkExtraBase): | ||
def name(self): | ||
return "TERMINAL_BLOCK" | ||
|
||
def appended_data(self): | ||
start = 4 | ||
return self._raw[start:] | ||
|
||
# Overwrite the usual size with the real appended data length | ||
def size(self): | ||
return 4 + len(self.appended_data()) | ||
|
||
def as_dict(self): | ||
tmp = super().as_dict() | ||
tmp["appended_data_sha256"] = hashlib.sha256(self.appended_data()).hexdigest() | ||
return tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import hashlib | ||
from LnkParse3.extra.lnk_extra_base import LnkExtraBase | ||
|
||
""" | ||
This class does not represent a specific extra block defined in the [MS-SHLLINK] documentation. | ||
It aims to cover cases where malicious shortcut files tries to hide their payload in an | ||
undocumented block that still uses the right format and a valid length. | ||
""" | ||
|
||
|
||
class Unknown(LnkExtraBase): | ||
def name(self): | ||
return "UNKNOWN_BLOCK" | ||
|
||
def extra_data(self): | ||
start = 4 | ||
return self._raw[start:] | ||
|
||
def as_dict(self): | ||
tmp = super().as_dict() | ||
tmp["extra_data_sha256"] = hashlib.sha256(self.extra_data()).hexdigest() | ||
return tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
{"shortcut_target": ".\\a.txt"} | ||
{ | ||
"shortcut_target": ".\\a.txt" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Windows Shortcut Information: | ||
Header Size: 76 | ||
Link CLSID: 00021401-0000-0000-C000-000000000046 | ||
Link Flags: HasTargetIDList | IsUnicode - (129) | ||
File Flags: - (0) | ||
|
||
Creation Timestamp: 2012-08-06 11:51:14.390625+00:00 | ||
Modified Timestamp: 2012-08-06 11:51:14.390625+00:00 | ||
Accessed Timestamp: 2012-08-06 11:51:14.390625+00:00 | ||
|
||
File Size: 0 (r: 68608) | ||
Icon Index: 0 | ||
Window Style: SW_SHOWNORMAL | ||
HotKey: UNSET - UNSET {0x0000} | ||
Reserved0: 0 | ||
Reserved1: 0 | ||
Reserved2: 0 | ||
|
||
TARGETS: | ||
Size: 877 | ||
Index: 78 | ||
ITEMS: | ||
Volume Item | ||
Flags: 0xe | ||
Data: None | ||
Unknown | ||
|
||
DATA | ||
|
||
EXTRA BLOCKS: | ||
TERMINAL_BLOCK | ||
Size: 67653 | ||
Appended data sha256: d64c62e65398d37cd27e11fd729fa102016a05ba67f5020e17dfbd3b857dd96e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters